Table of Contents
The Error
Plan: 0 to add, X to change, 0 to destroy (every run)
What Causes This
Terraform detects differences every plan because the cloud provider modifies values after creation (normalization).
How to Fix It
Solution 1: Use ignore_changes
lifecycle {
ignore_changes = [ami, tags["Updated"], user_data]
}
Solution 2: Use jsonencode for Policies
# Consistent JSON formatting prevents diffs
policy = jsonencode({ Version = "2012-10-17", Statement = [...] })
Solution 3: Explicitly Set Defaults
resource "aws_security_group" "web" {
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
Prevention Tips
- Pin provider versions — avoid surprise breaking changes
- Use CI/CD — catch errors before they hit production
- Test with
terraform plan— always review before applying - Keep Terraform updated — newer versions have better error messages
- Use
terraform validate— catches syntax errors early
Hands-On Courses
- Terraform for Beginners on CopyPasteLearn
- Terraform By Example — practical code examples
- Terraform Cheat Sheet — quick reference for all commands
Related Articles
- Terraform Troubleshooting - Common Errors and Solutions
- Terraform Enabling and Using Debugging
- Debugging with TFLint
Conclusion
This error is common and fixable. Follow the solutions above, and check our Terraform course for hands-on training that covers real-world troubleshooting scenarios.

