-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbucket.json
More file actions
137 lines (137 loc) · 3.74 KB
/
bucket.json
File metadata and controls
137 lines (137 loc) · 3.74 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
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "S3 Bucket and User account and credentials for file storage",
"Outputs": {
"BucketName": {
"Description": "Name of the bucket",
"Value": {
"Ref": "Bucket"
},
"Export" : {
"Name" : {"Fn::Sub": "${ApplicationName}-bucket" }
}
},
"BucketUserAccessKeyId": {
"Description": "Access Key ID for the user",
"Value": {
"Ref": "BucketUserAccessKey"
},
"Export" : {
"Name" : {"Fn::Sub": "${ApplicationName}-bucket-user-access-key-id" }
}
},
"BucketUserSecretAccessKeyARN": {
"Description": "ARN for the Secrets Manager secret containing the Secret Access Key for the user",
"Value": {
"Ref": "BucketUserSecretAccessKey"
},
"Export" : {
"Name" : {"Fn::Sub": "${ApplicationName}-bucket-user-secret-access-key-arn" }
}
}
},
"Parameters": {
"ApplicationName": {
"Description": "Name of the application (snake-case, will be prepended to make internal reference names)",
"Type": "String",
"Default": "app"
},
"DomainName": {
"Description": "Host domain name that should have access to the bucket through CORS",
"Type": "String"
}
},
"Resources": {
"Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"CorsConfiguration": {
"CorsRules": [
{
"AllowedHeaders": ["*"],
"AllowedMethods": ["GET", "PUT"],
"AllowedOrigins": [
{
"Fn::Sub": "https://${DomainName}"
}
]
}
]
},
"LifecycleConfiguration": {
"Rules": [
{
"Id": "DeleteOrphanUploadsRule",
"Prefix": "uploads/",
"Status": "Enabled",
"ExpirationInDays": 1
}
]
},
"OwnershipControls": {
"Rules": [
{
"ObjectOwnership": "BucketOwnerEnforced"
}
]
},
"PublicAccessBlockConfiguration": {
"BlockPublicAcls": "TRUE",
"BlockPublicPolicy": "TRUE",
"IgnorePublicAcls": "TRUE",
"RestrictPublicBuckets": "TRUE"
}
},
"DeletionPolicy": "Delete"
},
"BucketUser": {
"Type": "AWS::IAM::User",
"Properties": {
"Policies": [
{
"PolicyName": {
"Fn::Sub": "${ApplicationName}-bucket-policy"
},
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:GetObject", "s3:ListBucket", "s3:DeleteObject"],
"Resource": [
{ "Fn::Join": ["", ["arn:aws:s3:::", { "Ref": "Bucket" }, "/*"]] },
{ "Fn::Join": ["", ["arn:aws:s3:::", { "Ref": "Bucket" }]] }
]
}
]
}
}
],
"UserName": {
"Fn::Sub": "${ApplicationName}-bucket-user"
}
}
},
"BucketUserAccessKey": {
"Type": "AWS::IAM::AccessKey",
"Properties": {
"Status": "Active",
"UserName": {
"Ref": "BucketUser"
}
}
},
"BucketUserSecretAccessKey": {
"Type" : "AWS::SecretsManager::Secret",
"Properties" : {
"Name" : {
"Fn::Sub": "/iam/user/${ApplicationName}-bucket-user/secret-access-key"
},
"SecretString" : {
"Fn::GetAtt": ["BucketUserAccessKey", "SecretAccessKey"]
}
}
}
}
}