-
Notifications
You must be signed in to change notification settings - Fork 10
/
docs-preview.yaml
63 lines (58 loc) · 1.74 KB
/
docs-preview.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
AWSTemplateFormatVersion: 2010-09-09
Description : "Hosting docs previews"
Parameters:
BucketNameParameter:
Type: String
Default: nhsx-covid-chest-imaging-database-preview
Description: The base name of the storage bucket
Resources:
# Main bucket
DocsPreviewStorageBucket:
Type: AWS::S3::Bucket
DeletionPolicy: Retain
UpdateReplacePolicy: Retain
Properties:
AccessControl: PublicRead
BucketName: !Ref "BucketNameParameter"
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
LifecycleConfiguration:
Rules:
- Id: "BucketRecycling"
AbortIncompleteMultipartUpload:
DaysAfterInitiation: 7
ExpirationInDays: 7
Status: Enabled
PublicReadBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref DocsPreviewStorageBucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "s3:GetObject"
Resource:
!Join ["", [!GetAtt [DocsPreviewStorageBucket, Arn], "/*"]]
Principal: "*"
# IAM
UploadToDocsPreviewPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
ManagedPolicyName: !Join ["", ["upload-to-", !Ref "BucketNameParameter"]]
Description: Allow uploading to the the preview bucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action:
- "s3:PutObject"
Resource:
!Join ["", [!GetAtt [DocsPreviewStorageBucket, Arn], "/*"]]
DocsPreviewUploaderGroup:
Type: AWS::IAM::Group
Properties:
ManagedPolicyArns:
- !Ref UploadToDocsPreviewPolicy