-
Notifications
You must be signed in to change notification settings - Fork 4
/
project-resources-with-domain.yml
175 lines (171 loc) · 5.67 KB
/
project-resources-with-domain.yml
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
# TODO: this does not enable CORS support
# that should either be an option, or just done all of the time
AWSTemplateFormatVersion: '2010-09-09'
Description: portal ecs stack
Parameters:
ProjectName:
Type: String
Description: This should be lower case with words seperated by dashes. This same name
will need to be used as folder name in the cc-project-resources S3 bucket
Resources:
ReportDNS:
Type: AWS::Route53::RecordSet
Properties:
AliasTarget:
# need to get this from the cloudfront distribution
DNSName: !GetAtt CloudFrontDistribution.DomainName
# static zone id from documentation
HostedZoneId: Z2FDTNDATAQYW2
HostedZoneName: concord.org.
Name: !Sub '${ProjectName}-resources.concord.org'
Type: A
AccessGroup:
Type: AWS::IAM::Group
Properties:
GroupName: !Sub 'GroupAccess-${ProjectName}-Resources'
AccessPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: !Sub 'Access-${ProjectName}-Resources'
Groups:
- !Ref AccessGroup
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowUserToSeeBucketListInTheConsole
Action:
- s3:ListAllMyBuckets
- s3:GetBucketLocation
Effect: Allow
Resource: '*'
- Sid: AllowRootAndHomeListingOfBucket
Action:
- s3:ListBucket
Effect: Allow
Resource:
- arn:aws:s3:::cc-project-resources
Condition:
StringEquals:
s3:prefix:
- ''
s3:delimiter:
- "/"
- Sid: AllowRootListingWithoutPrefix
Action:
- s3:ListBucket
Effect: Allow
Resource:
- arn:aws:s3:::cc-project-resources
Condition:
'Null':
s3:prefix: 'true'
StringEquals:
s3:delimiter:
- "/"
- Sid: AllowListingOfProjectFolder
Action:
- s3:ListBucket
Effect: Allow
Resource:
- arn:aws:s3:::cc-project-resources
Condition:
StringLike:
s3:prefix:
- !Sub '${ProjectName}/*'
- Sid: AllowMostReadActionsOnBucket
Effect: Allow
Action:
- s3:GetAccelerateConfiguration
- s3:GetAnalyticsConfiguration
- s3:GetBucketAcl
- s3:GetBucketCORS
- s3:GetBucketLogging
- s3:GetBucketNotification
- s3:GetBucketPolicy
- s3:GetBucketRequestPayment
- s3:GetBucketTagging
- s3:GetBucketVersioning
- s3:GetBucketWebsite
- s3:GetInventoryConfiguration
- s3:GetIpConfiguration
- s3:GetLifecycleConfiguration
- s3:GetMetricsConfiguration
- s3:GetReplicationConfiguration
Resource:
- arn:aws:s3:::cc-project-resources
- Sid: AllowAllS3ActionsOnObjectsInProjectFolder
Effect: Allow
Action:
- s3:GetObject
- s3:GetObjectAcl
- s3:GetObjectTagging
- s3:GetObjectTorrent
- s3:GetObjectVersion
- s3:GetObjectVersionAcl
- s3:GetObjectVersionForReplication
- s3:GetObjectVersionTagging
- s3:GetObjectVersionTorrent
- s3:ListMultipartUploadParts
- s3:AbortMultipartUpload
- s3:DeleteObject
- s3:DeleteObjectTagging
- s3:DeleteObjectVersionTagging
- s3:PutObject
- s3:PutObjectTagging
- s3:PutObjectVersionTagging
- s3:ReplicateDelete
- s3:ReplicateObject
- s3:ReplicateTags
- s3:RestoreObject
- s3:ObjectOwnerOverrideToBucketOwner
- s3:PutObjectAcl
- s3:PutObjectVersionAcl
Resource:
- !Sub 'arn:aws:s3:::cc-project-resources/${ProjectName}'
- !Sub 'arn:aws:s3:::cc-project-resources/${ProjectName}/*'
- Sid: AllowSomeDistributionAccessToHelpCyberduck
Effect: Allow
Action:
- cloudfront:ListDistributions
- cloudfront:GetDistribution
- cloudfront:GetDistributionConfig
- cloudfront:ListInvalidations
- cloudfront:CreateInvalidation
- cloudfront:GetInvalidation
# There isn't documented support to limit these actions to a particular distribution
# I suspect with experimentation we could craft this to work that way
Resource: '*'
CloudFrontDistribution:
Type: "AWS::CloudFront::Distribution"
Properties:
DistributionConfig:
Aliases:
- !Sub '${ProjectName}-resources.concord.org'
Comment: !Sub 'Cloudfront Distribution for ${ProjectName} resources'
DefaultCacheBehavior:
AllowedMethods:
- GET
- HEAD
Compress: true
ForwardedValues:
QueryString: true
Cookies:
Forward: none
TargetOriginId: S3Origin
ViewerProtocolPolicy: redirect-to-https
Enabled: true
HttpVersion: 'http2'
Logging:
Bucket: cc-cloudfront-logs.s3.amazonaws.com
IncludeCookies: false
Prefix: !Sub '${ProjectName}-resources'
PriceClass: PriceClass_All
Origins:
- DomainName: cc-project-resources.s3.amazonaws.com
Id: S3Origin
OriginPath: !Sub '/${ProjectName}'
CustomOriginConfig:
OriginProtocolPolicy: https-only
ViewerCertificate:
AcmCertificateArn: arn:aws:acm:us-east-1:612297603577:certificate/2b62511e-ccc8-434b-ba6c-a8c33bbd509e
SslSupportMethod: sni-only