Skip to content

(aws-efs): EFS FileSystem construction always fails when passing both lifecyclePolicy and outOfInfrequentAccessPolicy #19058

@5t111111

Description

@5t111111

What is the problem?

When deploying an example in the official CDK document, EFS creation always fails with the following error:

One or more LifecyclePolicy objects specified are malformed.

After some investigation, I have found that setting both lifecyclePolicy and outOfInfrequentAccessPolicy is the cause of the problem. When you pass only one of them to a construct, it successfully deployed to AWS.

I assume that means CloudFormation template does not allow multiple entries in one LifecyclePolicies item. So, I have not confirmed though, the following changes to emitted CloudFormation template may work.

Bad

"LifecyclePolicies": [
  {
    "TransitionToIA": "AFTER_14_DAYS",
    "TransitionToPrimaryStorageClass": "AFTER_1_ACCESS"
  }
],

Good

"LifecyclePolicies": [
  {
    "TransitionToIA": "AFTER_14_DAYS"
  },
  {
    "TransitionToPrimaryStorageClass": "AFTER_1_ACCESS"
  }
],

Reproduction Steps

Running the example code in the official document

CDK stack source code:

const fileSystem = new efs.FileSystem(this, 'MyEfsFileSystem', {
  vpc: new ec2.Vpc(this, 'VPC'),
  lifecyclePolicy: efs.LifecyclePolicy.AFTER_14_DAYS, // files are not transitioned to infrequent access (IA) storage by default
  performanceMode: efs.PerformanceMode.GENERAL_PURPOSE, // default
  outOfInfrequentAccessPolicy: efs.OutOfInfrequentAccessPolicy.AFTER_1_ACCESS, // files are not transitioned back from (infrequent access) IA to primary storage by default
});

CloudFormation template emitted:

// -- snip --
    "MyEfsFileSystem570A3D32": {
      "Type": "AWS::EFS::FileSystem",
      "Properties": {
        "Encrypted": true,
        "FileSystemTags": [
          {
            "Key": "Name",
            "Value": "CdkTestStack/MyEfsFileSystem"
          }
        ],
        "LifecyclePolicies": [
          {
            "TransitionToIA": "AFTER_14_DAYS",
            "TransitionToPrimaryStorageClass": "AFTER_1_ACCESS"
          }
        ],
        "PerformanceMode": "generalPurpose"
      },
      "UpdateReplacePolicy": "Delete",
      "DeletionPolicy": "Delete",
      "Metadata": {
        "aws:cdk:path": "CdkTestStack/MyEfsFileSystem/Resource"
      }
    },
// -- snip --

What did you expect to happen?

You can successfully deploy EFS even when you set both lifecyclePolicy and outOfInfrequentAccessPolicy.

What actually happened?

Deployment fails with the error message:

One or more LifecyclePolicy objects specified are malformed.

CDK CLI Version

2.13.0 (build b0b744d)

Framework Version

No response

Node.js Version

v16.13.2

OS

macOS 12.2.1

Language

Typescript

Language Version

4.5.5

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-efsRelated to Amazon Elastic File SystembugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.p1

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions