Skip to content

cfn-parse.ts: parseDeletionPolicy is missing CreateExceptOnDelete #26863

@njsouthwood

Description

@njsouthwood

Describe the bug

CFN recently added support for a new deletion policy called RetainExceptOnCreate. This policy was added to the removal-policy enum in e0d5ca, however it is missing from the switch/case block in parseDeletionPolicy, which causes errors when this removal policy is used.

EDIT: It looks like this code may only be executed when using CfnInclude to create a stack from an existing CloudFormation template. Updating the rest of this issue to be more clear about that.

Expected Behavior

You should be able to use CfnInclude to import an existing cloudformation template with valid usage of DeletionPolicy: RetainExceptOnCreate without any errors

Current Behavior

If you define a stack resource with DeletionPolicy: RetainExceptOnCreate, then use CfnInclude to import that stack you'll get this error:

Error: Unrecognized DeletionPolicy 'RetainExceptOnCreate'

Reproduction Steps

  • Create Cloudformation template with a stack resource with DeletionPolicy: RetainExceptOnCreate
  • Import that template as a cdk stack using CfnInclude

Possible Solution

  • Add a case for RetainExceptOnCreate
  • It looks like cfn-parse uses this same parsing function for both deletionPolicy and updateReplacePolicy. It looks like the new RetainExceptOnCreate policy is not a valid updateReplacePolicy. There will need to be two separate parsing functions.

Additional Information/Context

No response

CDK CLI Version

2.91.0

Framework Version

No response

Node.js Version

v14.21.3

OS

AL2

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/cloudformation-includeIssues related to the "CFN include v.20" package@aws-cdk/coreRelated to core CDK functionalitybugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions