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
Terraform Cloud/Enterprise Features Setup
📖 Scenario: You are working as a cloud engineer for a company that wants to manage infrastructure using Terraform Cloud. Your task is to create a Terraform configuration that sets up a workspace with specific features enabled in Terraform Cloud.
🎯 Goal: Build a Terraform configuration that defines a Terraform Cloud workspace with version control integration, automatic runs enabled, and workspace variables configured.
📋 What You'll Learn
Create a Terraform Cloud workspace resource named example_workspace.
Set the workspace to use the main branch from a GitHub repository.
Enable automatic runs on changes.
Add a workspace variable named environment with the value production.
Configure the workspace to use Terraform version 1.5.0.
💡 Why This Matters
🌍 Real World
Terraform Cloud workspaces help teams manage infrastructure as code with collaboration, version control, and automation.
💼 Career
Knowing how to configure Terraform Cloud workspaces is essential for cloud engineers and DevOps professionals managing infrastructure deployments.
Progress0 / 4 steps
1
Create Terraform Cloud workspace resource
Write a Terraform resource block named terraform_cloud_workspace with the resource name example_workspace. Set the name attribute to example-workspace.
Terraform
Hint
Use the resource keyword to define a Terraform Cloud workspace resource with the exact name and resource identifier.
2
Configure version control and automatic runs
Add the vcs_repo block inside the terraform_cloud_workspace.example_workspace resource. Set identifier to github-user/repo-name and branch to main. Also, set auto_apply to true to enable automatic runs.
Terraform
Hint
Use the vcs_repo block to connect the workspace to a GitHub repo and set auto_apply to true to enable automatic runs.
3
Add workspace variable
Inside the terraform_cloud_workspace.example_workspace resource, add a variable block. Set key to environment, value to production, and category to terraform.
Terraform
Hint
Add a variable block with the exact key, value, and category to set workspace variables.
4
Set Terraform version for the workspace
Add the terraform_version attribute to the terraform_cloud_workspace.example_workspace resource and set it to "1.5.0".
Terraform
Hint
Set the terraform_version attribute to specify the Terraform version used by the workspace.
Practice
(1/5)
1. What is the main purpose of Terraform Cloud/Enterprise?
easy
A. To help teams manage infrastructure together safely
B. To replace Terraform CLI on local machines
C. To provide a graphical interface for writing Terraform code
D. To host websites built with Terraform
Solution
Step 1: Understand Terraform Cloud/Enterprise role
Terraform Cloud/Enterprise is designed to help teams collaborate on infrastructure management safely.
Step 2: Eliminate incorrect options
It does not replace the CLI, provide a GUI for coding, or host websites.
Final Answer:
To help teams manage infrastructure together safely -> Option A
Quick Check:
Collaboration and safety = B [OK]
Hint: Think teamwork and safety in infrastructure management [OK]
Common Mistakes:
Confusing Terraform Cloud with a code editor
Thinking it replaces local Terraform CLI
Assuming it hosts applications
2. Which of the following is the correct way to configure a Terraform Cloud workspace in terraform block?
easy
A. terraform { cloud { organization = "my-org" workspaces { name = "my-workspace" } } }
B. Backend "cloud" does not support workspace configuration
C. The key extra_key is not valid in backend configuration
D. The workspace name must be inside a workspaces block, not as workspace key
Solution
Step 1: Check valid keys for backend "cloud" block
Valid keys include organization and workspaces { name = "dev" } block. Direct workspace key is invalid.
Step 2: Identify invalid key causing error
The workspace = "dev" key is not valid; it must be inside a workspaces block.
Final Answer:
The workspace name must be inside a workspaces block, not as workspace key -> Option D
Quick Check:
workspace requires workspaces block = B [OK]
Hint: Only use documented keys in backend block [OK]
Common Mistakes:
Using direct workspace= instead of workspaces block
Adding unsupported keys in backend config
Misplacing workspace inside or outside workspaces block
Assuming organization can be omitted
5. Your team wants to enforce that all Terraform runs in Terraform Cloud must pass a policy check before applying changes. Which Terraform Cloud/Enterprise feature should you use to achieve this?
hard
A. Sentinel policies integrated with Terraform Cloud runs
B. Terraform CLI hooks on local machines
C. Manual approval outside Terraform Cloud
D. Terraform Cloud workspace tags
Solution
Step 1: Identify feature for policy enforcement in Terraform Cloud
Sentinel is Terraform Cloud's policy as code framework that integrates with runs to enforce rules.
Step 2: Eliminate other options
CLI hooks are local and not enforced centrally; manual approval is not automated; tags do not enforce policies.
Final Answer:
Sentinel policies integrated with Terraform Cloud runs -> Option A
Quick Check:
Policy enforcement = Sentinel = A [OK]
Hint: Use Sentinel for policy checks in Terraform Cloud [OK]
Common Mistakes:
Confusing local CLI hooks with centralized policy enforcement