Description
When community.aws.cloudformation_stack_set removes a StackSet with state: absent, it also deletes the associated stacks by default. Set purge_stacks: false to keep those stacks outside the StackSet.
Potential impact
Deleting stacks can interrupt services across accounts and Regions. Which resources survive depends on their CloudFormation deletion policies. Restoring lost data requires a backup.
Remediation
Before deletion, check the accounts, Regions and dependencies of the stacks. If the stacks must remain, explicitly set purge_stacks: false. If they can be deleted, confirm the intended scope, resource deletion policies and backups.
Examples
Both tasks delete the StackSet itself. Replace my-stack with its name and verify the execution account and Region.
Before
- name: Remove a StackSet and its stacks
community.aws.cloudformation_stack_set:
name: my-stack
state: absent
purge_stacks: true
After
- name: Remove a StackSet while retaining its stacks
community.aws.cloudformation_stack_set:
name: my-stack
state: absent
purge_stacks: false
After retaining stacks, verify their state and assign responsibility for operations, costs and eventual cleanup.