Reputation: 1569
import boto
import boto.s3
import boto.s3.connection
conn = boto.s3.connect_to_region(
'us-west-2',
aws_access_key_id='MY_KEY',
aws_secret_access_key='MY_ACCESS_KEY'
)
conn.create_bucket('bucket_in_west')
And I get this error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/user/.virtualenvs/west-tests/lib/python2.7/site-packages/boto/s3/connection.py", line 621, in create_bucket
response.status, response.reason, body)
S3ResponseError: S3ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>IllegalLocationConstraintException</Code><Message>The unspecified location constraint is incompatible for the region specific endpoint this request was sent to.</Message><RequestId>0C0F09FBC87
Does anybody have an answer for how to create an S3 bucket in a specific region with boto?
Upvotes: 0
Views: 1831
Reputation: 45846
If you are talking to the us-west-2
endpoint and you want to create a bucket in that region, you have to specify that when you call create_bucket
:
conn.create_bucket('bucket-in-west', location='us-west-2')
Upvotes: 2