forge-docs

0021. Environment-aware removal policies for CDK-managed resources

Status: Accepted Date: 2026-03-27 Context: CDK RemovalPolicy must balance destroy vs retain by environment and resource type without orphans or data loss.

Context

AWS CDK resources support a RemovalPolicy that determines whether resources are deleted or retained when a stack is destroyed or a resource is replaced.

A blanket policy (e.g. RETAIN for all production resources) can lead to:

Conversely, using DESTROY universally risks irreversible data loss for stateful resources.

Decision

Adopt an environment-sensitive and resource-type-aware removal policy strategy:

1. Environment Rules

2. Resource Classification

Stateful (RETAIN in production):

Stateless (DESTROY in production):

3. Additional Safeguards

Consequences

Positive

Negative

Notes

Retention is a data protection mechanism, not a substitute for:

Stack deletion in production should be considered an exceptional operation.