Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5t111111 opened this issue Feb 20, 2022 · 1 comment · Fixed by #19082
Assignees
Labels
@aws-cdk/aws-efs Related to Amazon Elastic File System bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1

Comments

@5t111111
Copy link

5t111111 commented Feb 20, 2022

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

@5t111111 5t111111 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 20, 2022
@github-actions github-actions bot added the @aws-cdk/aws-efs Related to Amazon Elastic File System label Feb 20, 2022
@ryparker ryparker added the p1 label Feb 21, 2022
@mergify mergify bot closed this as completed in #19082 Mar 1, 2022
mergify bot pushed a commit that referenced this issue Mar 1, 2022
…ntAccessPolicy (#19082)

Closes #19058

Most likely this was an oversight in CloudFormation docs. Submitted a PR for CF docs here: awsdocs/aws-cloudformation-user-guide#1165

Here are the API docs showing the proper parameters for LifecyclePolicies: https://docs.aws.amazon.com/efs/latest/ug/API_PutLifecycleConfiguration.html

<img width="418" alt="image" src="https://user-images.githubusercontent.com/31543/155045177-308d0608-bc11-4150-8d5f-b7da7f8f5b01.png">
<img width="1226" alt="Screen Shot 2022-02-21 at 5 14 50 PM" src="https://user-images.githubusercontent.com/31543/155045111-31e9d9b5-99b1-404f-bee7-61dd3e2751f2.png">
<img width="679" alt="Screen Shot 2022-02-21 at 5 14 57 PM" src="https://user-images.githubusercontent.com/31543/155045114-a56c68f7-60f4-4a6c-946a-1231cdf84448.png">

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Mar 1, 2022

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

TheRealAmazonKendra pushed a commit to TheRealAmazonKendra/aws-cdk that referenced this issue Mar 11, 2022
…ntAccessPolicy (aws#19082)

Closes aws#19058

Most likely this was an oversight in CloudFormation docs. Submitted a PR for CF docs here: awsdocs/aws-cloudformation-user-guide#1165

Here are the API docs showing the proper parameters for LifecyclePolicies: https://docs.aws.amazon.com/efs/latest/ug/API_PutLifecycleConfiguration.html

<img width="418" alt="image" src="https://user-images.githubusercontent.com/31543/155045177-308d0608-bc11-4150-8d5f-b7da7f8f5b01.png">
<img width="1226" alt="Screen Shot 2022-02-21 at 5 14 50 PM" src="https://user-images.githubusercontent.com/31543/155045111-31e9d9b5-99b1-404f-bee7-61dd3e2751f2.png">
<img width="679" alt="Screen Shot 2022-02-21 at 5 14 57 PM" src="https://user-images.githubusercontent.com/31543/155045114-a56c68f7-60f4-4a6c-946a-1231cdf84448.png">

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-efs Related to Amazon Elastic File System bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants