HashiCorpHashiCorp
TA-002-P · Question #74
TA-002-P Question #74: Real Exam Question with Answer & Explanation
The correct answer is B: As a part of terraform plan. While terraform import is a standalone command, newer Terraform versions (1.5+) allow import operations to be defined in import blocks within HCL, which are then processed and previewed as part of the terraform plan lifecycle.
Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)
Question
How is terraform import run?
Options
- AAs a part of terraform init
- BAs a part of terraform plan
- CAs a part of terraform refresh
- DBy an explicit call
- EAll of the above
Explanation
While terraform import is a standalone command, newer Terraform versions (1.5+) allow import operations to be defined in import blocks within HCL, which are then processed and previewed as part of the terraform plan lifecycle.
Common mistakes.
- A.
terraform initinitializes the working directory, downloads providers, and sets up backends; it does not involve importing resources. - C.
terraform refreshupdates the state file to reflect the current real-world infrastructure, but it does not import new, unmanaged resources into the state. - D. While
terraform import(the CLI command) is run by an explicit call, the question might be implicitly referring to how import operations are integrated into the overall Terraform workflow withimportblocks, whereplanplays a crucial role. - E.
terraform import(the command) is not part ofinit,plan, orrefreshcommands directly, andimportblocks are specifically part of theplan/applylifecycle, not all of them.
Concept tested. Terraform import process lifecycle
Reference. https://developer.hashicorp.com/terraform/language/import
Topics
#terraform import#terraform plan#CLI workflow#State management
Community Discussion
No community discussion yet for this question.