Skip to content

Commit 1c7f6e8

Browse files
author
Farid Nouri Neshat
committed
Add notes about @aws-cdk/kms:applyImportedAliasPermissionsToPrincipal to docs
1 parent 1798498 commit 1c7f6e8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

packages/aws-cdk-lib/aws-kms/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ const trail = new cloudtrail.Trail(this, 'myCloudTrail', {
9191
});
9292
```
9393

94-
Note that calls to `addToResourcePolicy` method on `myKeyAlias` will be a no-op,
95-
`addAlias` and `aliasTargetKey` will fail and `grant*` methods will not modify the key policy,
96-
as the imported alias does not have a reference to the underlying KMS Key.
94+
Note that calls to `addToResourcePolicy` method on `myKeyAlias` will be a no-op, `addAlias` and `aliasTargetKey` will fail.
95+
The `grant*` methods will not modify the key policy, as the imported alias does not have a reference to the underlying KMS Key.
96+
For the `grant*` methods to modify the principal's IAM policy, the feature flag `@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal`
97+
must be set to `true`. By default, this flag is `false` and `grant*` calls on an imported alias are a no-op.
9798

9899
### Lookup key by alias
99100

packages/aws-cdk-lib/aws-kms/lib/alias.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ export class Alias extends AliasBase {
188188
* Import an existing KMS Alias defined outside the CDK app, by the alias name. This method should be used
189189
* instead of 'fromAliasAttributes' when the underlying KMS Key ARN is not available.
190190
* This Alias will not have a direct reference to the KMS Key, so addAlias method is not supported.
191-
* The grant* methods will use the kms:ResourceAliases condition to grant permissions to the specific alias name. They will also only modify the principal policy, not the key resource policy.
191+
*
192+
* If the `@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal` feature flag is set to `true`,
193+
* the grant* methods will use the kms:ResourceAliases condition to grant permissions to the specific alias name.
194+
* They will only modify the principal policy, not the key resource policy.
195+
* Without the feature flag `grant*` methods will be a no-op.
192196
*
193197
* @param scope The parent creating construct (usually `this`).
194198
* @param id The construct's name.

0 commit comments

Comments
 (0)