0
0
Terraformcloud~5 mins

Terraform.workspace interpolation - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does terraform.workspace represent in Terraform?

terraform.workspace is a built-in variable that returns the name of the current workspace you are using in Terraform.

Click to reveal answer
beginner
How can terraform.workspace be used in resource naming?

You can include terraform.workspace in resource names to create unique names per workspace, helping avoid conflicts between environments.

Click to reveal answer
beginner
What is a Terraform workspace?

A workspace is like a separate environment in Terraform that keeps its own state file, allowing you to manage multiple environments (like dev, test, prod) with the same configuration.

Click to reveal answer
beginner
How do you reference the current workspace in a Terraform configuration?

Use ${terraform.workspace} or in Terraform 0.12+ simply terraform.workspace inside expressions to get the current workspace name.

Click to reveal answer
intermediate
Why is using terraform.workspace interpolation considered a best practice?

It helps keep resources isolated per environment by dynamically adjusting names or settings based on the workspace, reducing risk of accidental resource overlap.

Click to reveal answer
What does terraform.workspace return?
AThe current workspace name
BThe Terraform version
CThe current AWS region
DThe current user name
How can terraform.workspace help in managing multiple environments?
ABy creating separate state files per workspace
BBy changing the Terraform version automatically
CBy encrypting resource names
DBy deleting unused resources
Which syntax is correct to use terraform.workspace in Terraform 0.12+?
A${terraform.workspace}
Bterraform[workspace]
Cterraform.workspace
Dworkspace.terraform
What is the main benefit of interpolating terraform.workspace in resource names?
ATo reduce Terraform file size
BTo make resource names unique per environment
CTo speed up Terraform runs
DTo enable auto-scaling
Which command creates a new workspace in Terraform?
Aterraform apply workspace <name>
Bterraform create workspace <name>
Cterraform init workspace <name>
Dterraform workspace new <name>
Explain what terraform.workspace is and how it helps manage multiple environments.
Think about how Terraform keeps different environment states separate.
You got /4 concepts.
    Describe how you would use terraform.workspace interpolation to avoid resource name conflicts.
    Imagine you have dev and prod environments using the same config.
    You got /3 concepts.