Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add notes about @aws-cdk/kms:applyImportedAliasPermissionsToPrincipal…
… to docs
  • Loading branch information
Farid Nouri Neshat authored and faridnsh committed May 27, 2025
commit df4f6368544f35448f738ffc7fa04f28e017c71d
7 changes: 4 additions & 3 deletions packages/aws-cdk-lib/aws-kms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ const trail = new cloudtrail.Trail(this, 'myCloudTrail', {
});
```

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

### Lookup key by alias

Expand Down
6 changes: 5 additions & 1 deletion packages/aws-cdk-lib/aws-kms/lib/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ export class Alias extends AliasBase {
* Import an existing KMS Alias defined outside the CDK app, by the alias name. This method should be used
* instead of 'fromAliasAttributes' when the underlying KMS Key ARN is not available.
* This Alias will not have a direct reference to the KMS Key, so addAlias method is not supported.
* 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.
*
* If the `@aws-cdk/aws-kms:applyImportedAliasPermissionsToPrincipal` feature flag is set to `true`,
* the grant* methods will use the kms:ResourceAliases condition to grant permissions to the specific alias name.
* They will only modify the principal policy, not the key resource policy.
* Without the feature flag `grant*` methods will be a no-op.
*
* @param scope The parent creating construct (usually `this`).
* @param id The construct's name.
Expand Down