Added S3 static site support for Amazon CloudFront invalidation on sync.
Michal Ludvig authored on 2012/02/23 06:30:53... | ... |
@@ -555,8 +555,16 @@ class CloudFront(object): |
555 | 555 |
for d in response['dist_list'].dist_summs: |
556 | 556 |
if d.info.has_key("S3Origin"): |
557 | 557 |
CloudFront.dist_list[getBucketFromHostname(d.info['S3Origin']['DNSName'])[0]] = d.uri() |
558 |
+ elif d.info.has_key("CustomOrigin"): |
|
559 |
+ # Aral: This used to skip over distributions with CustomOrigin, however, we mustn't |
|
560 |
+ # do this since S3 buckets that are set up as websites use custom origins. |
|
561 |
+ # Thankfully, the custom origin URLs they use start with the URL of the |
|
562 |
+ # S3 bucket. Here, we make use this naming convention to support this use case. |
|
563 |
+ distListIndex = getBucketFromHostname(d.info['CustomOrigin']['DNSName'])[0]; |
|
564 |
+ distListIndex = distListIndex[:len(uri.bucket())] |
|
565 |
+ CloudFront.dist_list[distListIndex] = d.uri() |
|
558 | 566 |
else: |
559 |
- # Skip over distributions with CustomOrigin |
|
567 |
+ # Aral: I'm not sure when this condition will be reached, but keeping it in there. |
|
560 | 568 |
continue |
561 | 569 |
debug("dist_list: %s" % CloudFront.dist_list) |
562 | 570 |
try: |