Description
Identify the logical IDs that must be protected from modification, replacement or removal during a CloudFormation update.
Potential impact
An unexpected replacement can interrupt service or destroy data.
Remediation
Set policy_body or policy_url to a stack policy that allows required updates and restricts the actions you need to block. Enable termination protection separately if the stack itself must be protected from deletion.
Examples
In the second example, var.stack_policy_url points to the policy. Deployment also needs a stack template that defines VPCCidr.
Before
hcl
resource "aws_cloudformation_stack" "example" {
name = "networking-stack"
parameters = {
VPCCidr = "10.0.0.0/16"
}
}
After
hcl
resource "aws_cloudformation_stack" "example" {
name = "networking-stack"
parameters = {
VPCCidr = "10.0.0.0/16"
}
policy_url = var.stack_policy_url
}