nerdexam
HashiCorp

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.

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

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)
  • A
    6% (2)
  • B
    91% (29)
  • E
    3% (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.

Aterraform state

`terraform state` is a subcommand group for managing state entries directly and does not perform an infrastructure refresh.

Bterraform applyCorrect

`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.

Cterraform planCorrect
Dterraform validate

`terraform validate` only checks configuration syntax and schema correctness; it does not interact with providers or refresh state.

Eterraform output

`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

#Terraform CLI#State management#terraform plan#terraform apply

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice