Terraform Cloud
HashiCorp's managed platform for Terraform โ remote state storage, locked execution environments, team access controls, cost estimation, and Sentinel policy enforcement with zero infrastructure to manage.
What is Terraform Cloud?
Terraform Cloud (TFC) is HashiCorp's managed SaaS platform that extends open-source Terraform with collaboration, security, and governance features. At its core it solves three problems that arise when teams use Terraform: state management (where is the state file and who can access it?), execution consistency (runs on different machines produce different results due to different provider versions), and team workflows (who approved this apply and when?).
TFC organizes work into workspaces โ each workspace is an isolated Terraform working directory with its own state, variables, run history, and access controls. Workspaces map loosely to environments (dev/staging/prod) or infrastructure components (vpc/eks/rds). Runs (plans and applies) execute on HashiCorp-managed compute in an isolated, reproducible environment.
Configuring Remote State
Add the cloud block to your Terraform configuration to store state in Terraform Cloud:
# main.tf โ configure Terraform Cloud backend
terraform {
required_version = ">= 1.1.0"
cloud {
organization = "my-org"
workspaces {
name = "api-production"
}
}
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
# Authenticate via environment variable or interactive login
# export TF_TOKEN_app_terraform_io="your-api-token"
# OR run: terraform login VCS-Driven Workflow (GitHub Integration)
Connect a workspace to your GitHub repository for automatic plan-on-PR and apply-on-merge workflows:
# In Terraform Cloud UI: # Workspace โ Settings โ Version Control โ Connect to VCS # Install the Terraform Cloud GitHub App # Select repository and configure: # - Working directory: infra/aws/production # - Trigger: Only files in working directory # - Auto apply: enabled for main branch only # PR workflow (automatic): # 1. Developer opens PR โ TFC runs terraform plan # 2. Plan output posted as PR comment # 3. Reviewer approves the plan in TFC UI # 4. PR merged โ TFC runs terraform apply automatically # 5. Apply output stored in run history with committer identity
Cross-Workspace Remote State
# In producer workspace (vpc-production), expose outputs:
output "vpc_id" {
value = aws_vpc.main.id
}
output "private_subnet_ids" {
value = aws_subnet.private[*].id
}
# In consumer workspace (eks-production), read remote state:
data "terraform_remote_state" "vpc" {
backend = "remote"
config = {
organization = "my-org"
workspaces = {
name = "vpc-production"
}
}
}
resource "aws_eks_cluster" "main" {
name = "production"
role_arn = aws_iam_role.eks.arn
vpc_config {
subnet_ids = data.terraform_remote_state.vpc.outputs.private_subnet_ids
}
}
# Also enable remote state sharing in TFC:
# vpc-production workspace โ Settings โ Remote state sharing โ Add eks-production Sentinel Policy Enforcement
# policies/require-s3-versioning.sentinel
import "tfplan/v2" as tfplan
# Find all S3 bucket resources in the plan
s3_buckets = filter tfplan.resource_changes as _, rc {
rc.type is "aws_s3_bucket" and
rc.mode is "managed" and
rc.change.actions contains "create"
}
# Policy rule: all new S3 buckets must enable versioning
main = rule {
all s3_buckets as _, bucket {
bucket.change.after.versioning[0].enabled is true
}
}
# policy-set configuration (sentinel.hcl):
# policy "require-s3-versioning" {
# source = "./policies/require-s3-versioning.sentinel"
# enforcement_level = "soft-mandatory"
# } GitHub Actions Integration
# .github/workflows/terraform.yml
name: Terraform CI
on:
pull_request:
paths: ['infra/**']
push:
branches: [main]
paths: ['infra/**']
jobs:
terraform:
runs-on: ubuntu-latest
defaults:
run:
working-directory: infra/aws/production
env:
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "~1.7"
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
- name: Terraform Init
run: terraform init
- name: Terraform Plan
if: github.event_name == 'pull_request'
run: terraform plan -no-color
- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve Terraform Cloud vs Terraform Enterprise vs Local
| Feature | Local / S3 Backend | Terraform Cloud | Terraform Enterprise |
|---|---|---|---|
| Hosting | Self-managed | HashiCorp SaaS | Self-hosted |
| Remote state | Manual (S3 + DynamoDB) | Built-in, encrypted | Built-in, encrypted |
| Remote execution | No | Yes | Yes |
| Sentinel policies | No | Plus tier+ | Yes (all tiers) |
| Cost estimation | No | Yes | Yes |
| Data residency | Full control | HashiCorp US/EU | Full control |
| Cost | AWS S3 + DynamoDB fees | Free (500 resources) / $20+ per user | Enterprise contract |
Best Practices
- Use one workspace per environment per infrastructure component (e.g.,
vpc-dev,vpc-prod,eks-prod) - Store sensitive variables (AWS keys, database passwords) as sensitive workspace variables โ never in
.tfvarsfiles committed to Git - Enable cost estimation and review it before approving applies to avoid surprise AWS bills
- Use run triggers to automatically re-plan downstream workspaces when upstream state changes
- Pin Terraform and provider versions to avoid unexpected behavior from automatic upgrades
- Enable the "Require two-factor authentication" organization setting for all users
Frequently Asked Questions
What is Terraform Cloud and how does it differ from running Terraform locally?▼
Terraform Cloud is HashiCorp's managed service that provides remote state storage, a locked execution environment, team access controls, cost estimation, and Sentinel policy enforcement โ all in the cloud. When running Terraform locally, state files live on your machine or an S3 bucket you manage, runs execute on your laptop (with your environment variables), and there is no built-in team collaboration or audit trail. Terraform Cloud centralizes all of this: state is encrypted and versioned automatically, runs are reproducible in an isolated environment, and every plan and apply is logged with who triggered it.
How does VCS-driven (GitHub) workflow work in Terraform Cloud?▼
Connect your Terraform Cloud workspace to a GitHub repository. When you open a pull request, Terraform Cloud automatically runs terraform plan and posts the plan output as a PR comment. When the PR is merged to the main branch, Terraform Cloud runs terraform apply automatically. This creates a GitOps-style workflow where infrastructure changes go through code review before being applied. You configure the VCS connection in workspace settings by installing the Terraform Cloud GitHub App and specifying the working directory and trigger patterns.
What is the difference between Terraform Cloud and Terraform Enterprise?▼
Terraform Cloud is the SaaS offering hosted by HashiCorp at app.terraform.io โ you do not manage the infrastructure running it. Terraform Enterprise is the self-hosted version you install on your own servers (VM or Kubernetes), giving you full control over data residency, network isolation, and compliance requirements. Terraform Enterprise also includes additional enterprise features like audit logging, SAML/SSO integration, and higher Sentinel tier limits. Most teams start with Terraform Cloud Free or Plus tiers and only move to Enterprise for strict data sovereignty requirements.
How do I use remote state in Terraform Cloud from another workspace?▼
In your consumer workspace, declare a terraform_remote_state data source pointing to the producer workspace: data terraform_remote_state vpc { backend = 'remote' config = { organization = 'my-org' workspaces = { name = 'vpc-prod' } } }. Then reference outputs: data.terraform_remote_state.vpc.outputs.vpc_id. You must also enable 'Remote state sharing' in the producer workspace settings under General > Remote state sharing and add the consumer workspace to the allow list. This is how you compose infrastructure across multiple workspaces without hardcoding values.
What is Sentinel policy enforcement in Terraform Cloud?▼
Sentinel is HashiCorp's policy-as-code framework embedded in Terraform Cloud. You write policies in Sentinel language that run between the plan and apply phases. Policies can enforce rules like 'all S3 buckets must have versioning enabled' or 'no instance type larger than t3.xlarge is allowed in dev'. Policies have three enforcement modes: advisory (pass/fail logged but apply continues), soft-mandatory (can be overridden by a privileged user), and hard-mandatory (blocks apply unconditionally). Sentinel is available on Terraform Cloud Plus and Terraform Enterprise.
How do I integrate Terraform Cloud with GitHub Actions?▼
Use the hashicorp/setup-terraform GitHub Action to install Terraform, then authenticate to Terraform Cloud using a TFC API token stored as a GitHub secret. Set TF_API_TOKEN in your workflow environment. On pull_request events, run terraform plan; on push to main, run terraform apply. Alternatively, use Terraform Cloud's native VCS integration which avoids managing tokens in GitHub and provides richer plan output in the TFC UI. The native VCS integration is recommended for most teams as it provides better visibility and audit trails.
Related Products
on GumroadPremium Workflow Pack
Production-grade workflows, architecture guides, and deployment scripts for teams that ship. 10 advanced CI/CD workflows (blue-green, canary, E2E, security), 5 architecture deep-dives, code review checklist, PR process guide, and 5 battle-tested Bash deployment scripts.
Buy on Gumroad โGitHub Actions CI/CD Templates Pack
12 production-ready GitHub Actions workflow templates covering Node.js, Python, Docker, multi-environment deployments, security scanning, and auto-changelog. Copy, paste, ship.
Buy on Gumroad โDeveloper Productivity Bundle
Stop rebuilding the same setup every project. 51 VSCode snippets, 40 Git aliases, 5 Docker Compose stacks, 5 GitHub Actions workflows, 5 README templates, and a dotfiles kit. Set up a professional dev environment in under an hour.
Buy on Gumroad โYou Might Also Need
Terraform Variable Builder
Build Terraform variable declarations for variables.tf with a visual form. Set type, default value, description, sensitivity, and validation rules.
Open free tool โ
Terraform Variable Validator
Validate your Terraform variables.tf online. Catches missing type constraints, undocumented variables, unmasked secrets, and type/default mismatches. Runs 100% in your browser.
Open free tool โ
Terraform Variable Generator
Generate variables.tf and terraform.tfvars from a visual form. Add variables with type, description, defaults, sensitive flag, and validation blocks.
Open free tool โ
More Free Tools
Related Articles
Terraform vs Pulumi 2026: Infrastructure as Code Comparison with Code Examples
Complete Terraform vs Pulumi comparison for 2026 โ syntax, state management, multi-cloud support, testing, pricing, and when to choose each IaC tool.
AWS CDK vs Terraform vs Pulumi: Infrastructure as Code Comparison 2026
Complete comparison of AWS CDK, Terraform, and Pulumi for infrastructure as code in 2026 โ language support, state management, multi-cloud, community, and when to use each.
Pulumi vs Terraform 2026: Which IaC Tool Should You Choose?
A deep comparison of Pulumi and Terraform for infrastructure as code in 2026. Covers syntax, state management, provider ecosystem, team adoption, and when to choose each tool.
Terraform Infrastructure as Code: Complete 2024 Guide
Master Terraform for infrastructure as code. Learn HCL syntax, providers, state management, modules, and best practices to automate your cloud infrastructure.
Terraform vs Pulumi vs AWS CDK: Best Infrastructure as Code Tool 2026
Terraform vs Pulumi vs AWS CDK โ a deep comparison of language support, state management, cloud coverage, testing, and team fit. Find the right IaC tool for 2026.
Enjoying this tool? Get more like it.
Weekly developer tool guides, productivity playbooks & AI tricks. Free. No spam.
Unlock AI-Powered Dev Tools
- โก AI Code Review, Doc Generator & SQL Builder
- โก All premium templates & early access
- โก Member discounts on Gumroad products
$9/mo after trial ยท Cancel anytime
Want the full toolkit?
Get DevPlaybook Pro
Every template, guide, boilerplate, and automation script in one bundle. 13 premium products โ grab them all at once and save big.
MIT licensed ยท Instant download ยท No subscription
See what's included โ Browse all deals โ