Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

CloudFormation: Support intrinsic functions in DeletionPolicy and UpdateReplacePolicy#13679

Closed
nik-localstack wants to merge 1 commit into
mainfrom
cloudformation/support-intrinsic-fn-deletion-update-replace-policy
Closed

CloudFormation: Support intrinsic functions in DeletionPolicy and UpdateReplacePolicy#13679
nik-localstack wants to merge 1 commit into
mainfrom
cloudformation/support-intrinsic-fn-deletion-update-replace-policy

Conversation

@nik-localstack
Copy link
Copy Markdown
Contributor

Motivation

As reported in #13549, CloudFormation templates using intrinsic functions (such as Fn::If, Fn::FindInMap, or Ref) in DeletionPolicy and UpdateReplacePolicy attributes were failing with a RuntimeError during stack creation. This prevented users from implementing environment-specific or parameter-driven resource lifecycle policies, which works correctly in AWS CloudFormation.

Changes

  • Modified _visit_deletion_policy() and _visit_update_replace_policy() methods in change_set_model.py to accept ChangeSetEntity instead of TerminalValue, allowing intrinsic functions

Tests

Added validated tests to capture the previously failing scenarios.

Related

Closes #13549

@nik-localstack nik-localstack added aws:cloudformation AWS CloudFormation semver: patch Non-breaking changes which can be included in patch releases aws:cloudformation:v2 Issues related to the V2 CloudFormation engine docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Feb 2, 2026
@nik-localstack nik-localstack self-assigned this Feb 2, 2026
@nik-localstack nik-localstack added this to the 4.14 milestone Feb 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

Test Results - Preflight, Unit

23 088 tests  ±0   21 229 ✅ ±0   6m 32s ⏱️ -2s
     1 suites ±0    1 859 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit fb4e0c4. ± Comparison against base commit a8c43f2.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 5s ⏱️ +9s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit fb4e0c4. ± Comparison against base commit a8c43f2.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

LocalStack Community integration with Pro

  2 files  ±    0    2 suites  ±0   31m 29s ⏱️ - 1h 27m 5s
587 tests  - 4 591  474 ✅  - 4 316  113 💤  - 275  0 ❌ ±0 
589 runs   - 4 591  474 ✅  - 4 316  115 💤  - 275  0 ❌ ±0 

Results for commit fb4e0c4. ± Comparison against base commit a8c43f2.

This pull request removes 4595 and adds 4 tests. Note that renamed tests count towards both.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…
tests.aws.services.cloudformation.engine.test_conditions.TestCloudFormationConditions ‑ test_deletion_policy_with_conditional[dev-Delete]
tests.aws.services.cloudformation.engine.test_conditions.TestCloudFormationConditions ‑ test_deletion_policy_with_conditional[prod-Retain]
tests.aws.services.cloudformation.engine.test_conditions.TestCloudFormationConditions ‑ test_deletion_policy_with_fn_find_in_map
tests.aws.services.cloudformation.engine.test_conditions.TestCloudFormationConditions ‑ test_deletion_policy_with_ref_parameter

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

Test Results (amd64) - Integration, Bootstrap

  5 files    5 suites   43m 43s ⏱️
611 tests 499 ✅ 112 💤 0 ❌
617 runs  499 ✅ 118 💤 0 ❌

Results for commit fb4e0c4.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 2, 2026

Test Results - Alternative Providers

586 tests   326 ✅  18m 17s ⏱️
  1 suites  260 💤
  1 files      0 ❌

Results for commit fb4e0c4.

@nik-localstack nik-localstack marked this pull request as ready for review February 2, 2026 16:18
Copy link
Copy Markdown
Member

@pinzon pinzon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these changes. Be aware that a couple of lines will conflict with this pr(#13535) from @simonrw .

🔴 And since the tests are mainly about DeletionPolicy and UpdatePolicy we should move the tests to the new test files for them. So my recommendation would be to wait until Simon's PR is merged.

@nik-localstack
Copy link
Copy Markdown
Contributor Author

Thanks @pinzon
I'm closing this PR in favor of #13535 that would solve the same issue

@nik-localstack nik-localstack deleted the cloudformation/support-intrinsic-fn-deletion-update-replace-policy branch February 3, 2026 07:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

aws:cloudformation:v2 Issues related to the V2 CloudFormation engine aws:cloudformation AWS CloudFormation docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: patch Non-breaking changes which can be included in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: The DeletionPolicy and UpdateReplacePolicy of RDS:DBInstance not works in Localstack Cloudformation

2 participants