Skip to content

Commit

Permalink
fix(volume_access): consolidate role into org stackset
Browse files Browse the repository at this point in the history
* move role into single organization stackset
* deploy role in one region
* regional kms keys conditionally depend on role
* costs are sequential regional deployments
  • Loading branch information
cgeers committed Oct 4, 2024
1 parent 1f9e336 commit b97ee4d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 54 deletions.
1 change: 0 additions & 1 deletion modules/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ lint:
yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint -
yq '.Resources.OrganizationRuleStackSet.Properties.TemplateBody' log_ingestion.events.cft.yaml | cfn-lint -
yq '.Resources.ScanningKmsKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint -
yq '.Resources.OrganizationRoleStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint -
yq '.Resources.OrganizationKMSKeyStackSet.Properties.TemplateBody' volume_access.cft.yaml | cfn-lint -

publish:
Expand Down
88 changes: 35 additions & 53 deletions modules/volume_access.cft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ Resources:
Properties:
AliasName: !Sub alias/sysdig-secure-scanning-${NameSuffix}
TargetKeyId: !Ref ScanningKmsKey
OrganizationRoleStackSet:
OrganizationKMSKeyStackSet:
Type: AWS::CloudFormation::StackSet
Condition: IsOrganizational
Properties:
StackSetName: !Sub sysdig-secure-scanning-organization-roles-${NameSuffix}
Description: IAM Role used to create IAM roles scan organization accounts/regions
StackSetName: !Sub sysdig-secure-scanning-organization-kmskey-${NameSuffix}
Description: Create one role, and a kms key in each instrumented region, within accounts under instumented organizational units
PermissionModel: SERVICE_MANAGED
Capabilities:
- "CAPABILITY_NAMED_IAM"
Expand All @@ -282,6 +282,7 @@ Resources:
MaxConcurrentPercentage: 100
FailureTolerancePercentage: 90
ConcurrencyMode: SOFT_FAILURE_TOLERANCE
RegionConcurrencyType: SEQUENTIAL
Parameters:
- ParameterKey: NameSuffix
ParameterValue: !Ref NameSuffix
Expand All @@ -291,32 +292,43 @@ Resources:
ParameterValue: !Ref TrustedIdentity
- ParameterKey: ExternalID
ParameterValue: !Ref ExternalID
- ParameterKey: Regions
ParameterValue: !Join [ ',', !Ref Regions ]
StackInstancesGroup:
- DeploymentTargets:
OrganizationalUnitIds: !Ref OrganizationalUnitIDs
Regions: [!Ref "AWS::Region"]
Regions: !Ref Regions
TemplateBody: |
AWSTemplateFormatVersion: "2010-09-09"
Description: IAM Role used by Sysdig Secure Vulnerability Scanning
Parameters:
Description: "Template to create KMS Key and Alias for Sysdig Agentless Scanning"
Parameters:
NameSuffix:
Type: String
Description: Suffix to append to the resource name identifiers
AllowedPattern: '[0-9a-z]+'
MaxLength: 8
MinLength: 4
ScanningAccountID:
Type: String
Description: The AWS Account ID of the Sysdig Scanning Account
ExternalID:
Type: String
Description: Sysdig assigned token that proves you own this account
TrustedIdentity:
Type: String
Description: The Role in Sysdig's AWS Account with permissions to your account
ScanningAccountID:
Type: String
Description: The AWS Account ID of the Sysdig Scanning Account
Regions:
Type: CommaDelimitedList
Description: Comma separated list of regions enabled for Sysdig Scanning
Conditions:
GlobalRegion:
Fn::Equals:
- !Ref "AWS::Region"
- !Select [ "0", !Ref Regions ]
Resources:
ScanningRole:
Type: AWS::IAM::Role
Condition: GlobalRegion
Properties:
RoleName: !Sub sysdig-secure-scanning-${NameSuffix}
AssumeRolePolicyDocument:
Expand Down Expand Up @@ -396,52 +408,22 @@ Resources:
Condition:
StringEqualsIgnoreCase:
"aws:ResourceTag/CreatedBy": "Sysdig"
OrganizationKMSKeyStackSet:
Type: AWS::CloudFormation::StackSet
Condition: IsOrganizational
DependsOn:
- OrganizationRoleStackSet
Properties:
StackSetName: !Sub sysdig-secure-scanning-organization-kmskey-${NameSuffix}
Description: IAM Role used to create KMS Keys to scan organization accounts/regions
PermissionModel: SERVICE_MANAGED
Capabilities:
- "CAPABILITY_NAMED_IAM"
AutoDeployment:
Enabled: true
RetainStacksOnAccountRemoval: false
ManagedExecution:
Active: true
OperationPreferences:
MaxConcurrentPercentage: 100
FailureTolerancePercentage: 90
ConcurrencyMode: SOFT_FAILURE_TOLERANCE
RegionConcurrencyType: PARALLEL
Parameters:
- ParameterKey: NameSuffix
ParameterValue: !Ref NameSuffix
- ParameterKey: ScanningAccountID
ParameterValue: !Ref ScanningAccountID
StackInstancesGroup:
- DeploymentTargets:
OrganizationalUnitIds: !Ref OrganizationalUnitIDs
Regions: !Ref Regions
TemplateBody: |
AWSTemplateFormatVersion: "2010-09-09"
Description: "Template to create KMS Key and Alias for Sysdig Agentless Scanning"
Parameters:
NameSuffix:
Type: String
Description: Suffix to append to the resource name identifiers
AllowedPattern: '[0-9a-z]+'
MaxLength: 8
MinLength: 4
ScanningAccountID:
Type: String
Description: The AWS Account ID of the Sysdig Scanning Account
Resources:
GlobalRegionWaitHandle:
Condition: GlobalRegion
DependsOn: ScanningRole
Type: AWS::CloudFormation::WaitConditionHandle
RegionWaitHandle:
Type: AWS::CloudFormation::WaitConditionHandle
RegionalWaitCondition:
Type: AWS::CloudFormation::WaitCondition
Properties:
Handle: !If [ GlobalRegion, !Ref GlobalRegionWaitHandle, !Ref RegionWaitHandle ]
Timeout: 1
Count: 0
ScanningKmsKey:
Type: 'AWS::KMS::Key'
DependsOn: RegionalWaitCondition
Properties:
Description: "Sysdig Agentless Scanning encryption key"
PendingWindowInDays: 7
Expand Down

0 comments on commit b97ee4d

Please sign in to comment.