Created
December 21, 2015 13:16
-
-
Save martyzz1/71c8c487a067e1eec31d to your computer and use it in GitHub Desktop.
How to connect to None US S3 using Boto2, for CNAME'd subdomain buckets - useful if you get S3ResponseError: S3ResponseError: 301 Moved Permanently or CertificateError: hostname 'sub.primarydomain.com.s3.amazonaws.com' doesn't match either of '*.s3.amazonaws.com', 's3.amazonaws.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conn = boto.s3.connect_to_region( | |
'eu-west-1', | |
aws_access_key_id=<AWS_ACCESS_KEY_ID>, | |
aws_secret_access_key=<AWS_SECRET_ACCESS_KEY>, | |
calling_format=ProtocolIndependentOrdinaryCallingFormat() | |
) | |
bucket = conn.get_bucket('sub.primarydomain.com') | |
prefix = 'some/prefix/' | |
rs = bucket.list(prefix=prefix) | |
for key in rs: | |
print key.name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment