TF-004 Implement and maintain state Practice Question
After running terraform apply, you see the error: 'Error: Error loading state: state snapshot was created by Terraform v0.12.0, but this is Terraform v1.2.0'. What should you do to resolve this?
⚠ Common exam trap
HashiCorp often tests the misconception that there is a dedicated `terraform state upgrade` command, leading candidates to choose Option A, but Terraform handles state format upgrades implicitly during apply operations, not via a separate command.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Run terraform apply with no changes to upgrade the state format
Running `terraform apply` with no changes triggers Terraform to automatically upgrade the state file format to the version compatible with the current Terraform binary (v1.2.0). Terraform state files are versioned internally, and when a newer version of Terraform reads an older state format, it performs an in-place upgrade during the next state write operation, such as an apply that results in no changes. This avoids manual intervention or data loss.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Run terraform state upgrade
Why it's wrong here
The `terraform state upgrade` command does not exist within the Terraform CLI. While Terraform does manage state, there is no dedicated subcommand for explicitly upgrading the state file format through a direct `state upgrade` operation. Attempting to execute this command would result in an "unknown command" error, indicating it's not a valid method for addressing state format discrepancies.
- ✓
Run terraform apply with no changes to upgrade the state format
Why this is correct
When an older Terraform state file is detected by a newer version of the Terraform CLI, running `terraform apply` will automatically initiate an upgrade of the state format to the current version. Even if there are no configuration changes to apply, Terraform processes the existing state and writes it back in the updated format, resolving compatibility issues. This is the standard and recommended procedure for state file upgrades.
- ✗
Delete the state file and reimport resources
Why it's wrong here
Deleting the `terraform.tfstate` file and then attempting to reimport all resources is an extremely destructive and unnecessary approach. This action would sever Terraform's knowledge of all managed infrastructure, potentially leading to resource duplication, data loss, or unintended modifications during re-import. It's a last resort for unrecoverable state corruption, not a standard procedure for simple state format upgrades.
- ✗
Downgrade Terraform to v0.12.0
Why it's wrong here
Downgrading the Terraform CLI to an older version, such as v0.12.0, is generally not a recommended practice and introduces significant risks. Newer configurations and provider versions often rely on features or syntax introduced in later Terraform versions, making downgrading likely to cause parsing errors, provider incompatibility, or unexpected behavior. This approach attempts to match the tool to the old state rather than upgrading the state to the current tool.
Visual reference
Go deeper
Related to this question
About these practice questions
One of 428 original TF-004 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This TF-004 practice question is part of Courseiva's free HashiCorp certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the TF-004 exam.