Skip to content
Latchkey

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.

terraform init output
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.

Terminal
export TF_TOKEN_app_terraform_io="${{ secrets.TFC_TOKEN }}"
terraform init -input=false

Confirm the organization and workspace

  1. Verify the organization in the cloud block exactly matches your HCP Terraform org.
  2. Confirm the token’s identity can access that org and the named workspace.
  3. Use workspaces { name = ... } or tags = [...] that actually exist in the org.

How to prevent it

  • Inject TF_TOKEN_app_terraform_io from CI secrets rather than terraform login.
  • Pin the exact organization and workspaces in the cloud block.
  • Use a team token scoped to the workspaces CI needs.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →