nerdexam
HashiCorp

TA-002-P · Question #387

colleagues is new toTerraform and wants to add a new workspace named new-hire. What command he should execute from the following?

The correct answer is B. terraform workspace new new hire. To create a new workspace in Terraform, the command terraform workspace new <workspace-name> is the correct syntax.

Use the Terraform CLI (terraform plan, apply, destroy, fmt, init, validate, workspace, import, taint, providers, output)

Question

colleagues is new toTerraform and wants to add a new workspace named new-hire. What command he should execute from the following?

Options

  • Aterraform workspace-new-new-hire
  • Bterraform workspace new new hire
  • Cterraform workspace init new-hire
  • Dterraform workspace new-hire

How the community answered

(34 responses)
  • A
    3% (1)
  • B
    94% (32)
  • D
    3% (1)

Why each option

To create a new workspace in Terraform, the command `terraform workspace new <workspace-name>` is the correct syntax.

Aterraform workspace-new-new-hire

The command syntax terraform workspace-new-new-hire is incorrect; the subcommand new should be separate.

Bterraform workspace new new hireCorrect

The correct command to create a new workspace named new-hire is terraform workspace new new-hire. This command initializes a new isolated state for the specified workspace name, allowing different environments or configurations to share the same code.

Cterraform workspace init new-hire

terraform workspace init is not a valid command; terraform init initializes the working directory, but not specifically for creating workspaces.

Dterraform workspace new-hire

terraform workspace new-hire is incomplete syntax for creating a new workspace; it's missing the new subcommand.

Concept tested: Terraform workspace creation

Source: https://developer.hashicorp.com/terraform/cli/commands/workspace/new

Topics

#Terraform CLI#Workspaces#Command syntax#Workspace creation

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice