0
0
Terraformcloud~30 mins

Workspace naming conventions in Terraform - Mini Project: Build & Apply

Choose your learning style9 modes available
Workspace Naming Conventions in Terraform
📖 Scenario: You are managing infrastructure using Terraform. To keep your environments organized, you want to create workspaces with clear and consistent names.Think of workspaces like folders for different projects or environments, such as development, testing, and production.
🎯 Goal: Create Terraform workspace names following a specific naming convention to separate environments clearly.
📋 What You'll Learn
Create a Terraform workspace list with exact names
Add a prefix variable for workspace names
Use a loop to generate full workspace names with the prefix
Output the final list of workspace names
💡 Why This Matters
🌍 Real World
Naming workspaces clearly helps teams avoid confusion and manage multiple environments safely.
💼 Career
Understanding workspace naming conventions is essential for infrastructure as code and collaboration in cloud engineering roles.
Progress0 / 4 steps
1
Create a list of workspace environment names
Create a Terraform variable called environments with the exact list of strings: ["dev", "test", "prod"].
Terraform
Need a hint?

Use variable block with default set to the list.

2
Add a prefix variable for workspace names
Add a Terraform variable called prefix with the exact string value "teamA-".
Terraform
Need a hint?

Use a variable block with default set to "teamA-".

3
Generate full workspace names with prefix
Create a Terraform local variable called workspace_names that uses a for expression to combine var.prefix and each item in var.environments into a list of full workspace names.
Terraform
Need a hint?

Use a for expression inside locals to concatenate strings.

4
Output the final list of workspace names
Create a Terraform output called workspaces that outputs the value of local.workspace_names.
Terraform
Need a hint?

Use an output block with value set to local.workspace_names.