Skip to content

Conversation

@pinzon
Copy link
Member

@pinzon pinzon commented Jul 18, 2025

Motivation

This PR implements the DeleteChangeSet for Cloudformation v2 provider.

Changes

  • Operation implementation

Testing

  • Manual testing with tests.aws.services.cloudformation.api.test_changesets.test_delete_change_set_exception.
  • The logs pertaining to errors while deletion should be gone.

@pinzon pinzon added aws:cloudformation AWS CloudFormation semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases labels Jul 18, 2025
@github-actions
Copy link

github-actions bot commented Jul 18, 2025

Test Results - Preflight, Unit

21 983 tests  +121   20 249 ✅ +44   6m 31s ⏱️ +13s
     1 suites ±  0    1 734 💤 +77 
     1 files   ±  0        0 ❌ ± 0 

Results for commit c5ae9f1. ± Comparison against base commit 9bd5851.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 18, 2025

LocalStack Community integration with Pro

  2 files  ±    0    2 suites  ±0   23m 35s ⏱️ - 1h 18m 53s
896 tests  - 4 033  332 ✅  - 3 819  564 💤  - 214  0 ❌ ±0 
898 runs   - 4 033  332 ✅  - 3 819  566 💤  - 214  0 ❌ ±0 

Results for commit c5ae9f1. ± Comparison against base commit 9bd5851.

This pull request removes 4034 and adds 1 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.api.test_stacks ‑ test_non_existing_stack_message

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 18, 2025

Test Results (amd64) - Acceptance

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

Results for commit c5ae9f1. ± Comparison against base commit 9bd5851.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 18, 2025

Test Results (amd64) - Integration, Bootstrap

  5 files  ±    0    5 suites  ±0   34m 29s ⏱️ - 1h 46m 28s
920 tests  - 4 368  357 ✅  - 4 000  563 💤  - 368  0 ❌ ±0 
926 runs   - 4 368  357 ✅  - 4 000  569 💤  - 368  0 ❌ ±0 

Results for commit c5ae9f1. ± Comparison against base commit 9bd5851.

This pull request removes 4369 and adds 1 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.api.test_stacks ‑ test_non_existing_stack_message

♻️ This comment has been updated with latest results.

@pinzon pinzon marked this pull request as ready for review July 18, 2025 22:29
Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

My only question is around the error message. We should clear up if the message has changed and the snapshots need updating, or if it changes based on the operation

Also can you make sure to update the stack change set ids

)

change_set.stack.change_set_ids.remove(change_set.change_set_id)
state.change_sets.pop(change_set.change_set_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

We also need to remove the change set from stack.change_set_ids I think

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is actually an error and I did not read the code properly

Copy link
Contributor

@simonrw simonrw left a comment

Choose a reason for hiding this comment

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

Pair-reviewed with @pinzon

state = get_cloudformation_store(context.account_id, context.region)

if is_changeset_arn(change_set_name):
change_set = state.change_sets.get(change_set_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to early return if the change set cannot be found

Suggested change
change_set = state.change_sets.get(change_set_name)
change_set = state.change_sets.get(change_set_name)
if change_set is None:
# AWS does not raise an error if it cannot find the change set
return

if is_changeset_arn(change_set_name):
change_set = state.change_sets.get(change_set_name)
elif not is_changeset_arn(change_set_name) and stack_name:
change_set = find_change_set_v2(state, change_set_name, stack_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to early return if the change set cannot be found

Suggested change
change_set = find_change_set_v2(state, change_set_name, stack_name)
change_set = find_change_set_v2(state, change_set_name, stack_name)
if change_set is None:
# AWS does not raise an error if it cannot find the change set
return

Comment on lines 476 to 478
state.stacks_v2.get(change_set.stack.stack_id).change_set_ids.remove(
change_set.change_set_id
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be needed

Suggested change
state.stacks_v2.get(change_set.stack.stack_id).change_set_ids.remove(
change_set.change_set_id
)

)

change_set.stack.change_set_ids.remove(change_set.change_set_id)
state.change_sets.pop(change_set.change_set_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is actually an error and I did not read the code properly

@pinzon pinzon merged commit 82db418 into main Jul 23, 2025
39 checks passed
@pinzon pinzon deleted the cfn/delete-change-set branch July 23, 2025 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws:cloudformation AWS CloudFormation semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants