More Info:

Your AWS CloudFormation stacks should be using policies as a fail-safe mechanism in order to prevent accidental updates to stack resources.

Risk Level

Low

Address

Security

Compliance Standards

CBP

Triage and Remediation

Remediation

To remediate the misconfiguration “CloudFormation Stack Policy Should Use A Fail-Safe Mechanism” in AWS using the AWS console, you can follow the below steps:

  1. Login to the AWS Management Console.
  2. Go to the CloudFormation service.
  3. Click on the Stack for which you want to remediate the misconfiguration.
  4. Click on the “Permissions” tab.
  5. Scroll down to the “Stack Policy” section.
  6. Click on the “Edit” button.
  7. Add the following statement to the policy:
{
    "Effect": "Deny",
    "Action": "Update:Delete",
    "Principal": "*",
    "Resource": "*",
    "Condition": {
        "Null": {
            "aws:ResourceTag/aws:cloudformation:stack-name": "true"
        }
    }
}

This statement will deny any update that deletes a resource in the stack, unless the resource has a tag with the key “aws:cloudformation:stack-name” set to a non-null value.

  1. Click on the “Save” button to save the updated Stack Policy.

By adding this statement to the Stack Policy, you have implemented a fail-safe mechanism that prevents accidental deletion of resources in the stack.

Additional Reading: