You would like to reuse the same Terraform configuration for development and production with different state files; which command would you use?

Prepare for the HashiCorp Terraform Associate Exam with quizzes, flashcards, and multiple-choice questions. Each question includes hints and explanations. Boost your confidence and ace your exam!

Multiple Choice

You would like to reuse the same Terraform configuration for development and production with different state files; which command would you use?

Explanation:
Workspaces let you have separate state files for each environment while reusing the same configuration. By creating and switching between workspaces, Terraform uses a distinct state for development and production, so you can apply changes in one environment without affecting the other. You’d create or select a development workspace, then run plan and apply, and repeat with a production workspace for its state. The other commands don’t provide this per-environment state separation: the state subcommand only manipulates the state file, init prepares the working directory and downloads providers, and import brings existing resources into state.

Workspaces let you have separate state files for each environment while reusing the same configuration. By creating and switching between workspaces, Terraform uses a distinct state for development and production, so you can apply changes in one environment without affecting the other. You’d create or select a development workspace, then run plan and apply, and repeat with a production workspace for its state. The other commands don’t provide this per-environment state separation: the state subcommand only manipulates the state file, init prepares the working directory and downloads providers, and import brings existing resources into state.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy