Valid Methods to Import Existing Infrastructure into Terraform
Which TWO of the following are valid ways to import existing infrastructure into Terraform management? (Choose TWO.)
Quick Answer
The correct answers are using the `terraform import` command and manually writing configuration then running `terraform plan` to refresh state and adjust. The `terraform import` command is the dedicated, explicit method to bring existing infrastructure under Terraform management by binding a real-world resource ID to a resource address in your state file, making it the primary tool for this task. Alternatively, you can manually author configuration that mirrors the existing resource and then execute `terraform plan`; this forces Terraform to refresh its state against the live infrastructure, and you iteratively adjust your config until the plan shows zero changes, effectively importing by convergence. On the HashiCorp Terraform Associate TF-003 exam, this question tests your understanding of the two valid workflows for importing existing infrastructure, often trapping candidates who think only `terraform import` works or who confuse `terraform refresh` as a standalone import method. A key memory tip: think of import as either “explicit bind” with `terraform import` or “convergent match” with manual config plus plan.
⚠ Common exam trap
HashiCorp often tests the misconception that 'terraform validate' or 'terraform apply' can import resources, when in fact only 'terraform import' (or manual configuration with plan refresh) accomplishes this, and candidates confuse validation or apply with the import workflow.
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 the 'terraform import' command with the resource address and ID.
'terraform import' is the dedicated command to bring existing infrastructure under Terraform management by associating a real-world resource ID with a resource address in state. Option D is correct because you can manually write configuration that matches the existing resource, then run 'terraform plan' to refresh state and detect any drift, allowing you to adjust the configuration until the plan shows no changes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use 'terraform validate' to automatically import resources.
Why it's wrong here
Validate checks configuration syntax; it does not import.
- ✗
Use 'terraform state rm' to remove resources from state, then re-add them.
Why it's wrong here
This removes resources, it does not import.
- ✓
Use the 'terraform import' command with the resource address and ID.
Why this is correct
This is the primary method for importing existing resources.
- ✓
Write the configuration manually and run 'terraform plan' to refresh state, then adjust.
Why this is correct
This is a valid workflow for importing resources that are already in state.
- ✗
Run 'terraform apply' with an empty configuration to detect resources.
Why it's wrong here
This will not detect resources; it will create nothing.
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 →
Same concept, more angles
2 more ways this is tested on TF-004
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which TWO of the following are valid methods for importing existing infrastructure into Terraform management? (Choose two.)
easy- A.Use terraform apply directly on existing resources
- ✓ B.Use a third-party tool like Terraformer to generate configuration
- C.Use terraform state push to manually add state entries
- ✓ D.Write configuration for the resource and use terraform import
- E.Use terraform import without any prior configuration
Why B: The typical method is to write configuration and run terraform import. Third-party tools can generate configuration from existing resources. terraform import requires configuration beforehand. terraform state push is not for importing; it pushes a state file. terraform apply would try to create new resources.
Variation 2. Which TWO are valid methods to import existing infrastructure into Terraform?
medium- A.Use 'terraform state rm' to remove existing state before running apply.
- ✓ B.Run 'terraform import' with the resource address and ID.
- C.Use 'terraform console' to inspect and import.
- ✓ D.Add resource blocks manually and run 'terraform import' for each resource.
- E.Use 'terraform init -migrate-state' to import from another backend.
Why B: `terraform import` is the primary command for bringing existing infrastructure under Terraform management. It requires both the resource address (as defined in your configuration) and the provider-specific ID of the real-world object. This command maps the existing resource into the Terraform state, enabling subsequent `apply` operations to manage it.
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.