Question 1 · choose 1
A team copies a configuration as the starting point for a new project. Its backend block still points at the old project's state, so the engineer edits the bucket name. terraform init now asks whether to copy the old state to the new location, which the engineer does not want. Which option starts with the new backend and leaves the old state alone?
- Aterraform init -migrate-state
- Bterraform init -reconfigure
- Cterraform init -force-copy
- Dterraform init -get=false
Show the answer and why
Aterraform init -migrate-state
Incorrect
-migrate-state copies the existing state to the new backend, the opposite of what is wanted.
Bterraform init -reconfigure
Correct
-reconfigure disregards the existing backend configuration and prevents migration of any existing state.
Cterraform init -force-copy
Incorrect
-force-copy answers yes to the migration prompts and implies -migrate-state.
Dterraform init -get=false
Incorrect
That skips child module installation and does not answer the migration question.
After a backend change, init needs either -migrate-state (bring the state along) or -reconfigure (start clean with the new settings).
HashiCorp documentation