Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for sigv4 and PermanentRedirect errors #968

Merged
merged 1 commit into from
Oct 24, 2014

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Oct 24, 2014

The error message now includes a note on specifying the
correct region:

 $ aws s3api list-objects --bucket wrong.region.bucket

 A client error (PermanentRedirect) occurred when calling the ListObjects operation:

 The bucket you are attempting to access must be addressed using the specified
 endpoint. Please send all future requests to this endpoint:
 wrong.region.bucket.s3-ap-southeast-2.amazonaws.com
 You can fix this issue by explicity providing the correct region location
 using the --region argument, the AWS_DEFAULT_REGION environment variable, or
 the region variable in the AWS CLI configuration file.  You can get the
 bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".

Same thing when you try to access a bucket in eu-central-1.

cc @danielgtaylor @kyleknap

The error message now includes a note on specifying the
correct region:

 $ aws s3api list-objects --bucket wrong.region.bucket

 A client error (PermanentRedirect) occurred when calling the ListObjects operation:

 The bucket you are attempting to access must be addressed using the specified
 endpoint. Please send all future requests to this endpoint:
 wrong.region.bucket.s3-ap-southeast-2.amazonaws.com
 You can fix this issue by explicity providing the correct region location
 using the --region argument, the AWS_DEFAULT_REGION environment variable, or
 the region variable in the AWS CLI configuration file.  You can get the
 bucket's location by running "aws s3api get-bucket-location --bucket BUCKET".

Same thing when you try to access a bucket in eu-central-1.
elif _is_permanent_redirect_message(parsed):
endpoint = parsed['Error']['Endpoint']
message = parsed['Error']['Message']
new_message = message[:-1] + ': %s\n' % endpoint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the endpoint be the full name of the endpoint or will it be the name of the region? I could see this being confusing if it gives back the full name of the endpoint. But should be ok if the user just uses the get-bucket-location command.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, it will be the full point, something like, bucket.s3-us-west-2.amazonaws.com which could be confusing. I initially had an additional function that tried to parse the region name from the endpoint, but I was hesitant to add it because it is subject to change and we may not be able to always guarantee we can reliably get the region name. Do you think it's worth adding that logic to try to print the required region name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think later down the road if there are more requests. Always printing out the suggestion to run the get-bucket-location command should help out a good amount.

@kyleknap
Copy link
Contributor

It looks good. 🚢 It may be worth while in the future to inform the user what region they used when they ran their command. If it is a redirect, we could potentially reverse-map the endpoint to abstract the region name. I am not sure how we would handle error messages that do not contain info on the endpoint that request was sent to.

@jamesls jamesls merged commit 44f3b0f into aws:develop Oct 24, 2014
@bosmanx
Copy link

bosmanx commented Nov 1, 2014

It gets complicated if you copy between buckets:

$ aws configure set region us-east-1
$ aws s3 sync s3://my.eu.bucket s3://my.us.bucket
A client error (PermanentRedirect) [...] to this endpoint: my.eu.bucket.s3.amazonaws.com
You can fix this issue by explicity providing the correct region location using the --region argument ...

$ aws s3 sync s3://my.eu.bucket s3://my.us.bucket --region eu-west-1
A client error (PermanentRedirect) [...] to this endpoint: my.us.bucket.s3-us-west-2.amazonaws.com
You can fix this issue by explicity providing the correct region location using the --region argument ...

$ aws s3 sync s3://my.eu.bucket s3://my.us.bucket --region us-west-2
A client error (PermanentRedirect) [...] to this endpoint: my.eu.bucket.s3-eu-west-1.amazonaws.com
You can fix this issue by explicity providing the correct region location using the --region argument ...

With 2 DNS incompatible buckets you have to use --source-region:

$ aws s3 sync s3://my.eu.bucket s3://my.us.bucket --source-region eu-west-1 --region us-west-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants