-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsite.cfn.yaml
182 lines (173 loc) · 5.41 KB
/
website.cfn.yaml
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
Resources:
OriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: !Sub Static assets in ${AWS::StackName}
SharedLogGroup:
Type: AWS::Logs::LogGroup
Properties:
RetentionInDays: 7
LogGroupName: !Join [ '-', [ !Ref 'AWS::StackName', 'LogGroup']]
LogBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: shalerb-logs
AccessControl: LogDeliveryWrite
RedirectBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: shalerb.org
WebsiteConfiguration:
RedirectAllRequestsTo:
HostName: www.shalerb.org
Protocol: https
WebsiteBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: www.shalerb.org
LoggingConfiguration:
DestinationBucketName: !Ref LogBucket
LogFilePrefix: shalerb/s3
WebsiteBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref WebsiteBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- s3:GetObject
Effect: Allow
Resource: !Join
- ''
- - !GetAtt WebsiteBucket.Arn
- /*
Principal:
CanonicalUser: !GetAtt OriginAccessIdentity.S3CanonicalUserId
TLSCertificate:
Type: AWS::CertificateManager::Certificate
Properties:
DomainName: shalerb.org
SubjectAlternativeNames:
- '*.shalerb.org'
DomainValidationOptions:
- DomainName: shalerb.org
HostedZoneId: Z0022488YKPXZNTKN2
ValidationMethod: DNS
RedirectDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
HttpVersion: http2
PriceClass: PriceClass_100
ViewerCertificate:
AcmCertificateArn: !Ref TLSCertificate
MinimumProtocolVersion: TLSv1.1_2016
SslSupportMethod: sni-only
Aliases:
- shalerb.org
DefaultCacheBehavior:
AllowedMethods:
- HEAD
- GET
- OPTIONS
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # CachingOptimized
Compress: true
ViewerProtocolPolicy: redirect-to-https
TargetOriginId: RedirectBucket
Origins:
- Id: RedirectBucket
DomainName: !Select [1, !Split ["//", !GetAtt RedirectBucket.WebsiteURL]]
CustomOriginConfig:
OriginProtocolPolicy: http-only
Distribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Enabled: true
HttpVersion: http2
PriceClass: PriceClass_100
ViewerCertificate:
AcmCertificateArn: !Ref TLSCertificate
MinimumProtocolVersion: TLSv1.1_2016
SslSupportMethod: sni-only
Aliases:
- www.shalerb.org
DefaultRootObject: index.html
DefaultCacheBehavior:
AllowedMethods:
- HEAD
- GET
- OPTIONS
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # CachingOptimized
Compress: true
ViewerProtocolPolicy: redirect-to-https
TargetOriginId: Bucket
CacheBehaviors:
- AllowedMethods:
- GET
- HEAD
CachePolicyId: 658327ea-f89d-4fab-a63d-7e88639e58f6 # CachingOptimized
PathPattern: /js/script.js
ViewerProtocolPolicy: https-only
TargetOriginId: AnalyticsProxy
- AllowedMethods:
- GET
- HEAD
- OPTIONS
- PUT
- PATCH
- POST
- DELETE
CachePolicyId: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad # CachingDisabled
OriginRequestPolicyId: acba4595-bd28-49b8-b9fe-13317c0390fa # UserAgentRefererHeaders
PathPattern: /api/event
ViewerProtocolPolicy: https-only
TargetOriginId: AnalyticsProxy
Origins:
- Id: Bucket
DomainName: !GetAtt WebsiteBucket.DomainName
S3OriginConfig:
OriginAccessIdentity: !Join
- /
- - origin-access-identity
- cloudfront
- !Ref OriginAccessIdentity
- Id: AnalyticsProxy
DomainName: plausible.io
CustomOriginConfig:
OriginProtocolPolicy: https-only
Logging:
Bucket: !Join
- .
- - !Ref LogBucket
- s3
- !Ref AWS::URLSuffix
Prefix: shalerb/web
DNS:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneId: Z0022488YKPXZNTKN2
RecordSets:
- Name: shalerb.org.
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt RedirectDistribution.DomainName
- Name: shalerb.org.
Type: AAAA
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt RedirectDistribution.DomainName
- Name: www.shalerb.org.
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt Distribution.DomainName
- Name: www.shalerb.org.
Type: AAAA
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt Distribution.DomainName