Terraform "cloud" block - HCP "organization ... not found" in CI
A cloud {} block points init at HCP Terraform (app.terraform.io), but the organization name is wrong or the runner has no token - so init cannot connect to the remote workspace.
What this error means
terraform init fails configuring the cloud backend: it reports the organization does not exist, or that a required token could not be found. It surfaces on a fresh runner that was never logged in to HCP Terraform.
Error: Failed to request discovery document
Error: organization "my-org" not found or user unauthorized
# or, with no token configured:
Error: required token could not be found. Please run "terraform login".Common causes
Wrong organization or workspace name
The organization in the cloud block does not match an org you can access in HCP Terraform, so the workspace lookup fails.
No HCP Terraform token on the runner
CI never ran terraform login, and no TF_TOKEN_app_terraform_io (or credentials block) is set, so init has nothing to authenticate with.
How to fix it
Provide the HCP token via environment
Set the host-scoped token env var so init authenticates non-interactively in CI.
export TF_TOKEN_app_terraform_io="${{ secrets.TFC_TOKEN }}"
terraform init -input=falseConfirm the organization and workspace
- Verify the
organizationin thecloudblock exactly matches your HCP Terraform org. - Confirm the token’s identity can access that org and the named workspace.
- Use
workspaces { name = ... }ortags = [...]that actually exist in the org.
How to prevent it
- Inject
TF_TOKEN_app_terraform_iofrom CI secrets rather thanterraform login. - Pin the exact
organizationandworkspacesin thecloudblock. - Use a team token scoped to the workspaces CI needs.