0
0
Terraformcloud~20 mins

Creating and switching workspaces in Terraform - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Workspace Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
What happens after creating a new workspace?
You run the command terraform workspace new dev in your project directory. What is the immediate effect on your Terraform environment?
AThe current workspace is renamed to 'dev'.
BA new workspace named 'dev' is created but you remain in the current workspace.
CA new workspace named 'dev' is created and automatically switched to.
DAn error occurs because you must switch manually after creating a workspace.
Attempts:
2 left
💡 Hint
Think about what Terraform does immediately after creating a workspace.
Configuration
intermediate
2:00remaining
Which command switches to an existing workspace?
You have workspaces named 'default', 'staging', and 'production'. Which command switches your current workspace to 'staging'?
Aterraform workspace select staging
Bterraform workspace new staging
Cterraform workspace use staging
Dterraform workspace switch staging
Attempts:
2 left
💡 Hint
Look for the official command to switch workspaces.
Architecture
advanced
2:00remaining
How do workspaces affect your Terraform state files?
You have multiple workspaces in your Terraform project. How does Terraform manage state files for these workspaces?
ATerraform merges all workspace states into one file automatically.
BAll workspaces share the same state file but use different prefixes.
CWorkspaces do not affect state files; all changes go to a single state file.
DEach workspace has its own separate state file stored in the backend.
Attempts:
2 left
💡 Hint
Think about isolation of environments in Terraform.
security
advanced
2:00remaining
What is a security risk when sharing Terraform workspaces?
If multiple team members share the same Terraform workspace, what is a potential security risk?
AWorkspaces automatically encrypt state files, so no risk exists.
BAccidental overwriting of state causing resource conflicts or data loss.
CTerraform prevents multiple users from accessing the same workspace.
DWorkspaces expose sensitive variables publicly by default.
Attempts:
2 left
💡 Hint
Consider what happens if multiple people change infrastructure at once.
Best Practice
expert
2:00remaining
What is the best practice for managing environments with Terraform workspaces?
You want to manage multiple environments (dev, staging, prod) using Terraform workspaces. Which approach is best?
AUse separate workspaces for each environment and keep environment-specific variables outside the main config.
BAvoid workspaces and manage environments by copying the entire Terraform project folder.
CCreate a workspace per environment but store all variables in one file without separation.
DUse a single workspace and switch variables manually before each apply.
Attempts:
2 left
💡 Hint
Think about isolation and maintainability of environments.