HashiCorp Certified: Terraform Associate — Question 98
You have some Terraform code and a variable definitions file named dev.auto.tfvars that you tested successfully in the dev environment. You want to deploy the same code in the staging environment with a separate variable definition file and a separate state file.
Which two actions should you perform? (Choose two.)
Answer options
- A. Copy the existing terraform.tfstate file and save it as staging.terraform.tfstate
- B. Write a new staging.auto.tfvars variable definition file and run Terraform with the var-file=”staging.auto.tfvars” flag
- C. Create a new Terraform workspace for staging
- D. Create a new Terraform provider for staging
- E. Add new Terraform code (*.tf files) for staging in the same directory
Correct answer: B, C
Explanation
The correct actions are to create a new staging.auto.tfvars variable definition file and run Terraform with the var-file option (B), and to establish a new Terraform workspace for staging (C). Copying the state file (A) is not necessary as workspaces are designed to manage separate states. Creating a new Terraform provider (D) and adding new code (E) are not required for deploying to a different environment using the same codebase.