TA-002-P · Question #224
Which of the following Terraform commands will automatically refresh the state unless supplied with additional flags or arguments? Choose TWO correct answers.
The correct answer is B. terraform apply C. terraform plan. terraform plan and terraform apply both perform a state refresh by default before executing, reconciling real infrastructure state with the stored state file.
Question
Which of the following Terraform commands will automatically refresh the state unless supplied with additional flags or arguments? Choose TWO correct answers.
Options
- Aterraform state
- Bterraform apply
- Cterraform plan
- Dterraform validate
- Eterraform output
How the community answered
(32 responses)- A6% (2)
- B91% (29)
- E3% (1)
Why each option
`terraform plan` and `terraform apply` both perform a state refresh by default before executing, reconciling real infrastructure state with the stored state file.
`terraform state` is a subcommand group for managing state entries directly and does not perform an infrastructure refresh.
`terraform apply` automatically runs a refresh phase before generating and applying a plan, ensuring the execution plan reflects current real-world infrastructure. `terraform plan` also refreshes state by default unless the `-refresh=false` flag is explicitly passed, making both commands auto-refreshing by default.
`terraform validate` only checks configuration syntax and schema correctness; it does not interact with providers or refresh state.
`terraform output` reads values from the existing state file without querying providers or refreshing infrastructure state.
Concept tested: Automatic state refresh in terraform plan and apply
Source: https://developer.hashicorp.com/terraform/cli/commands/plan#refresh-false
Topics
Community Discussion
No community discussion yet for this question.