Skip to main content

Lifecycle & Version Management

Destroy Protection

Use prevent_destroy on stateful resources to guard against accidental deletion:

resource "aws_rds_cluster" "main" {
# ...

lifecycle {
prevent_destroy = true
}
}

Use ignore_changes sparingly and only for attributes managed outside Terraform (e.g. auto-scaling desired counts):

lifecycle {
ignore_changes = [desired_count]
}

Terraform Version Management

Use tfenv or mise to pin the Terraform version per repository. Commit a .terraform-version or mise.toml file so all developers and CI use the same binary.