HashiCorp Terraform Infrastructure as Code (IaC) Practice Test

Question: 1 / 400

Which command lists the workspaces in Terraform?

terraform list workspaces

terraform workspace list

The command that lists the workspaces in Terraform is "terraform workspace list." This command retrieves and displays all the workspaces associated with the current Terraform configuration. Workspaces in Terraform allow users to manage multiple states for a single configuration, providing a way to isolate environments or different versions of an infrastructure setup.

Understanding this command is crucial for efficient management of environments, especially when working in teams or deploying multiple instances of the same infrastructure configuration. By using "terraform workspace list," you can quickly verify which workspaces are available and switch between them as needed.

Other options may seem relevant at a glance but do not serve this specific function. For example, while “terraform list workspaces” and “terraform workspaces” could intuitively seem like they might perform similar tasks, those are not valid Terraform commands. The command "terraform state list workspaces" is also not designed for listing workspaces but rather is focused on listing resources within the current state file. Therefore, the correct command for listing workspaces is indeed "terraform workspace list."

Ask an Examzify Tutor

terraform workspaces

terraform state list workspaces

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy