Skip to content

Instantly share code, notes, and snippets.

@harperreed
Created January 14, 2011 21:46
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save harperreed/780318 to your computer and use it in GitHub Desktop.
creates a custom origin for cloudfront. EASY CDN!
import boto
# requires cf_customorigin branch
# https://github.com/boto/boto/tree/cf_customorigin
origin_domain = 'www.example.org'
cdn_cname = ['media.example.org']
caller_reference = 'exmaple Distribution'
c = boto.connect_cloudfront()
d = c.create_custom_distribution(
dns_name=origin_domain,
enabled=True,
caller_reference=caller_reference,
cnames=cdn_cname
)
print 'cname '+ cdn_cname + ' to ' d.domain_name
import datetime
from boto.cloudfront import CloudFrontConnection
AWS_CF_DISTRIBUTION_ID = 'LKJHSADLIUYWE(*&QW(E*'
files = ['/css/style.css','/filename/otherfile.name' ]
conn = CloudFrontConnection()
print conn.create_invalidation_request(AWS_CF_DISTRIBUTION_ID, files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment