- Tell Terraform where to connect (configure the
cloudblock). - Prove your identity to HCP Terraform with an API token (via
terraform loginfor interactive use or an environment variable for CI/CD automation).
terraform plan and terraform apply locally. HCP Terraform runs in the cloud. To move operations into HCP Terraform you must:
- Configure the
terraformsettings block with acloudblock that points to your organization and workspace. - Authenticate your CLI so HCP Terraform trusts your requests.
terraform settings block to your configuration that includes a cloud block. This instructs Terraform to use HCP Terraform (Terraform Cloud / HCP) instead of performing purely local operations.
Example HCL (targeting a specific workspace by name):
organizationmust exactly match the organization name in your HCP Terraform account.hostnamedefaults toapp.terraform.ioand is optional unless you use a custom hostname (for example, Terraform Enterprise).- Use
workspaces.nameto target a single workspace, orworkspaces.prefixto target workspaces sharing a name prefix. If multiple workspaces match a prefix, Terraform may prompt you to choose one at runtime. - The
cloudblock replaces the legacybackend "remote"configuration.
You cannot mix the
cloud block and a backend block in the same configuration. They are mutually exclusive — choose one or the other.- Terraform opens a browser to HCP Terraform to create an API token.
- If login succeeds, Terraform stores the token on disk for subsequent commands (for example
terraform init,terraform plan,terraform apply).

This file is stored in plain text. Ensure its filesystem permissions are restricted so unauthorized users cannot read the token.
| Token type | Purpose / typical use | Notes |
|---|---|---|
| Organization token | Admin-level management of teams, membership, and workspaces | Intended for organization administration — not for routine plan/apply operations |
| Team token | CI/CD and automation (e.g., Jenkins, GitHub Actions) | Commonly granted to automation workflows to run plans and applies |
| User token | terraform login creates this token for interactive users | Carries the user’s permissions and can access multiple organizations a user belongs to |
| Audit token | Read-only access to audit trail APIs | Intended for compliance and monitoring; cannot run Terraform operations |

TF_TOKEN_app_terraform_io to a valid API token before running Terraform commands.
Shell example:
- Store the token as a secret in your CI provider (GitHub Secrets, GitLab CI variables, Jenkins credentials, etc.).
- Use a team token or a service account with scoped permissions instead of a personal user token where appropriate.
- Rotate tokens periodically and set expirations when supported.
- Add a
cloudblock to your Terraform configuration to point at your HCP Terraform organization and workspace. - Authenticate with
terraform loginfor interactive use, or setTF_TOKEN_app_terraform_ioin CI/CD for non-interactive automation. - Keep credentials secure and choose the appropriate token type (organization, team, user, audit) for your use case.