nerdexam
HashiCorp

TA-002-P · Question #142

Which of the below terraform commands do not run terraform refresh implicitly before taking actual action of the command?

The correct answer is C. terraform init D. terraform import. The terraform init and terraform import commands do not implicitly refresh the state before executing, unlike apply, destroy, and plan.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

Which of the below terraform commands do not run terraform refresh implicitly before taking actual action of the command?

Options

  • Aterraform apply
  • Bterraform destroy
  • Cterraform init
  • Dterraform import
  • Eterraform plan

How the community answered

(42 responses)
  • B
    2% (1)
  • C
    93% (39)
  • E
    5% (2)

Why each option

The `terraform init` and `terraform import` commands do not implicitly refresh the state before executing, unlike `apply`, `destroy`, and `plan`.

Aterraform apply

`terraform apply` implicitly performs a refresh to update the state with the real-world infrastructure before proposing or applying changes.

Bterraform destroy

`terraform destroy` implicitly performs a refresh to ensure the state reflects the current infrastructure before planning or executing destruction.

Cterraform initCorrect

`terraform init` initializes a working directory, downloading providers and modules; it does not interact with existing remote infrastructure state or perform a refresh.

Dterraform importCorrect

`terraform import` brings existing infrastructure into Terraform state but does not perform a global state refresh across all resources before the import operation itself.

Eterraform plan

`terraform plan` implicitly performs a refresh to gather the current state of resources before generating an execution plan.

Concept tested: Implicit refresh behavior of Terraform commands

Source: https://developer.hashicorp.com/terraform/cli/commands/init

Topics

#Terraform CLI#Implicit refresh#terraform init#terraform import

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice