Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion packages/aws-cdk-lib/aws-kms/lib/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ export class Alias extends AliasBase {
}

public get keyRef(): KeyReference {
return this.aliasTargetKey.keyRef;
return {
keyArn: this.keyArn,
keyId: this.keyId,
};
}

public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant {
Expand Down
27 changes: 27 additions & 0 deletions packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,33 @@ describe('subscription filter', () => {
});
});

test('encrypting log group with referenced alias', () => {
const stack = new Stack();

const alias = kms.Alias.fromAliasName(stack, 'KmsAlias', 'alias/some-alias');

new LogGroup(stack, 'LogGroup', {
encryptionKey: alias,
});

Template.fromStack(stack).hasResourceProperties('AWS::Logs::LogGroup', {
KmsKeyId: {
'Fn::Join': [
'',
[
'arn:',
{ Ref: 'AWS::Partition' },
':kms:',
{ Ref: 'AWS::Region' },
':',
{ Ref: 'AWS::AccountId' },
':alias/some-alias',
],
],
},
});
});

test('create a Add Key transformer against a log group', () => {
// GIVEN
const stack = new Stack();
Expand Down
Loading