Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/aws-cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async function parseCommandLineArguments() {
.option('bootstrap-customer-key', { type: 'boolean', desc: 'Create a Customer Master Key (CMK) for the bootstrap bucket (you will be charged but can customize permissions, modern bootstrapping only)', default: undefined, conflicts: 'bootstrap-kms-key-id' })
.option('qualifier', { type: 'string', desc: 'Unique string to distinguish multiple bootstrap stacks', default: undefined })
.option('public-access-block-configuration', { type: 'boolean', desc: 'Block public access configuration on CDK toolkit bucket (enabled by default) ', default: undefined })
.option('container-asset-scan-on-push', { type: 'boolean', desc: 'Scan container asset images on push on CDK toolkit ECR (disabled by default)', default: false })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this disabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match current behavior.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opened a PR to enable by default:
#17994

.option('tags', { type: 'array', alias: 't', desc: 'Tags to add for the stack (KEY=VALUE)', nargs: 1, requiresArg: true, default: [] })
.option('execute', { type: 'boolean', desc: 'Whether to execute ChangeSet (--no-execute will NOT execute the ChangeSet)', default: true })
.option('trust', { type: 'array', desc: 'The AWS account IDs that should be trusted to perform deployments into this environment (may be repeated, modern bootstrapping only)', default: [], nargs: 1, requiresArg: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export class Bootstrapper {
CloudFormationExecutionPolicies: cloudFormationExecutionPolicies.join(','),
Qualifier: params.qualifier,
PublicAccessBlockConfiguration: params.publicAccessBlockConfiguration || params.publicAccessBlockConfiguration === undefined ? 'true' : 'false',
ContainerAssetScanOnPush: params.containerAssetScanOnPush === undefined ? 'false' : params.containerAssetScanOnPush ? 'true' : 'false',
}, {
...options,
terminationProtection: options.terminationProtection ?? current.terminationProtection,
Expand Down
7 changes: 7 additions & 0 deletions packages/aws-cdk/lib/api/bootstrap/bootstrap-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,11 @@ export interface BootstrappingParameters {
*/
readonly publicAccessBlockConfiguration?: boolean;

/**
* Whether or not to enable image scanning on push for the container assets ECR repository
*
* @default false
*/
readonly containerAssetScanOnPush?: boolean;

}
8 changes: 8 additions & 0 deletions packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Parameters:
Default: 'true'
Type: 'String'
AllowedValues: ['true', 'false']
ContainerAssetScanOnPush:
Description: Whether or not to enable image scanning on push for the container assets ECR repository
Default: 'false'
Type: 'String'
AllowedValues: [ 'true', 'false' ]
Conditions:
HasTrustedAccounts:
Fn::Not:
Expand Down Expand Up @@ -207,6 +212,9 @@ Resources:
- HasCustomContainerAssetsRepositoryName
- Fn::Sub: "${ContainerAssetsRepositoryName}"
- Fn::Sub: cdk-${Qualifier}-container-assets-${AWS::AccountId}-${AWS::Region}
ImageScanningConfiguration:
ScanOnPush:
Ref: ContainerAssetScanOnPush
FilePublishingRole:
Type: AWS::IAM::Role
Properties:
Expand Down
28 changes: 28 additions & 0 deletions packages/aws-cdk/test/api/bootstrap2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,32 @@ describe('Bootstrapping v2', () => {
}));
});
});

describe('Scan on push', () => {
test.each([
// no scan on push parameter passed
[undefined, 'false'],
// passed as true
[true, 'true'],
// passed as false
[false, 'false'],
])('containerAssetScanOnPush=%p => parameter becomes %p', async (containerAssetScanOnPush, execptedSetting) => {
// GIVEN
// mockTheToolkitInfo({});

// WHEN
await bootstrapper.bootstrapEnvironment(env, sdk, {
parameters: {
containerAssetScanOnPush,
},
});

// THEN
expect(mockDeployStack).toHaveBeenCalledWith(expect.objectContaining({
parameters: expect.objectContaining({
ContainerAssetScanOnPush: execptedSetting,
}),
}));
});
});
});