-
Notifications
You must be signed in to change notification settings - Fork 1
/
standby-region-infra.yml
87 lines (82 loc) · 2.76 KB
/
standby-region-infra.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
ACMCertArn:
Type: String
Description: This is the ACM arn
SiteURL:
Type: String
Description: This is the URL of the site
ZoneName:
Type: String
Description: This is the ZoneName of the SiteURL
USEast1Bucket:
Type: String
Outputs:
StandbyHealthCheckId:
Description: "Physical ID of healthcheck"
Value: !Ref StandbyHealthCheck
StandbyReplBucketArn:
Description: "Full S3 Bucket Arn"
Value: !Join [ "", [ 'arn:aws:s3:::' , !Ref StandbyReplicationBucket ] ]
CloudFrontDistributionDomainName:
Description: Domain Name
Value: !GetAtt StandbyCloudFrontDistribution.DomainName
CloudFrontDistributionID:
Description: CF ID
Value: !Ref StandbyCloudFrontDistribution
Route53StackName:
Description: Nested Stack Name
Value: !GetAtt Route53Stack.Outputs.StackName
Resources:
StandbyReplicationBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
VersioningConfiguration:
Status: Enabled
WebsiteConfiguration:
IndexDocument: "index.html"
StandbyHealthCheck:
Type: "AWS::Route53::HealthCheck"
Properties:
HealthCheckConfig:
FullyQualifiedDomainName: !Join [ '.', [ !Join [ '-', [ "s3", !Ref "AWS::Region" ] ], "amazonaws.com" ] ]
Type: "HTTP"
ResourcePath: !Join [ '/', [ '', !Ref 'StandbyReplicationBucket', 'index.html' ] ]
FailureThreshold: 1
HealthCheckTags:
- Key: "Name"
Value: !Sub "StandbyBucket - ${SiteURL}"
StandbyCloudFrontDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Aliases:
- !Ref SiteURL
Comment: StandbyCloudFrontDistribution
DefaultCacheBehavior:
ForwardedValues:
QueryString: false
TargetOriginId: StandbyBucketOrigin
ViewerProtocolPolicy: redirect-to-https
DefaultRootObject: index.html
Enabled: true
HttpVersion: http2
Origins:
# Use the WebsiteURL /but/ use the part after '//'
- DomainName: !Select [ "1" , "Fn::Split": [ "//", "Fn::GetAtt": [ StandbyReplicationBucket, WebsiteURL ] ] ]
Id: StandbyBucketOrigin
CustomOriginConfig:
OriginProtocolPolicy: "http-only"
PriceClass: PriceClass_100
ViewerCertificate:
AcmCertificateArn: !Ref ACMCertArn
SslSupportMethod: sni-only
Route53Stack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: !Join ['', [ "https://s3.amazonaws.com/", !Ref 'USEast1Bucket', '/nested-route53.yml' ] ]
Parameters:
ZoneName: !Ref ZoneName
SiteURL: !Ref SiteURL
AliasTargetDNSName: !GetAtt StandbyCloudFrontDistribution.DomainName