Skip to content

Commit 0e552db

Browse files
authored
fix(bootstrap): KMS keys cannot be tagged (#21975)
This change allows IAM users and roles within the account to update and replace the tags on the provided KMS key. If the bootstrap command is run and custom tags are specified, these are added to the KMS key. If the command is run additional times with different tags, the key policy needs to allow the replacing / updating of these tags so that it succeeds. Fixes #21281 **Note for reviewer:** Due to performance limitations of my current device, I have been unable to test these changes. I welcome edits by maintainers as necessary. ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent de68652 commit 0e552db

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ Resources:
123123
- kms:ScheduleKeyDeletion
124124
- kms:CancelKeyDeletion
125125
- kms:GenerateDataKey
126+
- kms:TagResource
127+
- kms:UntagResource
126128
Effect: Allow
127129
Principal:
128130
AWS:

packages/aws-cdk/test/integ/cli/bootstrapping.integtest.ts

+23
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,29 @@ integTest('add tags, left alone on re-bootstrap', withDefaultFixture(async (fixt
255255
]);
256256
}));
257257

258+
integTest('can add tags then update tags during re-bootstrap', withDefaultFixture(async (fixture) => {
259+
const bootstrapStackName = fixture.bootstrapStackName;
260+
261+
await fixture.cdkBootstrapModern({
262+
verbose: true,
263+
toolkitStackName: bootstrapStackName,
264+
tags: 'Foo=Bar',
265+
cfnExecutionPolicy: 'arn:aws:iam::aws:policy/AdministratorAccess',
266+
});
267+
await fixture.cdkBootstrapModern({
268+
verbose: true,
269+
toolkitStackName: bootstrapStackName,
270+
tags: 'Foo=BarBaz',
271+
cfnExecutionPolicy: 'arn:aws:iam::aws:policy/AdministratorAccess',
272+
force: true,
273+
});
274+
275+
const response = await fixture.aws.cloudFormation('describeStacks', { StackName: bootstrapStackName });
276+
expect(response.Stacks?.[0].Tags).toEqual([
277+
{ Key: 'Foo', Value: 'BarBaz' },
278+
]);
279+
}));
280+
258281
integTest('can deploy modern-synthesized stack even if bootstrap stack name is unknown', withDefaultFixture(async (fixture) => {
259282
const bootstrapStackName = fixture.bootstrapStackName;
260283

0 commit comments

Comments
 (0)