Tuesday, May 5, 2015

PermanentRedirect when accessing AWS S3 bucket

When running this on the command-line:
aws s3 ls s3://my-bucket/
I kept getting this error:
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.
The problem was that my region wasn't set. I did this to fix it:
export AWS_DEFAULT_REGION=us-west-2
This is a pretty stupid situation: when using the web console, the S3 service says that there's no need to choose a region, and it won't even let you select one. But obviously it's very important for configurations. Dumb.