-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudformation_v1.yaml
100 lines (89 loc) · 2.85 KB
/
cloudformation_v1.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
AWSTemplateFormatVersion: 2010-09-09
Description: |
Cloudformation Template for Enes carousel static website deploy on s3 through cloudfront and route 53
Parameters:
DomainName:
Description: DNS Name of existing Amazon Route 53 hosted zone (exp. enseturan.com)
Type: AWS::Route53::HostedZone::Id
EnesDomainName:
Description: Full domain name for the App (exp. ahmed.enesturan.com)
Type: String
AllowedPattern: (?!-)[a-zA-Z0-9-.]{1,63}(?<!-)
Resources:
EnesBucket:
Type: "AWS::S3::Bucket"
Properties:
AccessControl: PublicRead
BucketName: !Ref EnesDomainName
WebsiteConfiguration:
IndexDocument: index.html
EnesBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref EnesBucket
PolicyDocument:
Statement:
- Sid: PublicReadGetObject
Effect: Allow
Principal: "*"
Action: s3:GetObject
Resource: !Join ["", ["arn:aws:s3:::", !Ref "EnesBucket", /*]]
EnesCertificate:
Type: "AWS::CertificateManager::Certificate"
Properties:
CertificateTransparencyLoggingPreference: ENABLED
DomainName: !Ref EnesDomainName
DomainValidationOptions:
- DomainName: !Ref EnesDomainName
HostedZoneId: !Ref DomainName
ValidationMethod: DNS
EnesCloudfront:
Type: "AWS::CloudFront::Distribution"
Properties:
DistributionConfig:
Aliases:
- !Ref EnesDomainName
Comment: Cloudfront Distribution pointing to Enes S3 bucket
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
Compress: true
ForwardedValues:
QueryString: true
Cookies:
Forward: none
TargetOriginId: EnesOrigin
ViewerProtocolPolicy: allow-all
DefaultRootObject: index.html
Enabled: true
HttpVersion: "http2"
Origins:
- DomainName: !Select [2, !Split ["/", !GetAtt EnesBucket.WebsiteURL]]
Id: EnesOrigin
CustomOriginConfig:
OriginProtocolPolicy: http-only
PriceClass: PriceClass_All
ViewerCertificate:
AcmCertificateArn: !Ref EnesCertificate
SslSupportMethod: sni-only
EnesDNSName:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneId: !Ref DomainName
RecordSets:
- Name: !Ref EnesDomainName
Type: A
AliasTarget:
HostedZoneId: Z2FDTNDATAQYW2
DNSName: !GetAtt EnesCloudfront.DomainName
Outputs:
BucketName:
Description: S3 Bucket URL for Enes Website
Value: !GetAtt EnesBucket.WebsiteURL
CloudfrontEndpoint:
Description: Endpoint for Enes Cloudfront
Value: !GetAtt EnesCloudfront.DomainName
FullDomainName:
Description: Full Domain Name of my Application
Value: !Ref EnesDomainName