-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCommon-Buckets.yaml
268 lines (268 loc) · 8.71 KB
/
Common-Buckets.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
AWSTemplateFormatVersion: 2010-09-09
Description: Common-Buckets Template.
This creates S3 Buckets which should exist in every Region. These buckets hold artifacts needed to build Stacks, which are not created as part of a Build Process.
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Environment Configuration
Parameters:
- AccountAlias
- EnvironmentName
- Label:
default: Bucket Configuration
Parameters:
- UseGlacier
ParameterLabels:
AccountAlias:
default: Account Alias
EnvironmentName:
default: Environment Name
UseGlacier:
default: Use Glacier
Parameters:
AccountAlias:
Description: Unique Alias of the Account (if defined). If specified, the Alias instead of the AccountID is appended to bucket names to insure uniqueness.
Type: String
MaxLength: 32
Default: ''
AllowedPattern: (^$|^[a-z][-a-z0-9]*$)
ConstraintDescription: must begin with a lower case letter and contain lower case letters, numbers and dashes.
EnvironmentName:
Description: Name of the Environment associated with the Stack
Type: String
Default: Production
AllowedValues:
- Production
- Staging
- UAT
- QA
- Testing
- Development
- Build
- Core
- Recovery
- Log
- Identity
- Management
- Organization
ConstraintDescription: must be Production, Staging, UAT, QA, Testing, Development, Build, Core, Recovery, Log, Identity, Management or Organization.
UseGlacier:
Description: Use Glacier for Archived Logs
Type: String
Default: true
AllowedValues:
- true
- false
ConstraintDescription: must be either true or false.
Conditions:
AppendAccountId: !Equals [ !Ref AccountAlias, '' ]
ConfigureGlacier: !Equals [ !Ref UseGlacier, true ]
Resources:
TemplatesBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub
- templates-${Account}-${AWS::Region}
- Account: !If [ AppendAccountId, !Ref 'AWS::AccountId', !Ref AccountAlias ]
AccessControl: Private
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: ReduceStorageCostsThenDeletePriorVersions
Status: Enabled
Prefix: ''
Transitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
ExpirationInDays: 425
NoncurrentVersionTransitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
NoncurrentVersionExpirationInDays: 395
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-TemplatesBucket
DeletionPolicy: Retain
TemplatesBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref TemplatesBucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AllowCloudFormationACLCheck
Effect: Allow
Principal:
Service: cloudformation.amazonaws.com
Action: s3:GetBucketAcl
Resource: !Sub arn:aws:s3:::${TemplatesBucket}
- Sid: AllowCloudFormationRead
Effect: Allow
Principal:
Service: cloudformation.amazonaws.com
Action: s3:GetObject
Resource: !Sub arn:aws:s3:::${TemplatesBucket}/*
DependsOn: TemplatesBucket
FunctionsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub
- functions-${Account}-${AWS::Region}
- Account: !If [ AppendAccountId, !Ref 'AWS::AccountId', !Ref AccountAlias ]
AccessControl: Private
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: ReduceStorageCostsThenDeletePriorVersions
Status: Enabled
Prefix: ''
Transitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
ExpirationInDays: 425
NoncurrentVersionTransitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
NoncurrentVersionExpirationInDays: 395
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-FunctionsBucket
DeletionPolicy: Retain
ScriptsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub
- scripts-${Account}-${AWS::Region}
- Account: !If [ AppendAccountId, !Ref 'AWS::AccountId', !Ref AccountAlias ]
AccessControl: Private
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: ReduceStorageCostsThenDeletePriorVersions
Status: Enabled
Prefix: ''
Transitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
ExpirationInDays: 425
NoncurrentVersionTransitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
NoncurrentVersionExpirationInDays: 395
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-ScriptsBucket
DeletionPolicy: Retain
ConfigurationsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub
- configurations-${Account}-${AWS::Region}
- Account: !If [ AppendAccountId, !Ref 'AWS::AccountId', !Ref AccountAlias ]
AccessControl: Private
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: ReduceStorageCostsThenDeletePriorVersions
Status: Enabled
Prefix: ''
Transitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
ExpirationInDays: 425
NoncurrentVersionTransitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
NoncurrentVersionExpirationInDays: 395
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-ConfigurationsBucket
DeletionPolicy: Retain
ProductsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub
- products-${Account}-${AWS::Region}
- Account: !If [ AppendAccountId, !Ref 'AWS::AccountId', !Ref AccountAlias ]
AccessControl: Private
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: ReduceStorageCostsThenDeletePriorVersions
Status: Enabled
Prefix: ''
Transitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
ExpirationInDays: 425
NoncurrentVersionTransitions:
- StorageClass: STANDARD_IA
TransitionInDays: 30
NoncurrentVersionExpirationInDays: 395
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-ProductsBucket
DeletionPolicy: Retain
BackupsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub
- backups-${Account}-${AWS::Region}
- Account: !If [ AppendAccountId, !Ref 'AWS::AccountId', !Ref AccountAlias ]
AccessControl: Private
VersioningConfiguration:
Status: Enabled
LifecycleConfiguration:
Rules:
- Id: ReduceStorageCostsThenDeletePriorVersions
Status: Enabled
Prefix: ''
Transitions:
- StorageClass: !If [ ConfigureGlacier, GLACIER, STANDARD_IA ]
TransitionInDays: 90
ExpirationInDays: 365
NoncurrentVersionTransitions:
- StorageClass: !If [ ConfigureGlacier, GLACIER, STANDARD_IA ]
TransitionInDays: 30
NoncurrentVersionExpirationInDays: 180
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-BackupsBucket
DeletionPolicy: Retain
Outputs:
TemplatesBucket:
Description: The Templates Bucket Name
Value: !Ref TemplatesBucket
Export:
Name: !Sub ${AWS::StackName}-TemplatesBucket
FunctionsBucket:
Description: The Functions Bucket Name
Value: !Ref FunctionsBucket
Export:
Name: !Sub ${AWS::StackName}-FunctionsBucket
ScriptsBucket:
Description: The Scripts Bucket Name
Value: !Ref ScriptsBucket
Export:
Name: !Sub ${AWS::StackName}-ScriptsBucket
ConfigurationsBucket:
Description: The Configurations Bucket Name
Value: !Ref ConfigurationsBucket
Export:
Name: !Sub ${AWS::StackName}-ConfigurationsBucket
ProductsBucket:
Description: The Products Bucket Name
Value: !Ref ProductsBucket
Export:
Name: !Sub ${AWS::StackName}-ProductsBucket
BackupsBucket:
Description: The Backups Bucket Name
Value: !Ref BackupsBucket
Export:
Name: !Sub ${AWS::StackName}-BackupsBucket