This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cbpp-web.yaml
243 lines (216 loc) · 6.4 KB
/
cbpp-web.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
---
AWSTemplateFormatVersion: 2010-09-09
Description:
S3 Buckets
Parameters:
TLD:
Description: Git repository to retrieve source from
Type: String
Default: crunchbangplusplus.org
CloudFrontHostedZone:
Description: Hosted zone ID for cloudfront
Type: String
Default: Z2FDTNDATAQYW2
CbppHostedZone:
Description: Hosted zone for domain name
Type: String
Default: Z2KOY9F63D3MWH
Resources:
CbppDNSRecord: ## be sure to update registered domain's nameservers
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !Sub ${CbppHostedZone}
Name: !Sub ${TLD}.
Type: A
AliasTarget:
DNSName: !GetAtt Distribution.DomainName
HostedZoneId: !Ref CloudFrontHostedZone
wwwCbppDNSRecord:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneName: !Sub ${TLD}.
Name: !Sub www.${TLD}.
Type: A
AliasTarget:
DNSName: !GetAtt Distribution.DomainName
HostedZoneId: !Ref CloudFrontHostedZone
packagesCbppDNSRecord:
Type: AWS::Route53::RecordSet
Properties:
HostedZoneName: !Sub ${TLD}.
Name: !Sub packages.${TLD}.
Type: A
AliasTarget:
DNSName: !GetAtt Distribution.DomainName
HostedZoneId: !Ref CloudFrontHostedZone
## using route53 hosted zone
#~ CbppHostedZone:
#~ Type: AWS::Route53::HostedZone
#~ Properties:
#~ HostedZoneConfig:
#~ Comment: !Sub 'Hosted zone for ${TLD}'
#~ Name: !Sub ${TLD}
Certificate:
#~ DependsOn:
#~ - CbppHostedZone
Type: AWS::CertificateManager::Certificate
Properties:
DomainName: !Sub ${TLD}
ValidationMethod: DNS
DomainValidationOptions:
- DomainName: !Sub ${TLD}
ValidationDomain: !Sub ${TLD}
SubjectAlternativeNames: ## each san requires dns verification
- !Sub www.${TLD}
- !Sub packages.${TLD}
Distribution:
DependsOn:
- CbppBucket
Type: AWS::CloudFront::Distribution
Properties:
Tags:
- Key: domain
Value: www
DistributionConfig:
Aliases:
- !Sub ${TLD}
- !Sub www.${TLD}
DefaultCacheBehavior:
Compress: true
ForwardedValues:
QueryString: false
TargetOriginId: !Sub ${TLD}
ViewerProtocolPolicy: redirect-to-https
DefaultRootObject: index.html
HttpVersion: http2
Origins:
- DomainName: !Sub ${CbppBucket}.s3.amazonaws.com
Id: !Sub ${TLD}
S3OriginConfig:
OriginAccessIdentity: !Sub origin-access-identity/cloudfront/${CbppOriginAccessIdentity}
Enabled: true
ViewerCertificate:
AcmCertificateArn: !Ref Certificate
SslSupportMethod: sni-only
MinimumProtocolVersion: TLSv1
CbppOriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: !Sub 'CloudFront OAI for ${TLD}'
PackagesDistribution:
DependsOn:
- PackagesCbppBucket
Type: AWS::CloudFront::Distribution
Properties:
Tags:
- Key: domain
Value: packages
DistributionConfig:
Aliases:
- !Sub packages.${TLD}
DefaultCacheBehavior:
Compress: true
ForwardedValues:
QueryString: false
TargetOriginId: !Sub ${TLD}
ViewerProtocolPolicy: allow-all ## backwards compatiblity with old repos
DefaultRootObject: index.html
HttpVersion: http2
Origins:
- DomainName: !Sub packages.${CbppBucket}.s3.amazonaws.com
Id: !Sub ${TLD}
S3OriginConfig:
OriginAccessIdentity: !Sub origin-access-identity/cloudfront/${PackagesCbppOriginAccessIdentity}
Enabled: true
ViewerCertificate:
AcmCertificateArn: !Ref Certificate
SslSupportMethod: sni-only
MinimumProtocolVersion: TLSv1
PackagesCbppOriginAccessIdentity:
Type: AWS::CloudFront::CloudFrontOriginAccessIdentity
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: !Sub 'CloudFront OAI for ${TLD}'
WwwCbppBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: !Sub www.${CbppBucket}
AccessControl: PublicRead
VersioningConfiguration:
Status: Suspended
WebsiteConfiguration:
RedirectAllRequestsTo:
HostName: !Ref CbppBucket
Protocol: https
CbppBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: !Ref TLD
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
AccessControl: PublicRead
VersioningConfiguration:
Status: Suspended
CbppBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref CbppBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource:
- !Sub arn:aws:s3:::${CbppBucket}/*
PackagesCbppBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
Properties:
BucketName: !Sub packages.${TLD}
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
AccessControl: PublicRead
VersioningConfiguration:
Status: Suspended
PackagesCbppBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref PackagesCbppBucket
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource:
- !Sub arn:aws:s3:::${PackagesCbppBucket}/*
Outputs:
CbppBucket:
Value: !Ref CbppBucket
Description: Cbpp Bucket
WwwCbppBucket:
Value: !Ref WwwCbppBucket
Description: WWW Cbpp Bucket
CbppHostedZone:
Value: !Ref CbppHostedZone
Description: Hosted Zone ID
PackagesCbppBucket:
Value: !Ref PackagesCbppBucket
Description: Packages Cbpp Bucket
CbppDistribution:
Value: !Ref Distribution
Description: Cbpp Distribution
PackagesCbppDistribution:
Value: !Ref PackagesDistribution
Description: Packages Cbpp Distribution
PrimaryCertificate:
Value: !Ref Certificate
Description: Primary SSL cert