Skip to content

Commit 3578d84

Browse files
authored
fix(efs): cannot use encryption key imported from another account (#11524)
the `keyId` property supports using the ARN or the key ID. this change uses the ARN as it's more robust and allows usage of a key which is cross-account. It currently fails as the ID is looked up within the same account and not found. Closes #7641 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 90f0b9d commit 3578d84

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/@aws-cdk/aws-efs/lib/efs-file-system.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class FileSystem extends Resource implements IFileSystem {
244244

245245
const filesystem = new CfnFileSystem(this, 'Resource', {
246246
encrypted: props.encrypted,
247-
kmsKeyId: (props.kmsKey ? props.kmsKey.keyId : undefined),
247+
kmsKeyId: props.kmsKey?.keyArn,
248248
lifecyclePolicies: (props.lifecyclePolicy ? [{ transitionToIa: props.lifecyclePolicy }] : undefined),
249249
performanceMode: props.performanceMode,
250250
throughputMode: props.throughputMode,

packages/@aws-cdk/aws-efs/test/efs-file-system.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ test('encrypted file system is created correctly with custom KMS', () => {
7070
expectCDK(stack).to(haveResource('AWS::EFS::FileSystem', {
7171
Encrypted: true,
7272
KmsKeyId: {
73-
Ref: 'customKeyFSDDB87C6D',
73+
'Fn::GetAtt': [
74+
'customKeyFSDDB87C6D',
75+
'Arn',
76+
],
7477
},
7578
}));
7679
});

0 commit comments

Comments
 (0)