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

parseDeletionPolicy(module name): Reference based deletion policy #28292

Closed
stuburg opened this issue Dec 7, 2023 · 4 comments · Fixed by #28834
Closed

parseDeletionPolicy(module name): Reference based deletion policy #28292

stuburg opened this issue Dec 7, 2023 · 4 comments · Fixed by #28834
Assignees
Labels
@aws-cdk/aws-iam Related to AWS Identity and Access Management bug This issue is a bug. effort/small Small work item – less than a day of effort p1

Comments

@stuburg
Copy link

stuburg commented Dec 7, 2023

Describe the bug

There is no ability to use reference based deletion policies in the code.

Expected Behavior

The code should be able to use the reference to the deletion policy.

Current Behavior

Error: Unrecognized DeletionPolicy '[object Object]' is what is output

Reproduction Steps

'DeletionPolicy':
'Default': 'RetainExceptOnCreate'
'Description': 'Default DeletionPolicy. This parameter sources from AWSWaypointPipelineDeployableCfn.'
'Type': 'String'

'DeletionPolicy':
  'Ref': 'DeletionPolicy'

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.114.1

Framework Version

No response

Node.js Version

v21.3.0

OS

Ventura 13.5.1

Language

TypeScript

Language Version

TS 5.0.4

Other information

No response

@stuburg stuburg added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Dec 7, 2023
@github-actions github-actions bot added the @aws-cdk/aws-iam Related to AWS Identity and Access Management label Dec 7, 2023
@tim-finnigan tim-finnigan self-assigned this Dec 11, 2023
@tim-finnigan
Copy link

Hi @stuburg thanks for reaching out. Can you provide the full steps to reproduce? There was another issue (#26863) a few months ago involving parseDeletionPolicy, but that was fixed in 2.9.4.

@tim-finnigan tim-finnigan added p2 response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Dec 11, 2023
@stuburg
Copy link
Author

stuburg commented Dec 12, 2023

Yea, we are using lpt-to-cdk in a Typescript CDK project. We have the template.yml defined like this in the build:
"DeletionPolicy": "Default": "RetainExceptOnCreate" "Description": "Default DeletionPolicy." "Type": "String"

and we have resources defined in the template.yml defined like this:

"SampleResource": "DeletionPolicy": "Ref": "DeletionPolicy"

upon build, that error is generated given that a reference value is passed and not a string.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Dec 12, 2023
@mrog
Copy link
Member

mrog commented Dec 13, 2023

I'm seeing the same error when I use an intrinsic function to provide a deletion policy, like this:

Resources:
  MyHostedZone:
    Type: "AWS::Route53::HostedZone"
    Properties:
      Name: "MyZoneName" 
    DeletionPolicy:
      !If
        - DeleteZoneOnCleanup
        - 'Delete'
        - 'Retain'

This is valid according to the docs, but the CDK library can't parse it. The parsing code only understands null, undefined, or a string.

@tim-finnigan tim-finnigan removed their assignment Dec 22, 2023
@tim-finnigan tim-finnigan added p1 effort/small Small work item – less than a day of effort and removed p2 labels Dec 22, 2023
@ConnorRobertson ConnorRobertson self-assigned this Jan 18, 2024
@mergify mergify bot closed this as completed in #28834 Jan 24, 2024
Copy link

⚠️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.

mergify bot pushed a commit that referenced this issue Jan 24, 2024
> # Issue
> > When using `CfnInclude` it was not possible to have an intrinsic function in the `DeletionPolicy`. It only allowed the DeletionPolicy to be explicitly defined. 
> # Solution
> > Check if policy looks like an intrinsic. Check if it is an explicitly defined DeletionPolicy. Then Default to a case that checks if this is an intrinsic if it is return the policy after using parseValue. Else throw the same error it was previously.
> # Important Design Decisions
> > Unsure if any have been made please let me know if there are any I didn't think were Important Design Decisions. 
>
> Remember to follow the [CONTRIBUTING GUIDE] and [DESIGN GUIDELINES] for any
> code you submit.
>
> [CONTRIBUTING GUIDE]: https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md
> [DESIGN GUIDELINES]: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md

Closes #28292 .

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
penniman26 pushed a commit to penniman26/aws-cdk that referenced this issue Jan 25, 2024
> # Issue
> > When using `CfnInclude` it was not possible to have an intrinsic function in the `DeletionPolicy`. It only allowed the DeletionPolicy to be explicitly defined. 
> # Solution
> > Check if policy looks like an intrinsic. Check if it is an explicitly defined DeletionPolicy. Then Default to a case that checks if this is an intrinsic if it is return the policy after using parseValue. Else throw the same error it was previously.
> # Important Design Decisions
> > Unsure if any have been made please let me know if there are any I didn't think were Important Design Decisions. 
>
> Remember to follow the [CONTRIBUTING GUIDE] and [DESIGN GUIDELINES] for any
> code you submit.
>
> [CONTRIBUTING GUIDE]: https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md
> [DESIGN GUIDELINES]: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md

Closes aws#28292 .

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Vandita2020 pushed a commit to Vandita2020/aws-cdk that referenced this issue Jan 30, 2024
> # Issue
> > When using `CfnInclude` it was not possible to have an intrinsic function in the `DeletionPolicy`. It only allowed the DeletionPolicy to be explicitly defined. 
> # Solution
> > Check if policy looks like an intrinsic. Check if it is an explicitly defined DeletionPolicy. Then Default to a case that checks if this is an intrinsic if it is return the policy after using parseValue. Else throw the same error it was previously.
> # Important Design Decisions
> > Unsure if any have been made please let me know if there are any I didn't think were Important Design Decisions. 
>
> Remember to follow the [CONTRIBUTING GUIDE] and [DESIGN GUIDELINES] for any
> code you submit.
>
> [CONTRIBUTING GUIDE]: https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md
> [DESIGN GUIDELINES]: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md

Closes aws#28292 .

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
SankyRed pushed a commit that referenced this issue Feb 8, 2024
> # Issue
> > When using `CfnInclude` it was not possible to have an intrinsic function in the `DeletionPolicy`. It only allowed the DeletionPolicy to be explicitly defined. 
> # Solution
> > Check if policy looks like an intrinsic. Check if it is an explicitly defined DeletionPolicy. Then Default to a case that checks if this is an intrinsic if it is return the policy after using parseValue. Else throw the same error it was previously.
> # Important Design Decisions
> > Unsure if any have been made please let me know if there are any I didn't think were Important Design Decisions. 
>
> Remember to follow the [CONTRIBUTING GUIDE] and [DESIGN GUIDELINES] for any
> code you submit.
>
> [CONTRIBUTING GUIDE]: https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md
> [DESIGN GUIDELINES]: https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md

Closes #28292 .

----

*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-iam Related to AWS Identity and Access Management bug This issue is a bug. effort/small Small work item – less than a day of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants