Permalink
Browse files

Merge pull request #21 from aral/s3-static-site-cloudfront-invalidation

Added S3 static site support for Amazon CloudFront invalidation on sync.
  • Loading branch information...
2 parents add5f2b + 6eacb08 commit 23d133a2f715dc684b31604ce2d4525ebd50213c @mludvig mludvig committed Feb 22, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 S3/CloudFront.py
View
10 S3/CloudFront.py
@@ -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 23d133a

Please sign in to comment.