Reputation: 78234
Why do I get this error with s3 and boto?
<Error><Code>BucketAlreadyOwnedByYou</Code><Message>Your previous request to create the named bucket succeeded and you already own it.</Message><BucketName>rtbhui</BucketName><RequestId>84115D3E9513F3C9</RequestId><HostId>+3TxrA34xHcSx0ecOD3pseRnE+LwUv3Ax1Pvp3PFoE8tHfOcn5BXyihc9V/oJx2g</HostId></Error>
s3 = boto.connect_s3(parms['AWS_ACCESS_KEY_ID'], parms['AWS_SECRET_ACCESS_KEY'])
bucket = s3.create_bucket(bucket_name)
k = Key(bucket) #bucket is global
k.key = bucket_path_and_key #'test/test/test'
Upvotes: 4
Views: 9102
Reputation: 141
BucketAlreadyOwnedByYou
errors will only be returned outside of the US Standard region. Inside the US Standard region (i.e. when you don't specify a location constraint), attempting to recreate a bucket you already own will succeed.
Source http://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
Upvotes: 6
Reputation: 29
Since you already have a bucket you can just delete the last three lines of code and replace them with something like:
bucket = conn.get_bucket(bucket, validate = False)
k = Key(bucket)
k.key = key
Upvotes: 0