-
Notifications
You must be signed in to change notification settings - Fork 0
/
sra-guardduty-org-main-ssm.yaml
476 lines (462 loc) · 19.9 KB
/
sra-guardduty-org-main-ssm.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
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
########################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
########################################################################
AWSTemplateFormatVersion: 2010-09-09
Description:
This template enables an AWS Organizations GuardDuty in the Control Tower Audit or another delegated admin account with a customer managed KMS key
created in the Audit account sending the encrypted findings to an S3 bucket created within the Log Archive account. - 'guardduty_org' solution in
the repo, https://github.com/aws-samples/aws-security-reference-architecture-examples (sra-1ssgnse4k)
Metadata:
SRA:
Version: 1.2
Entry: Parameters for deploying solution resolving SSM parameters
Order: 1
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: General Properties
Parameters:
- pSRASolutionName
- pSRASolutionVersion
- pSRAStagingS3BucketName
- pSRAAlarmEmail
- pAuditAccountId
- pLogArchiveAccountId
- pRootOrganizationalUnitId
- Label:
default: IAM Properties
Parameters:
- pStackSetAdminRole
- pStackExecutionRole
- Label:
default: GuardDuty Delivery Properties
Parameters:
- pGuardDutyOrgDeliveryBucketPrefix
- pGuardDutyOrgDeliveryKeyAlias
- Label:
default: GuardDuty Configuration Properties
Parameters:
- pDisableGuardDuty
- pAutoEnableS3Logs
- pAutoEnableKubernetesAuditLogs
- pAutoEnableMalwareProtection
- pEnableRdsLoginEvents
- pEnableEksRuntimeMonitoring
- pEnableEksAddonManagement
- pEnableLambdaNetworkLogs
- pControlTowerRegionsOnly
- pEnabledRegions
- pFindingPublishingFrequency
- pOrganizationId
- Label:
default: General Lambda Function Properties
Parameters:
- pCreateLambdaLogGroup
- pLambdaLogGroupRetention
- pLambdaLogGroupKmsKey
- pLambdaLogLevel
ParameterLabels:
pStackSetAdminRole:
default: Stack Set Role
pStackExecutionRole:
default: Stack execution role
pAuditAccountId:
default: Audit Account ID
pAutoEnableS3Logs:
default: Auto Enable S3 Logs
pAutoEnableKubernetesAuditLogs:
default: Auto Enable Kubernetes Audit Logs
pAutoEnableMalwareProtection:
default: Auto Enable Malware Protection
pEnableRdsLoginEvents:
default: Auto enable RDS Login Events
pEnableEksRuntimeMonitoring:
default: Auto enable EKS Runtime Monitoring
pEnableEksAddonManagement:
default: Auto enable EKS Add-on Management
pEnableLambdaNetworkLogs:
default: Auto enable Lambda Network Logs
pControlTowerRegionsOnly:
default: Control Tower Regions Only
pCreateLambdaLogGroup:
default: Create Lambda Log Group
pDisableGuardDuty:
default: Disable GuardDuty in All Accounts
pEnabledRegions:
default: (Optional) Enabled Regions
pFindingPublishingFrequency:
default: Finding Publishing Frequency
pGuardDutyOrgDeliveryBucketPrefix:
default: GuardDuty Delivery Bucket Prefix
pGuardDutyOrgDeliveryKeyAlias:
default: GuardDuty Delivery KMS Key Alias
pLambdaLogGroupKmsKey:
default: (Optional) Lambda Logs KMS Key
pLambdaLogGroupRetention:
default: Lambda Log Group Retention
pLambdaLogLevel:
default: Lambda Log Level
pLogArchiveAccountId:
default: Log Archive Account ID
pOrganizationId:
default: Organization ID
pRootOrganizationalUnitId:
default: Root Organizational Unit ID
pSRAAlarmEmail:
default: (Optional) SRA Alarm Email
pSRASolutionName:
default: SRA Solution Name
pSRASolutionVersion:
default: SRA Solution Version
pSRAStagingS3BucketName:
default: SRA Staging S3 Bucket Name
Parameters:
pStackSetAdminRole:
AllowedValues: [sra-stackset]
Default: sra-stackset
Description: The administration role name that is used in the stackset.
Type: String
pStackExecutionRole:
AllowedValues: [sra-execution]
Default: sra-execution
Description: The execution role name that is used in the stack.
Type: String
pAuditAccountId:
AllowedPattern: '^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$'
ConstraintDescription:
Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
Default: /sra/control-tower/audit-account-id
Description: SSM Parameter for AWS Account ID of the Control Tower account to delegate administration.
Type: AWS::SSM::Parameter::Value<String>
pAutoEnableS3Logs:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable S3 logs
Type: String
pAutoEnableKubernetesAuditLogs:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable Kubernetes Audit Logs
Type: String
pAutoEnableMalwareProtection:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable Malware Protection
Type: String
pEnableRdsLoginEvents:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable RDS Login Events
Type: String
pEnableEksRuntimeMonitoring:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable EKS Runtime Monitoring
Type: String
pEnableEksAddonManagement:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable EKS Add-on Management
Type: String
pEnableLambdaNetworkLogs:
AllowedValues: ['true', 'false']
Default: 'true'
Description: Auto enable Lambda Network Logs
Type: String
pControlTowerRegionsOnly:
Type: String
Description: Only enable in the Control Tower governed regions (set to true for environments without AWS Control Tower)
Default: 'true'
AllowedValues: ['true', 'false']
pCreateLambdaLogGroup:
AllowedValues: ['true', 'false']
Default: 'false'
Description:
Indicates whether a CloudWatch Log Group should be explicitly created for the Lambda function, to allow for setting a Log Retention and/or KMS
Key for encryption.
Type: String
pDisableGuardDuty:
AllowedValues: ['true', 'false']
Default: 'false'
Description: Update to 'true' to disable GuardDuty in all accounts and regions before deleting the stack.
Type: String
pEnabledRegions:
AllowedPattern: '^$|^([a-z0-9-]{1,64})$|^(([a-z0-9-]{1,64},)*[a-z0-9-]{1,64})$'
ConstraintDescription:
Only lowercase letters, numbers, and hyphens ('-') allowed. (e.g. us-east-1) Additional AWS regions can be provided, separated by commas. (e.g.
us-east-1,ap-southeast-2)
Default: ''
Description: (Optional) Enabled regions (AWS regions, separated by commas). Leave blank to enable all regions.
Type: String
pFindingPublishingFrequency:
AllowedValues: [FIFTEEN_MINUTES, ONE_HOUR, SIX_HOURS]
Default: FIFTEEN_MINUTES
Description: Finding publishing frequency
Type: String
pGuardDutyOrgDeliveryBucketPrefix:
AllowedPattern: '^$|^[0-9a-zA-Z]+([0-9a-zA-Z-]*[0-9a-zA-Z])*$'
ConstraintDescription:
S3 bucket name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).
Default: sra-guardduty-org-delivery
Description:
GuardDuty Delivery S3 bucket prefix. The account and region will get added to the end. e.g. sra-guardduty-delivery-123456789012-us-east-1
Type: String
pGuardDutyOrgDeliveryKeyAlias:
Default: sra-guardduty-org-delivery-key
Description: GuardDuty Delivery KMS Key Alias
Type: String
pLambdaLogGroupKmsKey:
AllowedPattern: '^$|^arn:(aws[a-zA-Z-]*){1}:kms:[a-z0-9-]+:\d{12}:key\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$'
ConstraintDescription: 'Key ARN example: arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab'
Default: ''
Description:
(Optional) KMS Key ARN to use for encrypting the Lambda logs data. If empty, encryption is enabled with CloudWatch Logs managing the server-side
encryption keys.
Type: String
pLambdaLogGroupRetention:
AllowedValues: [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
Default: 14
Description: Specifies the number of days you want to retain log events
Type: String
pLambdaLogLevel:
AllowedValues: [INFO, ERROR, DEBUG]
Default: INFO
Description: Lambda Function Logging Level
Type: String
pLogArchiveAccountId:
AllowedPattern: ^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$
ConstraintDescription:
Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
Default: /sra/control-tower/log-archive-account-id
Description: SSM Parameter for AWS Account ID of the Control Tower Log Archive account.
Type: AWS::SSM::Parameter::Value<String>
pOrganizationId:
AllowedPattern: '^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$'
ConstraintDescription:
Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
Default: /sra/control-tower/organization-id
Description: SSM Parameter for AWS Organizations ID
Type: AWS::SSM::Parameter::Value<String>
pRootOrganizationalUnitId:
AllowedPattern: '^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$'
ConstraintDescription:
Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
Default: /sra/control-tower/root-organizational-unit-id
Description: SSM Parameter for Root Organizational Unit ID
Type: AWS::SSM::Parameter::Value<String>
pSRAAlarmEmail:
AllowedPattern: '^$|^([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)$'
ConstraintDescription: Must be a valid email address.
Default: ''
Description: (Optional) Email address for receiving SRA alarms
Type: String
pSRASolutionName:
AllowedValues: [sra-guardduty-org]
Default: sra-guardduty-org
Description: The SRA solution name. The default value is the folder name of the solution
Type: String
pSRAStagingS3BucketName:
AllowedPattern: '^([\w.-]{1,900})$|^(\/[\w.-]{1,900})*[\w.-]{1,900}$'
ConstraintDescription:
Must be alphanumeric or special characters [., _, -]. In addition, the slash character ( / ) used to delineate hierarchies in parameter names.
Default: /sra/staging-s3-bucket-name
Description:
SSM Parameter for SRA Staging S3 bucket name for the artifacts relevant to solution. (e.g., lambda zips, CloudFormation templates) S3 bucket
name can include numbers, lowercase letters, uppercase letters, and hyphens (-). It cannot start or end with a hyphen (-).
Type: AWS::SSM::Parameter::Value<String>
pSRASolutionVersion:
AllowedValues: [v1.2]
Default: v1.2
Description: The SRA solution version. Used to trigger updates on the nested StackSets.
Type: String
Resources:
rGuardDutyDeleteDetectorIAMRoleStackSet:
Type: AWS::CloudFormation::StackSet
Properties:
StackSetName: sra-guardduty-org-delete-detector-role
AutoDeployment:
Enabled: true
RetainStacksOnAccountRemoval: false
CallAs: SELF
Capabilities:
- CAPABILITY_NAMED_IAM
Description: !Sub ${pSRASolutionVersion} - Deploys an IAM role via ${pSRASolutionName} for deleting GuardDuty detectors.
ManagedExecution:
Active: true
OperationPreferences:
FailureTolerancePercentage: 100
MaxConcurrentPercentage: 100
RegionConcurrencyType: PARALLEL
PermissionModel: SERVICE_MANAGED
StackInstancesGroup:
- DeploymentTargets:
OrganizationalUnitIds:
- !Ref pRootOrganizationalUnitId
Regions:
- !Ref AWS::Region
TemplateURL: !Sub https://${pSRAStagingS3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${pSRASolutionName}/templates/sra-guardduty-org-delete-detector-role.yaml
Parameters:
- ParameterKey: pManagementAccountId
ParameterValue: !Ref AWS::AccountId
Tags:
- Key: sra-solution
Value: !Ref pSRASolutionName
rGuardDutyDeleteDetectorIAMRoleStack:
Type: AWS::CloudFormation::Stack
DeletionPolicy: Delete
UpdateReplacePolicy: Delete
Properties:
TemplateURL: !Sub https://${pSRAStagingS3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${pSRASolutionName}/templates/sra-guardduty-org-delete-detector-role.yaml
Tags:
- Key: sra-solution
Value: !Ref pSRASolutionName
Parameters:
pManagementAccountId: !Ref AWS::AccountId
rGuardDutyConfigurationIAMRoleStackSet:
Type: AWS::CloudFormation::StackSet
Properties:
StackSetName: sra-guardduty-org-configuration-role
AdministrationRoleARN: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${pStackSetAdminRole}
CallAs: SELF
Capabilities:
- CAPABILITY_NAMED_IAM
Description: !Sub ${pSRASolutionVersion} - Deploys an IAM role via ${pSRASolutionName} for configuring GuardDuty
ExecutionRoleName: !Ref pStackExecutionRole
ManagedExecution:
Active: true
OperationPreferences:
FailureTolerancePercentage: 0
MaxConcurrentPercentage: 100
RegionConcurrencyType: PARALLEL
PermissionModel: SELF_MANAGED
StackInstancesGroup:
- DeploymentTargets:
Accounts:
- !Ref pAuditAccountId
Regions:
- !Ref AWS::Region
TemplateURL: !Sub https://${pSRAStagingS3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${pSRASolutionName}/templates/sra-guardduty-org-configuration-role.yaml
Parameters:
- ParameterKey: pManagementAccountId
ParameterValue: !Ref AWS::AccountId
Tags:
- Key: sra-solution
Value: !Ref pSRASolutionName
rGuardDutyDeliveryKMSKeyStackSet:
Type: AWS::CloudFormation::StackSet
Properties:
StackSetName: sra-guardduty-org-delivery-kms-key
AdministrationRoleARN: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${pStackSetAdminRole}
CallAs: SELF
Description: !Sub ${pSRASolutionVersion} - Deploys a KMS Key via ${pSRASolutionName} for encrypting GuardDuty findings
ExecutionRoleName: !Ref pStackExecutionRole
ManagedExecution:
Active: true
OperationPreferences:
FailureTolerancePercentage: 0
MaxConcurrentPercentage: 100
RegionConcurrencyType: PARALLEL
PermissionModel: SELF_MANAGED
StackInstancesGroup:
- DeploymentTargets:
Accounts:
- !Ref pAuditAccountId
Regions:
- !Ref AWS::Region
TemplateURL: !Sub https://${pSRAStagingS3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${pSRASolutionName}/templates/sra-guardduty-org-delivery-kms-key.yaml
Parameters:
- ParameterKey: pGuardDutyOrgDeliveryKeyAlias
ParameterValue: !Ref pGuardDutyOrgDeliveryKeyAlias
- ParameterKey: pLogArchiveAccountId
ParameterValue: !Ref pLogArchiveAccountId
- ParameterKey: pManagementAccountId
ParameterValue: !Ref AWS::AccountId
- ParameterKey: pSRASecretsKeyAliasArn
ParameterValue: !Sub arn:${AWS::Partition}:kms:${AWS::Region}:${pAuditAccountId}:alias/sra-secrets-key
Tags:
- Key: sra-solution
Value: !Ref pSRASolutionName
rGuardDutyDeliveryS3BucketStackSet:
Type: AWS::CloudFormation::StackSet
DependsOn: rGuardDutyDeliveryKMSKeyStackSet
Properties:
StackSetName: sra-guardduty-org-delivery-s3-bucket
AdministrationRoleARN: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:role/${pStackSetAdminRole}
CallAs: SELF
Description: !Sub ${pSRASolutionVersion} - Deploys an S3 bucket via ${pSRASolutionName} for storing GuardDuty findings
ExecutionRoleName: !Ref pStackExecutionRole
ManagedExecution:
Active: true
OperationPreferences:
FailureTolerancePercentage: 0
MaxConcurrentPercentage: 100
RegionConcurrencyType: PARALLEL
PermissionModel: SELF_MANAGED
StackInstancesGroup:
- DeploymentTargets:
Accounts:
- !Ref pLogArchiveAccountId
Regions:
- !Ref AWS::Region
TemplateURL: !Sub https://${pSRAStagingS3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${pSRASolutionName}/templates/sra-guardduty-org-delivery-s3-bucket.yaml
Parameters:
- ParameterKey: pGuardDutyOrgDeliveryBucketPrefix
ParameterValue: !Ref pGuardDutyOrgDeliveryBucketPrefix
- ParameterKey: pGuardDutyOrgDeliveryKMSKeyArn
ParameterValue: !Sub '{{resolve:secretsmanager:arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${pAuditAccountId}:secret:sra/guardduty_org_delivery_key_arn:SecretString:GuardDutyDeliveryKeyArn:AWSCURRENT}}'
Tags:
- Key: sra-solution
Value: !Ref pSRASolutionName
rGuardDutyConfigurationStack:
Type: AWS::CloudFormation::Stack
DeletionPolicy: Delete
DependsOn:
- rGuardDutyDeleteDetectorIAMRoleStackSet
- rGuardDutyDeleteDetectorIAMRoleStack
- rGuardDutyDeliveryS3BucketStackSet
- rGuardDutyConfigurationIAMRoleStackSet
UpdateReplacePolicy: Delete
Properties:
TemplateURL: !Sub https://${pSRAStagingS3BucketName}.s3.${AWS::Region}.${AWS::URLSuffix}/${pSRASolutionName}/templates/sra-guardduty-org-configuration.yaml
Parameters:
pAutoEnableS3Logs: !Ref pAutoEnableS3Logs
pAutoEnableKubernetesAuditLogs: !Ref pAutoEnableKubernetesAuditLogs
pAutoEnableMalwareProtection: !Ref pAutoEnableMalwareProtection
pEnableRdsLoginEvents: !Ref pEnableRdsLoginEvents
pEnableEksRuntimeMonitoring: !Ref pEnableEksRuntimeMonitoring
pEnableEksAddonManagement: !Ref pEnableEksAddonManagement
pEnableLambdaNetworkLogs: !Ref pEnableLambdaNetworkLogs
pControlTowerRegionsOnly: !Ref pControlTowerRegionsOnly
pCreateLambdaLogGroup: !Ref pCreateLambdaLogGroup
pDelegatedAdminAccountId: !Ref pAuditAccountId
pDisableGuardDuty: !Ref pDisableGuardDuty
pEnabledRegions: !Ref pEnabledRegions
pFindingPublishingFrequency: !Ref pFindingPublishingFrequency
pKMSKeyArn: !Sub '{{resolve:secretsmanager:arn:${AWS::Partition}:secretsmanager:${AWS::Region}:${pAuditAccountId}:secret:sra/guardduty_org_delivery_key_arn:SecretString:GuardDutyDeliveryKeyArn:AWSCURRENT}}'
pLambdaLogGroupKmsKey: !Ref pLambdaLogGroupKmsKey
pLambdaLogGroupRetention: !Ref pLambdaLogGroupRetention
pLambdaLogLevel: !Ref pLambdaLogLevel
pOrganizationId: !Ref pOrganizationId
pPublishingDestinationBucketName: !Sub ${pGuardDutyOrgDeliveryBucketPrefix}-${pLogArchiveAccountId}-${AWS::Region}
pSRAAlarmEmail: !Ref pSRAAlarmEmail
pSRAStagingS3BucketName: !Ref pSRAStagingS3BucketName
Tags:
- Key: sra-solution
Value: !Ref pSRASolutionName
Outputs:
oPublishingDestinationBucketName:
Description: Publishing Destination Bucket Name
Value: !GetAtt [rGuardDutyConfigurationStack, Outputs.oPublishingDestinationBucketName]
Export:
Name: ePublishingDestinationBucketName
oPublishingDestinationBucketArn:
Description: Publishing Destination Bucket Name
Value: !GetAtt [rGuardDutyConfigurationStack, Outputs.oPublishingDestinationBucketArn]
Export:
Name: ePublishingDestinationBucketArn
oGuardDutyDeliveryKeyArn:
Description: GuardDuty Delivery KMS Key ARN
Value: !GetAtt [rGuardDutyConfigurationStack, Outputs.oGuardDutyDeliveryKeyArn]
Export:
Name: eGuardDutyDeliveryKeyArn