-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudfront.yaml
More file actions
164 lines (141 loc) · 4.7 KB
/
cloudfront.yaml
File metadata and controls
164 lines (141 loc) · 4.7 KB
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
Description: >
This template deploys a cloudfront distribution
Parameters:
EnvironmentName:
Description: An environment name that will be prefixed to resource names
Type: String
OriginName:
Description: S3 bucket Name for the Orgin CloudFront
Type: String
WebACLId:
Description: The WebACLId to be used in cloudfront
Type: String
CustomerUiBucket:
Description: The bucket name for customer-ui
Type: String
AgenthubBucket:
Description: The bucket name for agenthub-ui
Type: String
CustomerUiBucketARN:
Description: The arn of bucket
Type: String
AgenthubBucketARN:
Description: The arn of bucket
Type: String
Resources:
# CustomerUi
CloudFrontOriginAccessIdentityCustomer:
Type: 'AWS::CloudFront::CloudFrontOriginAccessIdentity'
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: !Ref EnvironmentName
CloudFrontDistributionCustomer:
Type: 'AWS::CloudFront::Distribution'
Properties:
DistributionConfig:
Origins:
- DomainName: !Sub 'sedera-${OriginName}-customer-ui.s3.amazonaws.com'
Id: !Ref EnvironmentName
S3OriginConfig:
OriginAccessIdentity: !Sub
- origin-access-identity/cloudfront/${ID}
- { ID: !Ref CloudFrontOriginAccessIdentityCustomer }
Enabled: 'true'
Comment: !Ref EnvironmentName
DefaultRootObject: index.html
Aliases:
- !Sub customer-ui-${EnvironmentName}.costshareaccount.com
HttpVersion: http2
DefaultCacheBehavior:
AllowedMethods:
- DELETE
- GET
- HEAD
- OPTIONS
- PATCH
- POST
- PUT
TargetOriginId: !Ref EnvironmentName
ForwardedValues:
QueryString: 'true'
Cookies:
Forward: all
ViewerProtocolPolicy: redirect-to-https
PriceClass: PriceClass_All
ViewerCertificate:
# CloudFrontDefaultCertificate: 'true'
AcmCertificateArn: arn:aws:acm:us-east-1:525128375046:certificate/55e0ddfb-2cdb-4b5e-ab80-8eabc7b34eae
MinimumProtocolVersion: TLSv1.1_2016
SslSupportMethod: sni-only
WebACLId: !Ref WebACLId
BucketPolicyCustomerUI:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref CustomerUiBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
CanonicalUser:
Fn::GetAtt: [ CloudFrontOriginAccessIdentityCustomer , S3CanonicalUserId ]
Action: "s3:GetObject"
Resource: !Sub "${CustomerUiBucketARN}/*"
# Agenthub
CloudFrontOriginAccessIdentityAgenthub:
Type: 'AWS::CloudFront::CloudFrontOriginAccessIdentity'
Properties:
CloudFrontOriginAccessIdentityConfig:
Comment: !Ref EnvironmentName
CloudFrontDistributionAgenthub:
Type: 'AWS::CloudFront::Distribution'
Properties:
DistributionConfig:
Origins:
- DomainName: !Sub 'sedera-${OriginName}-agenthub-ui.s3.amazonaws.com'
Id: !Ref EnvironmentName
S3OriginConfig:
OriginAccessIdentity: !Sub
- origin-access-identity/cloudfront/${ID}
- { ID: !Ref CloudFrontOriginAccessIdentityAgenthub }
Enabled: 'true'
Comment: !Ref EnvironmentName
DefaultRootObject: index.html
Aliases:
- !Sub agenthub-ui-${EnvironmentName}.costshareaccount.com
HttpVersion: http2
DefaultCacheBehavior:
AllowedMethods:
- DELETE
- GET
- HEAD
- OPTIONS
- PATCH
- POST
- PUT
TargetOriginId: !Ref EnvironmentName
ForwardedValues:
QueryString: 'true'
Cookies:
Forward: all
ViewerProtocolPolicy: redirect-to-https
PriceClass: PriceClass_All
ViewerCertificate:
# CloudFrontDefaultCertificate: 'true'
AcmCertificateArn: arn:aws:acm:us-east-1:525128375046:certificate/55e0ddfb-2cdb-4b5e-ab80-8eabc7b34eae
MinimumProtocolVersion: TLSv1.1_2016
SslSupportMethod: sni-only
WebACLId: !Ref WebACLId
BucketPolicyAgenthubUI:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref AgenthubBucket
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
CanonicalUser:
Fn::GetAtt: [ CloudFrontOriginAccessIdentityAgenthub , S3CanonicalUserId ]
Action: "s3:GetObject"
Resource: !Sub "${AgenthubBucketARN}/*"