Amazon Web Services S3 via Command Line

By | August 6, 2014

Amazon Web Services (AWS) has a nice Command Line Interface, allowing script or command line access to quite a wide range of capabilities. I recently attempted to use this with the Simple Storage Service (S3), but was frustrated with a repeated error message in response to a simple directory request on a bucket.

jeff@mars:~$aws s3 ls s3://MyBucket
A client error (PermanentRedirect) occurred when calling the ListObjects operation: The bucket you are attempting to access must be addressed using the specified endpoint look these up. Please send all future requests to this endpoint.

Not very helpful. A little research on the web gave me a bit of a clue. The message occurs when the message is directed to the wrong region. Well, I do (or thought I did) all of my work in us-west-2, so my default is there. Turns out I created my buckets in US Standard. Without going into the gory details, what I found was that US Standard S3 objects appear to be located in us-east-1 region. This wasn’t at all obvious, especially since I’d forgotten that I’d created the buckets somewhere other than us-west-2

So, the code that works to get, for example, a directory listing of a bucket named MyBucket looks like this:

aws s3 ls s3://MyBucket --region us-east-1

Hope this helps prevent an hour of so of head-scratching for someone.

Jeff

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.