Description
retain_stacks controls whether the underlying stack is retained when its instance is removed from a stack group. With the default false value, removal can also delete the stack and its resources.
Potential impact
- Deleting resources that should remain can interrupt services or lose data.
- Redeploying the stack and restoring data can require additional work.
Remediation
Set retain_stacks = true when the underlying stack must remain after stack-instance removal. Assign ownership of the retained stack, manage its costs and protect important data with separate backups.
Examples
These excerpts compare retention during stack-instance removal. Supply the actual target account ID, region and stack group for the environment.
Before
resource "alicloud_ros_stack_instance" "example" {
stack_group_name = alicloud_ros_stack_group.example.stack_group_name
stack_instance_account_id = var.account_id
stack_instance_region_id = data.alicloud_ros_regions.example.regions.0.region_id
retain_stacks = false
}
After
resource "alicloud_ros_stack_instance" "example" {
stack_group_name = alicloud_ros_stack_group.example.stack_group_name
stack_instance_account_id = var.account_id
stack_instance_region_id = data.alicloud_ros_regions.example.regions.0.region_id
retain_stacks = true
}
true leaves the underlying stack when its instance is removed from the stack group. This setting does not replace general deletion protection or data backups.