Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 197


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

Show Answer
Correct Answer: BC

To deploy the same Terraform code in the staging environment with a separate variable definition file and state file, you should write a new staging.auto.tfvars variable definition file and run Terraform with the var-file=”staging.auto.tfvars” flag. This ensures that different values are used for variables in the staging environment. Additionally, creating a new Terraform workspace for staging isolates the state, allowing separate state management for different environments while using the same code.

Discussion

7 comments
Sign in to comment
Ni33Options: BC
May 10, 2023

B and C are correct answers. same tfstate file can be used in multiple workspaces to provision infrastructure and each workspace has its own tfvar file matching workspace prefix.

ozbeyucelOptions: BC
Feb 10, 2023

......

akm_1010Options: BC
Aug 13, 2023

with a separate variable definition file :- Write a new staging.auto.tfvars variable definition file and run Terraform with the var-file=”staging.auto.tfvars” flag Want to deploy the same code in the staging environment with a separate state file :- Create a new Terraform workspace for staging. Workspaces isolate Terraform state.

nakikooOptions: BC
Jan 13, 2023

Correct, workspace to use same .tf configuration with a different environment such as dev, prod, test, write new stage then refer the existing .tf config

campsOptions: BC
Mar 31, 2023

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

starksolutions
Nov 30, 2023

merci .

7b5b962
Jun 17, 2024

B. Terraform core Terraform core is responsible for reading the configuration, generating the execution plan, and applying the changes by interacting with the providers.