HashiCorp Terraform Associate (004) Question 51
Single answer3a Describe the Terraform workflowA platform team stores Terraform configurations in Git and uses a remote backend for shared state. A developer updates the configuration to add a new subnet and wants to follow the standard Terraform workflow to safely review the impact before changing real infrastructure. Which sequence of commands best matches the recommended workflow for this situation?
- A
terraform init, terraform plan, terraform apply
- B
terraform validate, terraform destroy, terraform apply
- C
terraform plan, terraform init, terraform apply
- D
terraform refresh, terraform fmt, terraform output
Show answer and explanation
Correct answer: A
Explanation
The standard Terraform workflow for applying infrastructure changes is to initialize the working directory with terraform init, review proposed changes with terraform plan, and then make the changes with terraform apply. In real-world team environments, this is especially important when using a remote backend, because init prepares backend access and provider installation, while plan provides a chance to verify exactly what Terraform intends to change before applying it. Although commands such as terraform fmt and terraform validate are often used as supporting quality checks, they do not replace the core workflow of init -> plan -> apply. This aligns with HashiCorp documentation and common best practices for safe infrastructure changes.
- A. Correct.
Correct. In a typical Terraform workflow, you first run terraform init to initialize the working directory, download required providers, and configure the backend. Then terraform plan is used to preview the proposed infrastructure changes before they are made. Finally, terraform apply executes the approved changes. This sequence reflects the standard safe workflow for collaborating with remote state and reviewing changes before applying them.
- B. Incorrect.
Incorrect. terraform validate checks whether the configuration is syntactically valid and internally consistent, but it does not initialize providers or backends. terraform destroy is used to remove managed infrastructure, which is not appropriate when the goal is to add a subnet. Someone might choose this option by confusing validation with planning or by thinking destroy is part of a routine deployment workflow.
- C. Incorrect.
Incorrect. terraform plan generally requires the working directory to be initialized first, especially when providers and a backend must be configured. Running plan before init commonly fails because Terraform has not yet downloaded provider plugins or set up backend access. This option reflects a common misconception that planning can happen before initialization.
- D. Incorrect.
Incorrect. terraform refresh, terraform fmt, and terraform output are useful commands in some circumstances, but they do not represent the standard workflow for safely making and reviewing a configuration change. fmt only formats code, output displays values from state, and refresh is not the core review-before-change step expected here. This option may appeal to someone who recognizes valid Terraform commands but does not understand their role in the workflow.