-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Open
Labels
@aws-cdk/aws-kmsRelated to AWS Key ManagementRelated to AWS Key ManagementbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2
Description
Describe the bug
When using Alias.fromAliasName the alias name is not prefixed with "alias/" if its not already provided.
In comparsion, when using new Alias, alias name is prefixed with "alias/"
aws-cdk/packages/aws-cdk-lib/aws-kms/lib/alias.ts
Lines 244 to 248 in 7da5aeb
| public static fromAliasName(scope: Construct, id: string, aliasName: string): IAlias { | |
| class Import extends Resource implements IAlias { | |
| public readonly keyArn = Stack.of(this).formatArn({ service: 'kms', resource: aliasName }); | |
| public readonly keyId = aliasName; | |
| public readonly aliasName = aliasName; |
vs
aws-cdk/packages/aws-cdk-lib/aws-kms/lib/alias.ts
Lines 331 to 333 in 7da5aeb
| if (!aliasName.startsWith(REQUIRED_ALIAS_PREFIX)) { | |
| aliasName = REQUIRED_ALIAS_PREFIX + aliasName; | |
| } |
Regression Issue
- Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version
No response
Expected Behavior
Alias should be prefixed with alias/ when imported using Alias.fromAliasName when not already prefixed with alias/
Current Behavior
Alias is not prefixed with alias/
Reproduction Steps
Alias.fromAliasName(
this,
"Foo",
"my-alias-name",
).aliasName; // my-alias-name
new Alias(this, "FooNew", {
aliasName: "my-alias-name",
}).aliasName; // alias/my-alias-name
Possible Solution
Add required alias prefix when alias is not already prefixed
Additional Information/Context
I can provide a pull request with a fix
AWS CDK Library version (aws-cdk-lib)
aws-cdk-lib@2.230.0
AWS CDK CLI version
cdk@2.1100.3
Node.js Version
22.21.1
OS
macos
Language
TypeScript
Language Version
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-kmsRelated to AWS Key ManagementRelated to AWS Key ManagementbugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortp2