Aws-cli: s3api can't handle region correctly

Created on 16 Dec 2017  路  8Comments  路  Source: aws/aws-cli

aws s3api create-bucket can't create bucket in correct region. actually, the command fails all the time. the error message:

An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.

the cli version:
aws-cli/1.14.11 Python/2.7.12 Linux/4.9.58-18.55.amzn1.x86_64 botocore/1.8.15

cli-skeleton output:

[ec2-user@ip-10-113-0-23 ~]$ aws s3api create-bucket --bucket lxd-k8s-local-state-store --region cn-northwest-1 --generate-cli-skeleton
{
    "ACL": "public-read", 
    "Bucket": "", 
    "CreateBucketConfiguration": {
        "LocationConstraint": "ap-southeast-1"
    }, 
    "GrantFullControl": "", 
    "GrantRead": "", 
    "GrantReadACP": "", 
    "GrantWrite": "", 
    "GrantWriteACP": ""
}
[ec2-user@ip-10-113-0-23 ~]$ aws s3api create-bucket --bucket lxd-k8s-local-state-store --region cn-north-1 --generate-cli-skeleton
{
    "ACL": "private", 
    "Bucket": "", 
    "CreateBucketConfiguration": {
        "LocationConstraint": "ap-southeast-2"
    }, 
    "GrantFullControl": "", 
    "GrantRead": "", 
    "GrantReadACP": "", 
    "GrantWrite": "", 
    "GrantWriteACP": ""
}
[ec2-user@ip-10-113-0-23 ~]$ aws s3api create-bucket --bucket lxd-k8s-local-state-store --region us-east-1 --generate-cli-skeleton
{
    "ACL": "public-read", 
    "Bucket": "", 
    "CreateBucketConfiguration": {
        "LocationConstraint": "eu-central-1"
    }, 
    "GrantFullControl": "", 
    "GrantRead": "", 
    "GrantReadACP": "", 
    "GrantWrite": "", 
    "GrantWriteACP": ""
}
[ec2-user@ip-10-113-0-23 ~]$ aws s3api create-bucket --bucket lxd-k8s-local-state-store --region us-east-2 --generate-cli-skeleton
{
    "ACL": "authenticated-read", 
    "Bucket": "", 
    "CreateBucketConfiguration": {
        "LocationConstraint": "cn-north-1"
    }, 
    "GrantFullControl": "", 
    "GrantRead": "", 
    "GrantReadACP": "", 
    "GrantWrite": "", 
    "GrantWriteACP": ""
}
closing-soon guidance s3 s3api

All 8 comments

Can you provide debug logs for the command that is failing?

This is explained in the docs
https://docs.aws.amazon.com/cli/latest/reference/s3api/create-bucket.html#examples

Closing due to inactivity.

same thing happen for me too. i specified region as us-east-1, and couldn't even find the bucket nowhere.

aws s3api create-bucket --bucket tests-devops-test --region us-east-1 --generate-cli-skeleton

{
"ACL": "public-read",
"Bucket": "",
"CreateBucketConfiguration": {
"LocationConstraint": "eu-west-1"
},
"GrantFullControl": "",
"GrantRead": "",
"GrantReadACP": "",
"GrantWrite": "",
"GrantWriteACP": ""
}

$ aws --version
aws-cli/1.16.10 Python/3.7.0 Darwin/15.6.0 botocore/1.12.0

the following doesnt work for me:

aws s3 mb s3://avengers-docker-eb

make_bucket failed: s3://avengers-docker-eb An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
$ aws s3api create-bucket --bucket avengers-docker-eb --region us-east-1

An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.
aws s3api create-bucket --bucket avengers-docker-eb --region us-east-1 --create-bucket-configuration LocationConstraint=us-east-1

An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The us-east-1 location constraint is incompatible for the region specific endpoint this request was sent to.

from the logs i see:

The authorization header is malformed; the region \'us-east-1\' is wrong; expecting \'eu-west-3\'

can i provide you the entire --debug output or is that info confidential?

what works is when i set a different name:

$ aws s3 mb s3://avengers-docker-eb-1
make_bucket: avengers-docker-eb-1

@stealthycoin could you re-open the issue?

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@Arnold1 and @ykzj - I have reproduced this behavior under a similar issue and reopened this issue to provide some clarification and guidance in regards to the following error:

An error occurred (IllegalLocationConstraintException) when calling the CreateBucket operation: The us-east-1 location constraint

As per our documentation for regions and endpoints for s3:

Amazon S3 renamed the US Standard Region to the US East (N. Virginia) Region to be consistent with AWS regional naming conventions. There is no change to the endpoint and you do not need to make any changes to your application.

If you use a region other than the US East (N. Virginia) endpoint to create a bucket, you must set the LocationConstraint bucket parameter to the same region. Both the AWS SDK for Java and AWS SDK for .NET use an enumeration for setting location constraints (Region for Java, S3Region for .NET). For more information, see PUT Bucket in the Amazon Simple Storage Service API Reference.

As such, the location constraint error occurs when the bucket was created or located in a region other than the default region (us-east-1). If you send your create bucket request to the s3.amazonaws.com endpoint, the request go to the us-east-1 region.. Basically, the location constraint is not a required parameter when using us-east-1 but is required when using other regions. An example:

aws s3api create-bucket --bucket mybucket --create-bucket-configuration LocationConstraint=us-west-2

Another option is use s3 mb which using the global options --region and --endpoint-url to redirect the request:

aws s3 mb s3://mybucket --region us-west-2 --endpoint-url https://s3.us-west-2.amazonaws.com

It appears our documentation and examples require some improvement around this topic so I have escalated this issue internally to our documentation writers.

Related issues: #3567 #3510 #2603 #3723 #3044 #2138 #589 #90

Was this page helpful?
0 / 5 - 0 ratings