How do you diagnose a perpetual diff?
AdvancedProductionRefactoring, Migration and Drift
Answer
Run terraform plan twice and read the diff closely. Common causes: JSON documents with different key ordering or whitespace (use jsonencode), lists vs sets with order differences, provider-normalised values (lowercased names, trailing dots in DNS, full ARNs), tags added by AWS or other tools and computed defaults. Use TF_LOG=DEBUG to see what the API returns, compare terraform state show against config and fix the config to the canonical form.
More on Refactoring, Migration and Drift
What is your workflow for refactoring Terraform safely?IntermediateHow do you rename a resource inside a shared module without breaking consumers?AdvancedHow do you split one state into two without downtime?AdvancedHow do you merge two states?IntermediateHow do you import a large existing environment efficiently?IntermediateHow do you upgrade a major version of the AWS provider?Advanced