Skip to content

Commit

Permalink
feat: deprecated keyArn and added aliasArn as the new name for the AR…
Browse files Browse the repository at this point in the history
…N into the alias L2 construct
  • Loading branch information
rafaelrcamargo committed Nov 30, 2023
1 parent 1a586f2 commit fdc2cf9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/aws-cdk-lib/aws-kms/lib/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ abstract class AliasBase extends Resource implements IAlias {

public abstract readonly aliasTargetKey: IKey;

/**
* The ARN of the alias.
*
* @attribute
* @deprecated use `aliasArn` instead
*/
public get keyArn(): string {
return Stack.of(this).formatArn({
service: 'kms',
Expand All @@ -67,6 +73,15 @@ abstract class AliasBase extends Resource implements IAlias {
});
}

/**
* The ARN of the alias.
*
* @attribute
*/
public get aliasArn(): string {
return this.keyArn;
}

public get keyId(): string {
return this.aliasName;
}
Expand Down
10 changes: 10 additions & 0 deletions packages/aws-cdk-lib/aws-kms/test/alias.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,16 @@ test('does not add alias if starts with token', () => {
});
});

test('aliasArn and keyArn from alias should match', () => {
const app = new App();
const stack = new Stack(app, 'Test');
const key = new Key(stack, 'Key');

const alias = new Alias(stack, 'Alias', { targetKey: key, aliasName: 'alias/foo' });

expect(alias.aliasArn).toEqual(alias.keyArn);
});

class AliasOutputsConstruct extends Construct {
constructor(scope: Construct, id: string, key: IKey) {
super(scope, id);
Expand Down

0 comments on commit fdc2cf9

Please sign in to comment.