user3066737
user3066737

Reputation: 143

aws command line works but cannot get boto equivilent

I have a bucket with a subfolder ABC. The ACL has been set so my given access keys can only upload to the subfolder ABC

The following command line works

aws s3 cp local-file-name s3://my-bucket/ABC/

I'm trying to do the equivalent from boto

conn = S3Connection(access_key, secret_access_key)
b = conn.get_bucket('my-bucket')
k = Key(b)
k.key = 'ABC/Hello'
k.set_contents_from_string("Hello World")
print (k.get_contents_from_string())

boto.exception.S3ResponseError: S3ResponseError: 403 Forbidden

I know this is ACL related as when I swap the keys to a set with full access It works.

So why with the restricted keys the command line will work but boto will not ?

Do I need to give the restricted keys list access to the bucket ?

Upvotes: 3

Views: 740

Answers (1)

garnaat
garnaat

Reputation: 45916

By default, boto tries to validate the bucket by performing a HEAD request during the get_bucket call. That will fail for your scenario so tell boto to skip this validation step:

b = conn.get_bucket('my-bucket', validate=False)

Upvotes: 1

Related Questions