-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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. |
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 --region eu-west-1 $ aws s3 sync s3://my.eu.bucket s3://my.us.bucket --region us-west-2 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 |
The error message now includes a note on specifying the
correct region:
Same thing when you try to access a bucket in eu-central-1.
cc @danielgtaylor @kyleknap