nerdexam
HashiCorp

TERRAFORM-ASSOCIATE-004 · Question #141

Once you configure a new Terraform backend with a terraform code block, which command(s) should you use to migrate the state file?

The correct answer is A. terraform destroy, then terraform apply. When you configure a new backend in Terraform, running 'terraform init' detects the backend change and prompts you to migrate the existing state to the new backend. It handles the migration safely without destroying infrastructure. Running 'terraform destroy' followed by 'terrafo

Submitted by satoshi_tk· Apr 18, 2026Manage Terraform State

Question

Once you configure a new Terraform backend with a terraform code block, which command(s) should you use to migrate the state file?

Options

  • Aterraform destroy, then terraform apply
  • Bterraform init
  • Cterraform push
  • Dterraform apply

How the community answered

(22 responses)
  • A
    77% (17)
  • B
    14% (3)
  • C
    5% (1)
  • D
    5% (1)

Explanation

When you configure a new backend in Terraform, running 'terraform init' detects the backend change and prompts you to migrate the existing state to the new backend. It handles the migration safely without destroying infrastructure. Running 'terraform destroy' followed by 'terraform apply' would tear down all existing infrastructure and rebuild it from scratch - this destroys and recreates resources rather than migrating the state file, which is dangerous and incorrect. 'terraform push' is a legacy/deprecated command, and 'terraform apply' alone does not trigger backend migration. The correct answer should be B.

Topics

#Terraform Backend#State Management#Terraform CLI Commands#Infrastructure Lifecycle

Community Discussion

No community discussion yet for this question.

Full TERRAFORM-ASSOCIATE-004 Practice