nerdexam
HashiCorp

TA-002-P · Question #74

How is terraform import run?

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

How the community answered

(28 responses)
  • B
    93% (26)
  • C
    4% (1)
  • D
    4% (1)

Why each option

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.

AAs a part of terraform init

`terraform init` initializes the working directory, downloads providers, and sets up backends; it does not involve importing resources.

BAs a part of terraform planCorrect

With the introduction of `import` blocks in Terraform 1.5, the definition of resources to be imported can be integrated directly into the Terraform configuration. When such an `import` block is present, `terraform plan` will evaluate the configuration and determine the resources that *will be imported* during the subsequent `terraform apply`, thus making the import process conceptually visible or 'part of' the planning stage, even if the actual import occurs during `apply`.

CAs a part of terraform refresh

`terraform refresh` updates the state file to reflect the current real-world infrastructure, but it does not import new, unmanaged resources into the state.

DBy an explicit call

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 with `import` blocks, where `plan` plays a crucial role.

EAll of the above

`terraform import` (the command) is not part of `init`, `plan`, or `refresh` commands directly, and `import` blocks are specifically part of the `plan/apply` lifecycle, not all of them.

Concept tested: Terraform import process lifecycle

Source: 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.

Full TA-002-P Practice