Downloading private files from Spaces CDN using boto3

I just enabled CDN access for my Spaces and was previously using the following to download private objects from the buckets using boto3:

S3_REGION = 'sfo2'
S3_BUCKET = 'mybucket'


amzn_s3 = boto3.resource('s3', \
                        region_name=S3_REGION, \
                        endpoint_url=S3_ENDPOINT, \
                        aws_access_key_id=AWS_ACCESS_KEY_ID, \
bucket = amzn_s3.Bucket(S3_BUCKET)
bucket.download_file('remote_file.tar.gz', 'local_file.tar.gz')

How do I pull private objects from CDN? I’ve tried a bunch of variations of S3_REGION and S3_ENDPOINT but can’t seem to make any progress.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer