Skip to content

Commit

Permalink
Added S3 static site support for Amazon CloudFront invalidation on sync.
Browse files Browse the repository at this point in the history
  • Loading branch information
aral committed Jan 15, 2012
1 parent 1bc3cd0 commit 6eacb08
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion S3/CloudFront.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 6eacb08

Please sign in to comment.