File tree 2 files changed +20
-10
lines changed
packages/@aws-cdk/aws-efs 2 files changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -341,15 +341,21 @@ export class FileSystem extends FileSystemBase {
341
341
const encrypted = props . encrypted ?? ( FeatureFlags . of ( this ) . isEnabled (
342
342
cxapi . EFS_DEFAULT_ENCRYPTION_AT_REST ) ? true : undefined ) ;
343
343
344
+ // LifecyclePolicies is an array of lists containing a single policy
345
+ let lifecyclePolicies = [ ] ;
346
+
347
+ if ( props . lifecyclePolicy ) {
348
+ lifecyclePolicies . push ( { transitionToIa : props . lifecyclePolicy } ) ;
349
+ }
350
+
351
+ if ( props . outOfInfrequentAccessPolicy ) {
352
+ lifecyclePolicies . push ( { transitionToPrimaryStorageClass : props . outOfInfrequentAccessPolicy } ) ;
353
+ }
354
+
344
355
const filesystem = new CfnFileSystem ( this , 'Resource' , {
345
356
encrypted : encrypted ,
346
357
kmsKeyId : props . kmsKey ?. keyArn ,
347
- lifecyclePolicies : (
348
- ( props . lifecyclePolicy || props . outOfInfrequentAccessPolicy ) ?
349
- [ {
350
- transitionToIa : props . lifecyclePolicy ,
351
- transitionToPrimaryStorageClass : props . outOfInfrequentAccessPolicy ,
352
- } ] : undefined ) ,
358
+ lifecyclePolicies : lifecyclePolicies . length > 0 ? lifecyclePolicies : undefined ,
353
359
performanceMode : props . performanceMode ,
354
360
throughputMode : props . throughputMode ,
355
361
provisionedThroughputInMibps : props . provisionedThroughputPerSecond ?. toMebibytes ( ) ,
Original file line number Diff line number Diff line change @@ -137,10 +137,14 @@ test('file system is created correctly with a life cycle property and out of inf
137
137
} ) ;
138
138
// THEN
139
139
Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::EFS::FileSystem' , {
140
- LifecyclePolicies : [ {
141
- TransitionToIA : 'AFTER_7_DAYS' ,
142
- TransitionToPrimaryStorageClass : 'AFTER_1_ACCESS' ,
143
- } ] ,
140
+ LifecyclePolicies : [
141
+ {
142
+ TransitionToIA : 'AFTER_7_DAYS' ,
143
+ } ,
144
+ {
145
+ TransitionToPrimaryStorageClass : 'AFTER_1_ACCESS' ,
146
+ } ,
147
+ ] ,
144
148
} ) ;
145
149
} ) ;
146
150
You can’t perform that action at this time.
0 commit comments