Skip to content

Instantly share code, notes, and snippets.

@peplin
Created September 15, 2010 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peplin/580833 to your computer and use it in GitHub Desktop.
Save peplin/580833 to your computer and use it in GitHub Desktop.
Set the default root object on a CloudFront distribution.
""" Need to serve some static HTML files, but can't use S3 because it won't
resolve index.html for you? Grab a CloudFront distribution from Amazon, point it
to your bucket, and set your index.html as the "default root object".
This code snippet uses the boto (http://code.google.com/p/boto/) Python package
to set the default root object on your distribution.
Christopher Peplin, chris.peplin@rhubarbtech.com
"""
from boto.cloudfront import CloudFrontConnection
c = CloudFrontConnection('YOUR_ACCESS_KEY', 'YOUR_SECRET_KEY')
c.get_all_distributions()
# Assuming you only have on distribution, otherwise find yours in the list
d = c.get_all_distributions()[0]
i = d.get_distribution()
i.config.default_root_object = "index.html"
i.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment