Introduction
When creating Terraform Cloud (TFC) workspaces connected to GitHub repositories, users may encounter the following error:
Error: Error updating workspace ws-XXXXXXX: invalid attribute │ Repository doesn't exist or isn't accessible
This error typically arises in VCS-driven workflows when the GitHub repository or organization is not properly connected or authorized in Terraform Cloud.
Background
When integrating Terraform Cloud with GitHub via the GitHub App or an OAuth connection, authentication and repository access are scoped to the GitHub account and organization that performed the installation and authorization.
Tokens used in this process — such as TFE_TOKEN
or OAuth tokens — must be associated with GitHub users who have access to the intended repositories and organizations. If a token or GitHub App was authorized under one GitHub organization, it won’t automatically grant access to repositories in another organization.
This becomes particularly important when workspaces are being created programmatically and need to connect to repositories across different GitHub organizations.
Cause
This error generally occurs due to one or more of the following reasons:
- In case they're using tfe provider for creating resource tfe_workspace, the
repo_identifier
(e.g.,org_name/repo_name
) is incorrect or the repository doesn't exist. - The GitHub App connected to Terraform Cloud has not been authorized to access the GitHub organization or its repositories.
- A mismatch in GitHub access tokens (
TFE_TOKEN
) where the token belongs to a user who lacks access to the target GitHub organization.
Solution
-
Verify that Terraform Cloud has access to the repository via the VCS provider. Go to your VCS Provider settings in Terraform Cloud and ensure that the GitHub App has been properly installed and the target repository is authorized for use.
For detailed steps, refer to: Authorization – Terraform Cloud GitHub App Integration - To ensure the GitHub App has the necessary access:
- Go to your GitHub account and click on “Your Organizations.”
- Select the relevant organization (e.g.,
GH_Test_orgB
). - Navigate to:
Settings → Third-party access - Under OAuth App access policy, check whether the Terraform Cloud GitHub App is listed and approved.
- If the app access is denied or not yet authorized, approve it for the organization.
Once access is granted, the repository will become accessible to Terraform Cloud, and the error should be resolved.
Alternatively, you can use a per-organization OAuth connection in Terraform Cloud, authorized with the permissions of a specific GitHub user who has access to the relevant GitHub organization.