What are common Terraform anti-patterns and pitfalls?

Answer

Common Terraform anti-patterns to avoid: Storing secrets in state unencrypted: always encrypt remote backend and restrict access. Monolithic state file: one state for entire company infrastructure — blast radius is enormous; split by layer and team. No state locking: allows concurrent apply corruption. Manual changes to Terraform-managed resources: causes drift and confusion. count for non-homogeneous resources: causes destructive index shifts; use for_each. Hard-coded values: credentials, region, account IDs in .tf files; use variables and environment-specific configs. Missing version constraints: provider and module versions unpinned; next init may break everything. Committed terraform.tfvars with secrets: sensitive values in Git history. No destroy protection: databases without prevent_destroy. Using provisioners for everything: breaks idempotency. Missing tagging strategy: impossible to track cost and ownership without consistent tags. No testing: applying to prod without validate, tflint, checkov, or plan review.