Skip to content

Commit b97ee4d

Browse files
committed
fix(volume_access): consolidate role into org stackset
* move role into single organization stackset * deploy role in one region * regional kms keys conditionally depend on role * costs are sequential regional deployments
1 parent 1f9e336 commit b97ee4d

File tree

2 files changed

+35
-54
lines changed

2 files changed

+35
-54
lines changed

modules/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ lint:
2727
yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint -
2828
yq '.Resources.OrganizationRuleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint -
2929
yq '.Resources.ScanningKmsKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint -
30-
yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint -
3130
yq '.Resources.OrganizationKMSKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint -
3231

3332
publish:

modules/volume_access.cft.yaml

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ Resources:
264264
Properties:
265265
AliasName: !Sub alias/sysdig-secure-scanning-${NameSuffix}
266266
TargetKeyId: !Ref ScanningKmsKey
267-
OrganizationRoleStackSet:
267+
OrganizationKMSKeyStackSet:
268268
Type: AWS::CloudFormation::StackSet
269269
Condition: IsOrganizational
270270
Properties:
271-
StackSetName: !Sub sysdig-secure-scanning-organization-roles-${NameSuffix}
272-
Description: IAM Role used to create IAM roles scan organization accounts/regions
271+
StackSetName: !Sub sysdig-secure-scanning-organization-kmskey-${NameSuffix}
272+
Description: Create one role, and a kms key in each instrumented region, within accounts under instumented organizational units
273273
PermissionModel: SERVICE_MANAGED
274274
Capabilities:
275275
- "CAPABILITY_NAMED_IAM"
@@ -282,6 +282,7 @@ Resources:
282282
MaxConcurrentPercentage: 100
283283
FailureTolerancePercentage: 90
284284
ConcurrencyMode: SOFT_FAILURE_TOLERANCE
285+
RegionConcurrencyType: SEQUENTIAL
285286
Parameters:
286287
- ParameterKey: NameSuffix
287288
ParameterValue: !Ref NameSuffix
@@ -291,32 +292,43 @@ Resources:
291292
ParameterValue: !Ref TrustedIdentity
292293
- ParameterKey: ExternalID
293294
ParameterValue: !Ref ExternalID
295+
- ParameterKey: Regions
296+
ParameterValue: !Join [ ',', !Ref Regions ]
294297
StackInstancesGroup:
295298
- DeploymentTargets:
296299
OrganizationalUnitIds: !Ref OrganizationalUnitIDs
297-
Regions: [!Ref "AWS::Region"]
300+
Regions: !Ref Regions
298301
TemplateBody: |
299302
AWSTemplateFormatVersion: "2010-09-09"
300-
Description: IAM Role used by Sysdig Secure Vulnerability Scanning
301-
Parameters:
303+
Description: "Template to create KMS Key and Alias for Sysdig Agentless Scanning"
304+
Parameters:
302305
NameSuffix:
303306
Type: String
304307
Description: Suffix to append to the resource name identifiers
305308
AllowedPattern: '[0-9a-z]+'
306309
MaxLength: 8
307310
MinLength: 4
311+
ScanningAccountID:
312+
Type: String
313+
Description: The AWS Account ID of the Sysdig Scanning Account
308314
ExternalID:
309315
Type: String
310316
Description: Sysdig assigned token that proves you own this account
311317
TrustedIdentity:
312318
Type: String
313319
Description: The Role in Sysdig's AWS Account with permissions to your account
314-
ScanningAccountID:
315-
Type: String
316-
Description: The AWS Account ID of the Sysdig Scanning Account
320+
Regions:
321+
Type: CommaDelimitedList
322+
Description: Comma separated list of regions enabled for Sysdig Scanning
323+
Conditions:
324+
GlobalRegion:
325+
Fn::Equals:
326+
- !Ref "AWS::Region"
327+
- !Select [ "0", !Ref Regions ]
317328
Resources:
318329
ScanningRole:
319330
Type: AWS::IAM::Role
331+
Condition: GlobalRegion
320332
Properties:
321333
RoleName: !Sub sysdig-secure-scanning-${NameSuffix}
322334
AssumeRolePolicyDocument:
@@ -396,52 +408,22 @@ Resources:
396408
Condition:
397409
StringEqualsIgnoreCase:
398410
"aws:ResourceTag/CreatedBy": "Sysdig"
399-
OrganizationKMSKeyStackSet:
400-
Type: AWS::CloudFormation::StackSet
401-
Condition: IsOrganizational
402-
DependsOn:
403-
- OrganizationRoleStackSet
404-
Properties:
405-
StackSetName: !Sub sysdig-secure-scanning-organization-kmskey-${NameSuffix}
406-
Description: IAM Role used to create KMS Keys to scan organization accounts/regions
407-
PermissionModel: SERVICE_MANAGED
408-
Capabilities:
409-
- "CAPABILITY_NAMED_IAM"
410-
AutoDeployment:
411-
Enabled: true
412-
RetainStacksOnAccountRemoval: false
413-
ManagedExecution:
414-
Active: true
415-
OperationPreferences:
416-
MaxConcurrentPercentage: 100
417-
FailureTolerancePercentage: 90
418-
ConcurrencyMode: SOFT_FAILURE_TOLERANCE
419-
RegionConcurrencyType: PARALLEL
420-
Parameters:
421-
- ParameterKey: NameSuffix
422-
ParameterValue: !Ref NameSuffix
423-
- ParameterKey: ScanningAccountID
424-
ParameterValue: !Ref ScanningAccountID
425-
StackInstancesGroup:
426-
- DeploymentTargets:
427-
OrganizationalUnitIds: !Ref OrganizationalUnitIDs
428-
Regions: !Ref Regions
429-
TemplateBody: |
430-
AWSTemplateFormatVersion: "2010-09-09"
431-
Description: "Template to create KMS Key and Alias for Sysdig Agentless Scanning"
432-
Parameters:
433-
NameSuffix:
434-
Type: String
435-
Description: Suffix to append to the resource name identifiers
436-
AllowedPattern: '[0-9a-z]+'
437-
MaxLength: 8
438-
MinLength: 4
439-
ScanningAccountID:
440-
Type: String
441-
Description: The AWS Account ID of the Sysdig Scanning Account
442-
Resources:
411+
412+
GlobalRegionWaitHandle:
413+
Condition: GlobalRegion
414+
DependsOn: ScanningRole
415+
Type: AWS::CloudFormation::WaitConditionHandle
416+
RegionWaitHandle:
417+
Type: AWS::CloudFormation::WaitConditionHandle
418+
RegionalWaitCondition:
419+
Type: AWS::CloudFormation::WaitCondition
420+
Properties:
421+
Handle: !If [ GlobalRegion, !Ref GlobalRegionWaitHandle, !Ref RegionWaitHandle ]
422+
Timeout: 1
423+
Count: 0
443424
ScanningKmsKey:
444425
Type: 'AWS::KMS::Key'
426+
DependsOn: RegionalWaitCondition
445427
Properties:
446428
Description: "Sysdig Agentless Scanning encryption key"
447429
PendingWindowInDays: 7

0 commit comments

Comments
 (0)