-
Notifications
You must be signed in to change notification settings - Fork 1
/
enable_control_tower.yml
386 lines (367 loc) · 12.5 KB
/
enable_control_tower.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
---
AWSTemplateFormatVersion: "2010-09-09"
Description: Cloud Foundations on AWS Control Tower deployment
Metadata:
"AWS::CloudFormation::Interface":
ParameterGroups:
- Label:
default: "AWS Organization"
Parameters:
- pCreateNewAwsOrg
- pSecurityOuName
- pSandboxOuName
- Label:
default: "Security Account"
Parameters:
- pDeployNewSecurityAccount
- pImportedSecurityAccountId
- pSecurityAccountAlias
- pSecurityAccountEmailAddress
- Label:
default: "Log Archive Account"
Parameters:
- pDeployNewLogArchiveAccount
- pImportedLogArchiveAccountId
- pLogArchiveAccountAlias
- pLogArchiveAccountEmailAddress
- Label:
default: "Control Tower"
Parameters:
- pVersion
- pGovernedRegions
- pLoggingBucketRetentionPeriod
- pAccessLoggingBucketRetentionPeriod
ParameterLabels:
pCreateNewAwsOrg:
default: "Create new AWS Organization"
pSecurityOuName:
default: "Security OU Name"
pSandboxOuName:
default: "Additional Control Tower OU"
pImportedSecurityAccountId:
default: "Import Security Account ID"
pSecurityAccountAlias:
default: "Security account alias"
pSecurityAccountEmailAddress:
default: "Security account email address"
pImportedLogArchiveAccountId:
default: "Import Log Archive account ID"
pLogArchiveAccountAlias:
default: "Log Archive account alias"
pLogArchiveAccountEmailAddress:
default: "Log Archive account email address"
pVersion:
default: "Landing Zone version"
pGovernedRegions:
default: "Governed Regions"
pLoggingBucketRetentionPeriod:
default: "Logging Bucket Retention Period"
pAccessLoggingBucketRetentionPeriod:
default: "Access Logging Bucket Retention Period"
pDeployNewSecurityAccount:
default: "Deploy new Security account"
pDeployNewLogArchiveAccount:
default: "Deploy new Log Archive account"
Parameters:
pCreateNewAwsOrg:
Type: String
Description: Specify whether to create the AWS Organization or if one already exists. Select no if you already have an AWS Organization.
Default: "Yes"
AllowedValues:
- "Yes"
- "No"
pDeployNewLogArchiveAccount:
Type: String
Description: Deploy a NEW Log Archive account or select No and enter an existing AWS account ID to use a pre-existing account
Default: "Yes"
AllowedValues:
- "Yes"
- "No"
pLogArchiveAccountAlias:
Type: String
Description: The AWS account alias for the Log Archive account. If importing a pre-existing Log Archive account, leave blank.
Default: "Log Archive"
pLogArchiveAccountEmailAddress:
Type: String
Description: The Log Archive email address for any newly created Log Archive account. Leave this blank if importing a pre-existing Log Archive account.
pImportedLogArchiveAccountId:
Type: String
Description: If you selected No for creating a new Log Archive account, enter the existing account ID that will serve as your Log Archive account ID.
pDeployNewSecurityAccount:
Type: String
Description: Deploy a NEW Security account or select No and enter an existing AWS account ID to use a pre-existing account
Default: "Yes"
AllowedValues:
- "Yes"
- "No"
pSecurityAccountAlias:
Type: String
Description: The AWS account alias for the Security account. If importing a pre-existing Security account, leave blank.
Default: "Audit"
pSecurityAccountEmailAddress:
Type: String
Description: The Security email address for any newly created Security account. Leave this blank if importing a pre-existing Security account.
pImportedSecurityAccountId:
Type: String
Description: If you selected No for creating a new Security account, enter the existing account ID that will serve as your Security account ID.
pVersion:
Type: String
Description: The version number of Landing Zone
Default: "3.3"
pGovernedRegions:
Type: CommaDelimitedList
Description: List of governed regions
Default: "us-east-1, us-west-2"
pSecurityOuName:
Type: String
Description: The security Organizational Unit name
Default: "Security"
pSandboxOuName:
Type: String
Description: Name of additional OU to be created and registered in Control Tower
Default: "Sandbox"
pLoggingBucketRetentionPeriod:
Type: Number
Description: Retention period for centralized logging bucket
Default: 365
pAccessLoggingBucketRetentionPeriod:
Type: Number
Description: Retention period for access logging bucket
Default: 90
Conditions:
pCreateNewAwsOrg: !Equals ["Yes", !Ref pCreateNewAwsOrg]
cDeployNewLogArchiveAccount: !Equals ["Yes", !Ref pDeployNewLogArchiveAccount]
cDeployNewSecurityAccount: !Equals ["Yes", !Ref pDeployNewSecurityAccount]
Resources:
rOrganization:
Type: "AWS::Organizations::Organization"
Condition: pCreateNewAwsOrg
Properties:
FeatureSet: ALL
rOrgWaiter:
Type: "AWS::CloudFormation::WaitConditionHandle"
Metadata:
WaitOn: !If [pCreateNewAwsOrg, !Ref rOrganization, !Ref AWS::NoValue ]
rLoggingAccount:
Type: "AWS::Organizations::Account"
DependsOn:
- rOrgWaiter
Condition: cDeployNewLogArchiveAccount
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Properties:
AccountName: !Ref pLogArchiveAccountAlias
Email: !Ref pLogArchiveAccountEmailAddress
rSecurityAccount:
Type: "AWS::Organizations::Account"
DependsOn:
- rOrgWaiter
Condition: cDeployNewSecurityAccount
UpdateReplacePolicy: Retain
DeletionPolicy: Retain
Properties:
AccountName: !Ref pSecurityAccountAlias
Email: !Ref pSecurityAccountEmailAddress
rAWSControlTowerAdmin:
Type: "AWS::IAM::Role"
Metadata:
cfn_nag:
rules_to_suppress:
- id: W28
reason: "Ignoring explicit role name"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: "controltower.amazonaws.com"
Action: "sts:AssumeRole"
Path: "/service-role/"
ManagedPolicyArns:
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSControlTowerServiceRolePolicy"
RoleName: AWSControlTowerAdmin
Tags:
- Key: "aws-cloudformation:stack-name"
Value: !Ref "AWS::StackName"
- Key: "aws-cloudformation:stack-id"
Value: !Ref "AWS::StackId"
- Key: "aws-cloudformation:logical-id"
Value: rAWSControlTowerAdmin
rAWSControlTowerAdminPolicy:
Type: "AWS::IAM::Policy"
Metadata:
cfn_nag:
rules_to_suppress:
- id: W12
reason: "Ignoring star in policy"
Properties:
PolicyName: AWSControlTowerAdminPolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "ec2:DescribeAvailabilityZones"
Resource: "*"
Roles:
- !Ref rAWSControlTowerAdmin
rAWSControlTowerCloudTrailRole:
Type: "AWS::IAM::Role"
Metadata:
cfn_nag:
rules_to_suppress:
- id: W28
reason: "Ignoring explicit role name"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: "cloudtrail.amazonaws.com"
Action: "sts:AssumeRole"
Path: "/service-role/"
RoleName: AWSControlTowerCloudTrailRole
Tags:
- Key: "aws-cloudformation:stack-name"
Value: !Ref "AWS::StackName"
- Key: "aws-cloudformation:stack-id"
Value: !Ref "AWS::StackId"
- Key: "aws-cloudformation:logical-id"
Value: rAWSControlTowerCloudTrailRole
rAWSControlTowerCloudTrailRolePolicy:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: AWSControlTowerCloudTrailRolePolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action:
- "logs:CreateLogStream"
- "logs:PutLogEvents"
Resource: !Sub "arn:${AWS::Partition}:logs:*:*:log-group:aws-controltower/CloudTrailLogs:*"
Roles:
- !Ref rAWSControlTowerCloudTrailRole
rAWSControlTowerConfigAggregatorRoleForOrganizations:
Type: "AWS::IAM::Role"
Metadata:
cfn_nag:
rules_to_suppress:
- id: W28
reason: "Ignoring explicit role name"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: "config.amazonaws.com"
Action: "sts:AssumeRole"
ManagedPolicyArns:
- !Sub "arn:${AWS::Partition}:iam::aws:policy/service-role/AWSConfigRoleForOrganizations"
Path: "/service-role/"
RoleName: AWSControlTowerConfigAggregatorRoleForOrganizations
Tags:
- Key: "aws-cloudformation:stack-name"
Value: !Ref "AWS::StackName"
- Key: "aws-cloudformation:stack-id"
Value: !Ref "AWS::StackId"
- Key: "aws-cloudformation:logical-id"
Value: rAWSControlTowerConfigAggregatorRoleForOrganizations
rAWSControlTowerStackSetRole:
Type: "AWS::IAM::Role"
Metadata:
cfn_nag:
rules_to_suppress:
- id: W28
reason: "Ignoring explicit role name"
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: "cloudformation.amazonaws.com"
Action: "sts:AssumeRole"
Path: "/service-role/"
RoleName: AWSControlTowerStackSetRole
Tags:
- Key: "aws-cloudformation:stack-name"
Value: !Ref "AWS::StackName"
- Key: "aws-cloudformation:stack-id"
Value: !Ref "AWS::StackId"
- Key: "aws-cloudformation:logical-id"
Value: rAWSControlTowerStackSetRole
rAWSControlTowerStackSetRolePolicy:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: AWSControlTowerStackSetRolePolicy
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: "sts:AssumeRole"
Resource: !Sub "arn:${AWS::Partition}:iam::*:role/AWSControlTowerExecution"
Roles:
- !Ref rAWSControlTowerStackSetRole
rSecurityAccountWaiter:
Type: "AWS::CloudFormation::WaitConditionHandle"
Metadata:
WaitOn: !If
- cDeployNewSecurityAccount
- !Ref rSecurityAccount
- !Ref "AWS::NoValue"
rLogArchiveAccountWaiter:
Type: "AWS::CloudFormation::WaitConditionHandle"
Metadata:
WaitOn: !If
- cDeployNewLogArchiveAccount
- !Ref rLoggingAccount
- !Ref "AWS::NoValue"
rControlTowerLandingZone:
Type: "AWS::ControlTower::LandingZone"
DependsOn:
- rSecurityAccountWaiter
- rLogArchiveAccountWaiter
Properties:
Version: !Ref pVersion
Manifest:
governedRegions: !Ref pGovernedRegions
organizationStructure:
security:
name: !Ref pSecurityOuName
sandbox:
name: !Ref pSandboxOuName
centralizedLogging:
accountId: !If
- cDeployNewLogArchiveAccount
- !Ref rLoggingAccount
- !Ref pImportedLogArchiveAccountId
configurations:
loggingBucket:
retentionDays: !Ref pLoggingBucketRetentionPeriod
accessLoggingBucket:
retentionDays: !Ref pAccessLoggingBucketRetentionPeriod
enabled: true
securityRoles: # specify your Audit/Security Tooling account
accountId: !If
- cDeployNewSecurityAccount
- !Ref rSecurityAccount
- !Ref pImportedSecurityAccountId
accessManagement: # enable identity center or not
enabled: true
Outputs:
LoggingAccountId:
Description: Logging Account ID
Condition: cDeployNewLogArchiveAccount
Value: !Ref rLoggingAccount
SecurityAccountId:
Description: Security Account ID
Condition: cDeployNewSecurityAccount
Value: !Ref rSecurityAccount
LandingZoneId:
Description: Control Tower Landing Zone ID
Value: !GetAtt rControlTowerLandingZone.LandingZoneIdentifier