Hi. I’ve followed Jack Tracy’s blog post here and setup an environment that’s been working for weeks but suddenly stopped working with “Backend configuration changed”.
The “Terraform Status Check” works fine with no errors. That runs against a new branch that is not yet merged. The Plan in this pipeline works, so we then proceed to merge into main.
The next pipeline (Plan) is fired CI/CD after the approval to merge. The “terraform init” in that Plan has been failing for the last 3 days & I’m failing to fix it.
I contacted Microsoft Support & after some extensive testing/proving, they are happy that the self hosted Linux agent running the pipelines is running fine.
The error is:
> Error: Backend configuration changed
> A change in the backend configuration has been detected, which may require
> migrating existing state.
The recommended fixes are to run:
- terraform init -reconfigure and
- terraform init -migrate-state
I added a task into the Plan pipeline and initially tried reconfigure. That didn’t work, so tried -migrate-state. That hasn’t seemed to work either.
Someone in this Slack forum had the same issue & posted:
> Fixed it by running terraform init -reconfigure and checking the version in the logs and amend as necessary.
Can someone point me in the right direction please to troubleshoot/fix this issue, and explain how to check version (what’s that referring to please) & in what logs.
Looking in the pipeline logs, I see:
2022-05-14T19:43:44.0534820Z 2022-05-14T19:43:44.053Z [TRACE] Preserving existing state lineage “39281718-16af-f366-8d22-b2f300830a28”
2022-05-14T19:43:44.0542246Z 2022-05-14T19:43:44.053Z [TRACE] Meta.Backend: working directory was previously initialized for “azurerm” backend
2022-05-14T19:43:44.0543987Z 2022-05-14T19:43:44.054Z [TRACE] backendConfigNeedsMigration: configuration values have changed, so migration is required
2022-05-14T19:43:44.0545361Z 2022-05-14T19:43:44.054Z [TRACE] Meta.Backend: backend configuration has changed (from type “azurerm” to type “azurerm”)
Many thanks in anticipation.
(NB: My first post here so please be gentle guys!)