-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Describe the bug
Given an s3 bucket in eu-west-1
, when setting AWS_REGION=eu-west-1
and AWS_ENDPOINT_URL=https://s3.amazonaws.com
env vars and issuing an aws s3 ls s3://bucketname/some/path/to/object
, it will give you the following error message:
An error occurred (PermanentRedirect) when calling the ListObjectsV2 operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: bucketname.s3.amazonaws.com
You can fix this issue by explicitly 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".
It is right that it gives the error, as the endpoint should either be unset, or set to the region-specific s3.eu-west-1.amazonaws.com
endpoint. The endpoint which is suggested in the error message is however wrong, and will result in NotFound errors.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
The error message should either give a link to how/where to find the correct endpoint, or it should give the correct endpoint. Giving a non-functional endpoint is a bug to me.
Current Behavior
See the output in the above snippet
Reproduction Steps
Create a new bucket in non us-east-1, make sure you have access to it, and then:
bash-5.1$ set | grep AWS
AWS_ENDPOINT_URL=https://s3.amazonaws.com
AWS_REGION=eu-west-1
AWS_SHARED_CREDENTIALS_FILE=/tmp/aws-credfile
_=AWS_ENDPOINT_URL=https://s3.amazonaws.com
bash-5.1$ aws s3 ls s3://[BUCKET-REDACTED]/some/path/ --summarize
An error occurred (PermanentRedirect) when calling the ListObjectsV2 operation: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint: [BUCKET-REDACTED].s3.amazonaws.com
You can fix this issue by explicitly 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".
bash-5.1$ export AWS_ENDPOINT_URL="https://[BUCKET-REDACTED].s3.amazonaws.com"
bash-5.1$ aws s3 ls s3://[BUCKET-REDACTED]/some/path/ --summarize
An error occurred (NoSuchKey) when calling the ListObjectsV2 operation: The specified key does not exist.
bash-5.1$ unset AWS_ENDPOINT_URL
bash-5.1$ aws s3 ls s3://[BUCKET_REDACTED]/some/path/ --summarize
Total Objects: 0
Total Size: 0
(it also works when setting the correct endpoint s3.eu-west-1.amazonaws.com
)
Possible Solution
Change the error message.
Additional Information/Context
No response
CLI version used
latest
Environment details (OS name and version, etc.)
ubuntu docker container, latest, amd64