Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a workspace in Terraform?
A workspace in Terraform is a separate instance of your infrastructure state. It allows you to manage multiple environments (like development, staging, production) using the same configuration but with isolated states.
Click to reveal answer
beginner
Why use naming conventions for Terraform workspaces?
Naming conventions help keep workspaces organized and easy to identify. They reduce confusion, prevent mistakes like deploying to the wrong environment, and make collaboration smoother.
Click to reveal answer
beginner
Give an example of a simple workspace naming convention.
A simple naming convention could be: environment-purpose. For example, dev-webapp for the development environment of a web application, or prod-db for the production database.
Click to reveal answer
intermediate
What characters should you avoid in Terraform workspace names?
Avoid spaces, special characters, and uppercase letters. Use only lowercase letters, numbers, and hyphens (-) to keep names simple and compatible.
Click to reveal answer
intermediate
How does consistent workspace naming improve team collaboration?
Consistent names make it easy for everyone to understand which environment they are working on. It reduces errors, speeds up onboarding, and helps automate scripts that depend on workspace names.
Click to reveal answer
What is the main purpose of Terraform workspaces?
ATo manage multiple isolated infrastructure states
BTo store Terraform configuration files
CTo run Terraform commands faster
DTo create backups of infrastructure
✗ Incorrect
Terraform workspaces allow you to manage multiple isolated states, such as different environments, using the same configuration.
Which of the following is a good workspace name?
AProd-WebApp
Bdev_webapp
Cdev-webapp
DDev WebApp
✗ Incorrect
Use lowercase letters and hyphens only. 'dev-webapp' follows the best practice for workspace naming.
Why should you avoid spaces in workspace names?
AThey are hard to remember
BThey make names too long
CThey slow down Terraform
DThey cause errors in Terraform commands
✗ Incorrect
Spaces can cause errors or require extra handling in command-line tools like Terraform.
What does a workspace name like 'staging-api' tell you?
AIt is the production API environment
BIt is the staging environment for the API
CIt is a backup workspace
DIt is a test workspace for the database
✗ Incorrect
'staging-api' indicates the workspace is for the staging environment of the API service.
How does a naming convention help automation?
ABy allowing scripts to identify environments easily
BBy making workspace names unpredictable
CBy hiding workspace names from users
DBy increasing the number of workspaces
✗ Incorrect
Consistent naming lets automation scripts detect and use the correct workspace without manual input.
Explain why using a clear workspace naming convention is important in Terraform.
Think about how names help you and your team avoid confusion.
You got /4 concepts.
Describe a simple and effective workspace naming convention you could use.
Combine environment and project with a dash.
You got /4 concepts.
Practice
(1/5)
1.
What is the main purpose of using workspace names in Terraform?
easy
A. To store Terraform code files
B. To organize different environments like development and production
C. To define cloud provider credentials
D. To create virtual machines automatically
Solution
Step 1: Understand workspace role
Workspaces in Terraform separate different environments or states, like dev and prod.
Step 2: Match purpose to options
Only To organize different environments like development and production describes organizing environments, which is the workspace's main use.
Final Answer:
To organize different environments like development and production -> Option B
Quick Check:
Workspace names = environment organization [OK]
Hint: Workspaces separate environments, not code or credentials [OK]
Common Mistakes:
Confusing workspace with code storage
Thinking workspace manages credentials
Assuming workspace creates resources directly
2.
Which of the following workspace names follows best naming conventions in Terraform?
terraform workspace new ?
easy
A. staging-1
B. dev_environment
C. Prod-Env
D. TestEnv
Solution
Step 1: Review naming rules
Best practice is lowercase letters, hyphens allowed, no underscores or uppercase.
Step 2: Check each option
staging-1 uses lowercase and hyphen, fitting the rules. Others use uppercase or underscores.
Final Answer:
staging-1 -> Option A
Quick Check:
Lowercase + hyphen = staging-1 [OK]
Hint: Use lowercase and hyphens, avoid underscores and capitals [OK]
Common Mistakes:
Using uppercase letters
Using underscores instead of hyphens
Including spaces or special characters
3.
What will happen if you run the command terraform workspace select prod-env but the workspace prod-env does not exist?
medium
A. Terraform shows an error saying workspace not found
B. Terraform deletes the current workspace
C. Terraform switches to the default workspace
D. Terraform creates a new workspace named prod-env automatically
Solution
Step 1: Understand workspace select behavior
The select command switches to an existing workspace; it does not create one.
Step 2: Check command outcome
If the workspace does not exist, Terraform returns an error message.
Final Answer:
Terraform shows an error saying workspace not found -> Option A
Quick Check:
Select non-existent workspace = error [OK]
Hint: Select only switches; create with 'terraform workspace new' [OK]
Common Mistakes:
Assuming select creates workspace
Thinking Terraform switches to default silently
Believing workspace gets deleted
4.
Identify the error in this workspace creation command:
terraform workspace new Dev_Env
medium
A. Workspace names cannot contain uppercase letters
B. Workspace names must start with a number
C. Workspace names must be longer than 10 characters
D. Workspace names cannot contain underscores
Solution
Step 1: Check naming rules for characters
Workspace names should use lowercase letters and hyphens; underscores are not recommended.
Step 2: Analyze the command
The name 'Dev_Env' contains an underscore, which breaks the naming convention.
Final Answer:
Workspace names cannot contain underscores -> Option D
Quick Check:
Underscores disallowed in workspace names [OK]
Hint: Avoid underscores; use hyphens instead [OK]
Common Mistakes:
Thinking uppercase letters are forbidden (they are discouraged but allowed)
Believing names must start with numbers
Assuming length restrictions apply
5.
You want to create workspaces for three environments: development, testing, and production. Which set of workspace names follows best practices for naming conventions?
hard
A. dev, test_env, production
B. development, testing, production
C. dev-01, test-01, prod-01
D. Dev, Test, Prod
Solution
Step 1: Review naming best practices
Use lowercase letters, hyphens allowed, no underscores or uppercase letters.
Step 2: Evaluate each option
dev-01, test-01, prod-01 uses lowercase and hyphens with numbers, fitting best practices. dev, test_env, production uses underscore, B is long but valid, D uses uppercase.
Step 3: Choose best consistent and clear naming
dev-01, test-01, prod-01 is concise, consistent, and follows all rules.
Final Answer:
dev-01, test-01, prod-01 -> Option C
Quick Check:
Lowercase + hyphens + numbers = best practice [OK]
Hint: Use lowercase, hyphens, and numbers for clarity [OK]