Terraform Anti-Patterns Overview
Terraform Anti-Patterns Overview
Terraform, despite its powerful infrastructure as code capabilities, has several common anti-patterns that can lead to maintainability issues, security risks, and operational problems. Here are the most important anti-patterns to avoid when writing Terraform code.
Hardcoding Sensitive Values
Hardcoding Sensitive Values
Not Using Modules
Not Using Modules
Not Using Remote State
Not Using Remote State
Not Using State Locking
Not Using State Locking
Not Using Workspaces for Environment Separation
Not Using Workspaces for Environment Separation
Not Using Data Sources for External Resources
Not Using Data Sources for External Resources
Not Using Count or For_each for Resource Collections
Not Using Count or For_each for Resource Collections
count
or for_each
to create multiple instances of a resource dynamically.Not Using Version Constraints
Not Using Version Constraints
Not Using Resource Targeting Carefully
Not Using Resource Targeting Carefully
Not Using Output Values
Not Using Output Values
Not Using Terraform Fmt
Not Using Terraform Fmt
terraform fmt
to automatically format your code according to the standard style.Not Using Terraform Validate
Not Using Terraform Validate
terraform validate
to check for syntax errors and other issues before running terraform plan
or terraform apply
.Not Using Proper Resource Naming
Not Using Proper Resource Naming
Not Using Proper Error Handling
Not Using Proper Error Handling
count
or for_each
to handle potential errors.