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.
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)- B2% (1)
- C93% (39)
- E5% (2)
Why each option
The `terraform init` and `terraform import` commands do not implicitly refresh the state before executing, unlike `apply`, `destroy`, and `plan`.
`terraform apply` implicitly performs a refresh to update the state with the real-world infrastructure before proposing or applying changes.
`terraform destroy` implicitly performs a refresh to ensure the state reflects the current infrastructure before planning or executing destruction.
`terraform init` initializes a working directory, downloading providers and modules; it does not interact with existing remote infrastructure state or perform a refresh.
`terraform import` brings existing infrastructure into Terraform state but does not perform a global state refresh across all resources before the import operation itself.
`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
Community Discussion
No community discussion yet for this question.