Terraform Tutorial — Terraform Cloud Backend
Terraform Cloud (HCP Terraform) provides a managed backend with built-in state storage, locking, team access, and a UI.
Configuration
terraform {
cloud {
organization = "my-company"
workspaces {
name = "web-app-prod"
}
}
}
Or the older remote backend syntax:
terraform {
backend "remote" {
organization = "my-company"
workspaces {
name = "web-app-prod"
}
}
}
Setup Steps
- Create an account at app.terraform.io
- Create an organization
- Generate an API token:
terraform login - Add the
cloudblock to your configuration - Run
terraform init
$ terraform login
# Opens browser for authentication
$ terraform init
Initializing Terraform Cloud...
Features
| Feature | S3 Backend | Terraform Cloud |
|---|---|---|
| State storage | ✅ | ✅ |
| Locking | ✅ (DynamoDB) | ✅ (built-in) |
| Encryption | ✅ (SSE) | ✅ (built-in) |
| State history | ✅ (versioning) | ✅ (UI + API) |
| Remote runs | ❌ | ✅ |
| Policy as Code | ❌ | ✅ (Sentinel) |
| Team management | ❌ (IAM) | ✅ (built-in) |
| Cost estimation | ❌ | ✅ |
| Free tier | N/A (S3 costs) | Up to 500 resources |
When to Use Terraform Cloud
| Scenario | Recommendation |
|---|---|
| Small team, AWS-only | S3 backend is simpler |
| Multi-cloud team | Terraform Cloud |
| Need policy enforcement | Terraform Cloud (Sentinel) |
| Want a UI for state | Terraform Cloud |
| Enterprise compliance | Terraform Enterprise (self-hosted) |
What’s Next?
Learn how to migrate state between backends and configure .gitignore.