Created
November 7, 2014 22:10
-
-
Save teknogeek0/35354d56eab84e3ac778 to your computer and use it in GitHub Desktop.
For Re:Invent 2014, Deployment Automation talk - ELB to S3 Website "Fail Whale" failover CloudFormation template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AWSTemplateFormatVersion" : "2010-09-09", | |
"Description" : "Create a Route53 Fail Whale failover setup from ELB to S3. You need a preexisting ELB, S3 bucket configured as a Website endpoint, and Hosted Zone.", | |
"Parameters" : { | |
"ELBDnsName" : { | |
"Type" : "String", | |
"Description" : "Your ELB's DNS Name" | |
}, | |
"ELBHostedZoneID" : { | |
"Type" : "String", | |
"Description" : "Your ELB's Hosted Zone ID" | |
}, | |
"HostedZoneName" : { | |
"Type" : "String", | |
"Description" : "Your Hosted zone's name. Should end with a period after the TLD." | |
}, | |
"DNSRecordName" : { | |
"Type" : "String", | |
"Description" : "The name of the DNS record to do failover for. NOTE: Your S3 bucket name must match this. Should end with a period after the TLD." | |
}, | |
"S3BucketRegion" : { | |
"Type" : "String", | |
"Description" : "The S3 API region that your bucket lives in. US-Standard is us-east-1.", | |
"AllowedValues": [ | |
"us-east-1", | |
"us-west-1", | |
"us-west-2", | |
"eu-west-1", | |
"eu-central-1", | |
"ap-southeast-1", | |
"ap-southeast-2", | |
"ap-northeast-1", | |
"sa-east-1" | |
], | |
"ConstraintDescription": "Must be a valid S3 API region." | |
} | |
}, | |
"Mappings" : { | |
"S3RegionWebEndpoints": { | |
"us-east-1": { | |
"DNSEndpoint": "s3-website-us-east-1.amazonaws.com", | |
"HostedZoneId": "Z3AQBSTGFYJSTF" | |
}, | |
"us-west-1": { | |
"DNSEndpoint": "s3-website-us-west-1.amazonaws.com", | |
"HostedZoneId": "Z2F56UZL2M1ACD" | |
}, | |
"us-west-2": { | |
"DNSEndpoint": "s3-website-us-west-2.amazonaws.com", | |
"HostedZoneId": "Z3BJ6K6RIION7M" | |
}, | |
"eu-west-1": { | |
"DNSEndpoint": "s3-website-eu-west-1.amazonaws.com", | |
"HostedZoneId": "Z1BKCTXD74EZPE" | |
}, | |
"eu-central-1": { | |
"DNSEndpoint": "s3-website.eu-central-1.amazonaws.com", | |
"HostedZoneId": "Z21DNDUVLTQW6Q" | |
}, | |
"ap-southeast-1": { | |
"DNSEndpoint": "s3-website-ap-southeast-1.amazonaws.com", | |
"HostedZoneId": "Z3O0J2DXBE1FTB" | |
}, | |
"ap-southeast-2": { | |
"DNSEndpoint": "s3-website-ap-southeast-2.amazonaws.com", | |
"HostedZoneId": "Z1WCIGYICN2BYD" | |
}, | |
"ap-northeast-1": { | |
"DNSEndpoint": "s3-website-ap-northeast-1.amazonaws.com", | |
"HostedZoneId": "Z2M4EHUR26P7ZW" | |
}, | |
"sa-east-1": { | |
"DNSEndpoint": "s3-website-sa-east-1.amazonaws.com", | |
"HostedZoneId": " Z7KQH4QJS55SO" | |
} | |
} | |
}, | |
"Resources" : { | |
"myMainSite" : { | |
"Type" : "AWS::Route53::RecordSetGroup", | |
"Properties" : { | |
"HostedZoneName" : {"Ref" : "HostedZoneName"}, | |
"Comment" : "Main site with fail whale.", | |
"RecordSets" : [ | |
{ | |
"Name" : {"Ref" : "DNSRecordName"}, | |
"Type" : "A", | |
"SetIdentifier": "Primary", | |
"Failover": "PRIMARY", | |
"AliasTarget" : { | |
"HostedZoneId" : {"Ref" : "ELBHostedZoneID"}, | |
"DNSName" : {"Ref" : "ELBDnsName"}, | |
"EvaluateTargetHealth" : "True" | |
} | |
}, | |
{ | |
"Name": {"Ref" : "DNSRecordName"}, | |
"Type": "A", | |
"SetIdentifier" : "Secondary", | |
"Failover": "SECONDARY", | |
"AliasTarget": { | |
"HostedZoneId": { "Fn::FindInMap" : [ "S3RegionWebEndpoints", { "Ref" : "S3BucketRegion" }, "HostedZoneId" ]}, | |
"EvaluateTargetHealth": "False", | |
"DNSName": { "Fn::FindInMap" : [ "S3RegionWebEndpoints", { "Ref" : "S3BucketRegion" }, "DNSEndpoint" ]} | |
} | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment