TF-004 Use the core Terraform workflow Practice Question
A company has a monolithic Terraform configuration that manages all of its AWS infrastructure. They want to break it into smaller, manageable configurations without causing downtime or resource duplication. Which approach best follows the core Terraform workflow?
⚠ Common exam trap
HashiCorp often tests the misconception that you must destroy and recreate resources to reorganize configurations, when in fact Terraform's state manipulation commands allow safe refactoring without impacting live infrastructure.
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
✓
Use `terraform state mv` to move resources from the monolithic state to new state files for the smaller configurations
`terraform state mv` allows you to move resources from the monolithic state file into separate state files for the new, smaller configurations without destroying or recreating resources. This adheres to the core Terraform workflow by preserving the existing infrastructure state, avoiding downtime, and preventing resource duplication. The command updates the state mapping so that Terraform continues to manage the same real-world resources under the new configuration structure.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Create separate configurations from scratch and manually recreate all resources by running `terraform apply`
Why it's wrong here
Creating separate configurations from scratch and applying them would instruct Terraform to provision entirely new resources. Since the original resources still exist and are managed by the monolithic configuration, this action would lead to resource duplication, increased cloud costs, and potential conflicts. Furthermore, attempting to replace existing production resources by deleting the old and applying the new would inevitably cause service downtime and operational disruption.
- ✓
Use `terraform state mv` to move resources from the monolithic state to new state files for the smaller configurations
Why this is correct
The `terraform state mv` command is the correct and safest approach for refactoring a monolithic configuration into smaller, independent ones. It allows specific resource instances to be moved from one Terraform state file to another without modifying or recreating the actual infrastructure resources. This enables an incremental migration strategy, where resources are logically reassigned to new configurations, preserving their existing state and avoiding any service disruption or resource recreation.
- ✗
Import all existing resources into the new configurations before removing the old configuration
Why it's wrong here
Using `terraform import` to add existing resources to new configurations while the monolithic configuration still manages them would result in duplicate entries across different state files. While `import` brings unmanaged resources into a state, it does not remove them from a *previously managed* state. This duplication would lead to confusion, potential conflicts during future `terraform apply` operations, and necessitate manual state cleanup, which is error-prone and risky.
- ✗
Delete the monolithic state and apply all new configurations at once
Why it's wrong here
Deleting the monolithic Terraform state file would effectively sever Terraform's knowledge of the existing infrastructure resources. When the new configurations are subsequently applied, Terraform would perceive all resources defined within them as entirely new and unprovisioned. This would trigger a full recreation of all infrastructure components, leading to significant service downtime, potential data loss, and unnecessary operational overhead.
Go deeper
Related to this question
About these practice questions
Courseiva writes every TF-004 question from scratch — 428 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.