You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(kms): kms key grant methods misidentify region when enclosing stack is different region (#29315)
### Issue # (if applicable)
Closes#29308
### Reason for this change
This problem is grant() determines the region of a Key using
Stack.of(key).region, however the enclosing Stack's region may differ to
that of the actual resource. When this happens, the IAM policy generated
allows a `*` resource which is against the least privilege rule.
### Description of changes
KMS key already has `env` value on account and region, use this first.
If not exist, use stack account and region.
### Description of how you validated changes
New unit test
### Checklist
- [X] My code adheres to the [CONTRIBUTING
GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and
[DESIGN
GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)
----
*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
---------
Co-authored-by: paulhcsun <[email protected]>
Copy file name to clipboardExpand all lines: packages/aws-cdk-lib/cx-api/FEATURE_FLAGS.md
+17-1
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,7 @@ Flags come in three types:
66
66
|[@aws-cdk/aws-cloudwatch-actions:changeLambdaPermissionLogicalIdForLambdaAction](#aws-cdkaws-cloudwatch-actionschangelambdapermissionlogicalidforlambdaaction)| When enabled, the logical ID of a Lambda permission for a Lambda action includes an alarm ID. | 2.124.0 | (fix) |
67
67
|[@aws-cdk/aws-codepipeline:crossAccountKeysDefaultValueToFalse](#aws-cdkaws-codepipelinecrossaccountkeysdefaultvaluetofalse)| Enables Pipeline to set the default value for crossAccountKeys to false. | 2.127.0 | (default) |
68
68
|[@aws-cdk/aws-codepipeline:defaultPipelineTypeToV2](#aws-cdkaws-codepipelinedefaultpipelinetypetov2)| Enables Pipeline to set the default pipeline type to V2. | V2NEXT | (default) |
69
+
|[@aws-cdk/aws-kms:reduceCrossAccountRegionPolicyScope](#aws-cdkaws-kmsreducecrossaccountregionpolicyscope)| When enabled, IAM Policy created from KMS key grant will reduce the resource scope to this key only. | V2NEXT | (fix) |
69
70
70
71
<!-- END table -->
71
72
@@ -122,7 +123,8 @@ The following json shows the current recommended set of flags, as `cdk init` wou
0 commit comments