Terraform Tutorial — Terraform Cloud Backend

1 minute read

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

  1. Create an account at app.terraform.io
  2. Create an organization
  3. Generate an API token: terraform login
  4. Add the cloud block to your configuration
  5. 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.


← DynamoDB Locking Backend Migration and .gitignore →