Permalink
Browse files

Added S3 static site support for Amazon CloudFront invalidation on sync.

  • Loading branch information...
1 parent 1bc3cd0 commit 6eacb08150fc1dd57f792af72d664f7ce34df320 @aral committed Jan 15, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 S3/CloudFront.py
View
@@ -555,8 +555,16 @@ def get_dist_name_for_bucket(self, uri):
for d in response['dist_list'].dist_summs:
if d.info.has_key("S3Origin"):
CloudFront.dist_list[getBucketFromHostname(d.info['S3Origin']['DNSName'])[0]] = d.uri()
+ elif d.info.has_key("CustomOrigin"):
+ # Aral: This used to skip over distributions with CustomOrigin, however, we mustn't
+ # do this since S3 buckets that are set up as websites use custom origins.
+ # Thankfully, the custom origin URLs they use start with the URL of the
+ # S3 bucket. Here, we make use this naming convention to support this use case.
+ distListIndex = getBucketFromHostname(d.info['CustomOrigin']['DNSName'])[0];
+ distListIndex = distListIndex[:len(uri.bucket())]
+ CloudFront.dist_list[distListIndex] = d.uri()
else:
- # Skip over distributions with CustomOrigin
+ # Aral: I'm not sure when this condition will be reached, but keeping it in there.
continue
debug("dist_list: %s" % CloudFront.dist_list)
try:

0 comments on commit 6eacb08

Please sign in to comment.