I wrapped one resource in a module and switched another from count to for_each . Then I ran terraform plan . It wanted to destroy all three resources and create three new ones.
Same files, different addresses. Terraform can't tell they're the same objects.
On a local file that's nothing. On a database it's a bad afternoon. So I kept the plan with and without moved blocks. This was Terraform 1.17.2 with the local provider, local state, no cloud account.
Starting point
One config file at the root, plus two workers made with count :
resource "local_file" "app_config" { filename = "${path.module}/out/app.conf" content = "port=8080\n" }
resource "local_file" "worker" { count = 2 filename = "${path.module}/out/worker-${count.index}.conf" content = "worker=${count.index}\n" }
Enter fullscreen mode
Exit fullscreen mode
terraform apply ended with:
Apply complete!…