forked from thinegan/cloudformation-project1
-
Notifications
You must be signed in to change notification settings - Fork 4
/
webapp-cdn.yaml
72 lines (63 loc) · 1.82 KB
/
webapp-cdn.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
# Note, Initiate separate CDN Deployment due to time consuming ~(30-40min to complete deploy)
#
---
AWSTemplateFormatVersion: "2010-09-09"
Description: >
CDN Deployment require Webhosting S3 bucket
####### Condition Setup #######
#Conditions:
# UseProdEnv: !Equals [ !Sub "${AWS::StackName}-PMHostedZone", "prodCDN" ]
Resources:
MyCDN:
Type: "AWS::CloudFront::Distribution"
Properties:
DistributionConfig:
Origins:
- Id: "MyOrigin"
DomainName:
Fn::ImportValue: !Sub "${AWS::StackName}-S3CloudFrontDN"
S3OriginConfig: {}
Enabled: 'true'
Aliases:
- Fn::ImportValue: !Sub "${AWS::StackName}-PMCDNDOMAIN"
DefaultCacheBehavior:
TargetOriginId: "MyOrigin"
ForwardedValues:
QueryString: 'false'
ViewerProtocolPolicy: "allow-all"
ViewerCertificate:
AcmCertificateArn:
Fn::ImportValue: !Sub "${AWS::StackName}-PMDomain1CertARN"
SslSupportMethod: "sni-only"
PriceClass: "PriceClass_All"
Route53CDN:
Type: "AWS::Route53::RecordSetGroup"
Properties:
HostedZoneName:
Fn::Join:
- ''
- - Fn::ImportValue: !Sub "${AWS::StackName}-PMHostedZone"
- "."
Comment: "CNAME CDN Record"
RecordSets:
- Name:
Fn::Join:
- ''
- - Fn::ImportValue: !Sub "${AWS::StackName}-PMCDNDOMAIN"
- "."
Type: 'CNAME'
TTL: '300'
ResourceRecords:
- !GetAtt "MyCDN.DomainName"
Outputs:
MyCDN:
Description: "CDN Reference Id"
Value: !Ref "MyCDN"
MyCDNUrl:
Description: "Static Server Site"
Value:
Fn::Join:
- ''
- - "http://"
- Fn::ImportValue: !Sub "${AWS::StackName}-PMCDNDOMAIN"
- "/"