Sign in
Menu
Sign up
Docs
Operational rules

Workarounds

A lifecycle block cannot take a variable, and that single Terraform and OpenTofu restriction is behind most recurring "why can't this module just…" requests: prevent_destroy on a data bucket, ignore_changes on tags an external controller writes, create_before_destroy on a security group that is still attached. These pages are for engineers who hit one of them in a terraform-aws-modules module. Each states the cause, links the upstream issues, gives the native workaround in full, and names the Operational Rule that answers it, or says there is none yet.

Modules

Each problem links the Playground with only its rule selected; the last column opens the module with every rule this page answers.

ModuleProblems and the rule that answers eachPlayground
Auto ScalingAuto Scaling group desired_capacity reverts on every apply - lifecycle_ignore_scaling_changesOpen with all rules
DynamoDB tableDynamoDB read and write capacity reverts on every plan - lifecycle_ignore_autoscaling_changes

terraform destroy deleted a DynamoDB table - lifecycle_prevent_destroy_data
Open with all rules
EC2 instanceTerraform wants to replace my EC2 instance because the AMI changed - lifecycle_ignore_ami_changesOpen with all rules
ECSTerraform reverts the task definition my pipeline just deployed - lifecycle_ignore_deployed_artifactsOpen with all rules
EKSChanging desired_size on an EKS node group does nothing, and raising min_size fails - eks_node_group_set_desired_sizeOpen with all rules
IAMTerraform keeps reverting tags on IAM roles - lifecycle_ignore_tagsOpen with all rules
KMSterraform destroy scheduled deletion of a KMS key - lifecycle_prevent_destroy_encryptionOpen with all rules
LambdaTerraform keeps reverting my Lambda code to an old version - lifecycle_ignore_deployed_artifactsOpen with all rules
RDSterraform destroy deleted a production database - lifecycle_prevent_destroy_data

Terraform wants to reset the database password on every plan - lifecycle_ignore_secret_rotation
Open with all rules
RDS Auroraterraform destroy deleted an Aurora cluster - lifecycle_prevent_destroy_dataOpen with all rules
S3 bucketterraform destroy deleted a production S3 bucket - lifecycle_prevent_destroy_data

Terraform keeps reverting tags on my S3 buckets - lifecycle_ignore_tags
Open with all rules
Secrets Managerterraform destroy deleted a secret other systems depend on - lifecycle_prevent_destroy_encryptionOpen with all rules
VPCTerraform keeps removing the tags that Kubernetes and load balancer controllers add - lifecycle_ignore_tagsOpen with all rules

How to read a page

  1. The symptom, written the way it gets searched for.
  2. Why Terraform cannot fix it, with the upstream issues so you can check.
  3. The native workaround in full, including when it is a fork.
  4. The rule, where one exists, with the HCL diff it produces - or an explicit "native option only, today" where it does not.

On a framework host you name the rules you want in ?add_rules=, on top of whatever Baseline your organization has Enforced; on an organization host that organization's configuration decides.

On this page

Ask AI about this

Help improve this page