Skip to content

Commit f78c346

Browse files
authored
fix(efs): LifecyclePolicy of AFTER_7_DAYS is not applied (#9475)
Closes #9474 (see for details). ```ts const fileSystem = new efs.FileSystem(this, "EFS", { removalPolicy: cdk.RemovalPolicy.DESTROY, lifecyclePolicy: efs.LifecyclePolicy.AFTER_7_DAYS, vpc, }); ``` Old behavior: ```bash npm run build; cdk synth | grep -r -n1 "AFTER_"; cdk diff > demo@0.1.0 build /Users/robertd/code/demo > tsc Stack EFSDemoTest Resources [~] AWS::EFS::FileSystem EFS EFSBAA8953A └─ [-] LifecyclePolicies └─ [{"TransitionToIA":"AFTER_14_DAYS"}] ``` **New (expected) behavior:** 🎆 🥳 🍾 ```bash npm run build; cdk synth | grep -r -n1 "AFTER_"; cdk diff > demo@0.1.0 build /Users/robertd/demo > tsc (standard input)-327- LifecyclePolicies: (standard input):328: - TransitionToIA: AFTER_7_DAYS (standard input)-329- UpdateReplacePolicy: Delete Stack EFSDemoTest Resources [~] AWS::EFS::FileSystem EFS EFSBAA8953A └─ [~] LifecyclePolicies └─ @@ -1,5 +1,5 @@ [ ] [ [ ] { [-] "TransitionToIA": "AFTER_14_DAYS" [+] "TransitionToIA": "AFTER_7_DAYS" [ ] } [ ] ] ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5c01da8 commit f78c346

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

packages/@aws-cdk/aws-efs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fileSystem.connections.allowDefaultPortFrom(instance);
6868

6969
In order to automatically mount this file system during instance launch,
7070
following code can be used as reference:
71-
```
71+
```ts
7272
const vpc = new ec2.Vpc(this, 'VPC');
7373

7474
const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {

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

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,27 @@ export enum LifecyclePolicy {
1313
/**
1414
* After 7 days of not being accessed.
1515
*/
16-
AFTER_7_DAYS,
16+
AFTER_7_DAYS = 'AFTER_7_DAYS',
1717

1818
/**
1919
* After 14 days of not being accessed.
2020
*/
21-
AFTER_14_DAYS,
21+
AFTER_14_DAYS = 'AFTER_14_DAYS',
2222

2323
/**
2424
* After 30 days of not being accessed.
2525
*/
26-
AFTER_30_DAYS,
26+
AFTER_30_DAYS = 'AFTER_30_DAYS',
2727

2828
/**
2929
* After 60 days of not being accessed.
3030
*/
31-
AFTER_60_DAYS,
31+
AFTER_60_DAYS = 'AFTER_60_DAYS',
3232

3333
/**
3434
* After 90 days of not being accessed.
3535
*/
36-
AFTER_90_DAYS
36+
AFTER_90_DAYS = 'AFTER_90_DAYS'
3737
}
3838

3939
/**
@@ -247,9 +247,7 @@ export class FileSystem extends Resource implements IFileSystem {
247247
const filesystem = new CfnFileSystem(this, 'Resource', {
248248
encrypted: props.encrypted,
249249
kmsKeyId: (props.kmsKey ? props.kmsKey.keyId : undefined),
250-
lifecyclePolicies: (props.lifecyclePolicy ? Array.of({
251-
transitionToIa: LifecyclePolicy[props.lifecyclePolicy],
252-
} as CfnFileSystem.LifecyclePolicyProperty) : undefined),
250+
lifecyclePolicies: (props.lifecyclePolicy ? [{ transitionToIa: props.lifecyclePolicy }] : undefined),
253251
performanceMode: props.performanceMode,
254252
throughputMode: props.throughputMode,
255253
provisionedThroughputInMibps: props.provisionedThroughputPerSecond?.toMebibytes(),

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ test('encrypted file system is created correctly with custom KMS', () => {
7575
}));
7676
});
7777

78-
test('file system is created correctly with life cycle property', () => {
78+
test('file system is created correctly with a life cycle property', () => {
7979
// WHEN
8080
new FileSystem(stack, 'EfsFileSystem', {
8181
vpc,
82-
lifecyclePolicy: LifecyclePolicy.AFTER_14_DAYS,
82+
lifecyclePolicy: LifecyclePolicy.AFTER_7_DAYS,
8383
});
8484
// THEN
8585
expectCDK(stack).to(haveResource('AWS::EFS::FileSystem', {
8686
LifecyclePolicies: [{
87-
TransitionToIA: 'AFTER_14_DAYS',
87+
TransitionToIA: 'AFTER_7_DAYS',
8888
}],
8989
}));
9090
});

0 commit comments

Comments
 (0)