forked from aws-samples/amazon-cloudfront-secure-static-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.yaml
116 lines (108 loc) · 3.5 KB
/
main.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
AWSTemplateFormatVersion: 2010-09-09
Description: |
ACFS3 - S3 Static site with CF and ACM
https://github.com/aws-samples/amazon-cloudfront-secure-static-site
(uksb-1qnk6ni7b) (version:v0.12)
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Domain
Parameters:
- SubDomain
- DomainName
Mappings:
Solution:
Constants:
Version: 'v0.12'
Rules:
OnlyUsEast1:
Assertions:
- Assert:
Fn::Equals:
- !Ref AWS::Region
- us-east-1
AssertDescription: |
This template can only be deployed in the us-east-1 region.
This is because the ACM Certificate must be created in us-east-1
Parameters:
SubDomain:
Description: The part of a website address before your DomainName - e.g. www or img
Type: String
Default: www
AllowedPattern: ^[^.]*$
DomainName:
Description: The part of a website address after your SubDomain - e.g. example.com
Type: String
HostedZoneId:
Description: HostedZoneId for the domain e.g. Z23ABC4XYZL05B
Type: String
CreateApex:
Description: Create an Apex Alias in CloudFront distribution - yes/no
Type: String
Default: 'no'
AllowedValues: ['yes', 'no']
Resources:
CustomResourceStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: ./custom-resource.yaml
Tags:
- Key: Solution
Value: ACFS3
AcmCertificateStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: ./acm-certificate.yaml
Parameters:
SubDomain: !Ref SubDomain
DomainName: !Ref DomainName
CreateApex: !Ref CreateApex
HostedZoneId: !Ref HostedZoneId
Tags:
- Key: Solution
Value: ACFS3
CloudFrontStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: ./cloudfront-site.yaml
Parameters:
CertificateArn: !GetAtt AcmCertificateStack.Outputs.CertificateArn
DomainName: !Ref DomainName
SubDomain: !Ref SubDomain
CreateApex: !Ref CreateApex
S3BucketRoot: !GetAtt CustomResourceStack.Outputs.S3BucketRoot
S3BucketRootName: !GetAtt CustomResourceStack.Outputs.S3BucketRootName
S3BucketRootArn: !GetAtt CustomResourceStack.Outputs.S3BucketRootArn
S3BucketLogs: !GetAtt CustomResourceStack.Outputs.S3BucketLogs
S3BucketLogsName: !GetAtt CustomResourceStack.Outputs.S3BucketLogsName
Tags:
- Key: Solution
Value: ACFS3
Outputs:
SolutionVersion:
Value: !FindInMap [Solution, Constants, Version]
CopyFunction:
Description: S3 helper function
Value: !GetAtt CustomResourceStack.Outputs.CopyFunction
S3BucketLogs:
Description: Logging bucket
Value: !GetAtt CustomResourceStack.Outputs.S3BucketLogs
S3BucketRoot:
Description: Website bucket
Value: !GetAtt CustomResourceStack.Outputs.S3BucketRoot
S3BucketLogsName:
Description: Logging bucket name
Value: !GetAtt CustomResourceStack.Outputs.S3BucketLogsName
S3BucketRootName:
Description: Website bucket name
Value: !GetAtt CustomResourceStack.Outputs.S3BucketRootName
CertificateArn:
Description: Issued certificate
Value: !GetAtt AcmCertificateStack.Outputs.CertificateArn
CFDistributionName:
Description: CloudFront distribution
Value: !GetAtt CloudFrontStack.Outputs.CloudFrontDistribution
CloudFrontDomainName:
Description: Website address
Value: !GetAtt CloudFrontStack.Outputs.CloudFrontDomainName