HashiCorp Certified: Terraform Associate — Question 68

You would like to reuse the same Terraform configuration for your development and production environments with a different state file for each.
Which command would you use?

Answer options

Correct answer: B

Explanation

The correct answer is B, 'terraform workspace', as it allows you to create and manage multiple workspaces, enabling you to maintain different state files for different environments. The other options do not provide a way to separate state files; 'terraform import' is used to import existing resources, 'terraform state' deals with state management, and 'terraform init' initializes a working directory.