toinbis
toinbis

Reputation: 757

Terraform Cloud github app: error retrieving Github App Installations: forbidden

I have this terraform setup:

terraform {
  required_providers {
    tfe = {
      source = "hashicorp/tfe"
    }
  }
}


data "tfe_github_app_installation" "gha_installation" {
  installation_id = 45797187
}

resource "tfe_workspace" "core-auth0" {
  name         = "core-auth0"
  description = "Auth0 configuration"

  organization = var.organization
  project_id = var.auth0_project_id

  working_directory = "src"
  queue_all_runs = true
  file_triggers_enabled = false

  vcs_repo {
    identifier = "exporio-infra/infra-core-auth0"
    branch     = "main"
    github_app_installation_id = data.tfe_github_app_installation.gha_installation.id
    ingress_submodules   = false
  }

}

I use it to configure the terraform cloud itself. I do use terraform cli for this. It was working some time ago, I got back to it after few months, appearantly some tokens got expired or I can't rememember how to configure it to work again.

I run terraform refresh and get:

terraform refresh                                           
module.xxxx-organization.module.workspaces.module.core-auth0.data.tfe_github_app_installation.gha_installation: Reading...
module.xxxx-organization.tfe_organization.exporio: Refreshing state... [id=xxxx]
module.xxxx-organization.module.projects.tfe_project.auth0: Refreshing state... [id=prj-MdMmD3yVHmk6mE]
module.xxxx-organization.module.varsets.module.auth0-dev.tfe_variable_set.auth0_dev: Refreshing state... [id=varset-xxx]

╷
│ Error: error retrieving Github App Installations: forbidden
│ 
│ Team and Organization Tokens are not supported
│ 
│   with module.xxx-organization.module.workspaces.module.core-auth0.data.tfe_github_app_installation.gha_installation,
│   on modules/organisations/xxxx/modules/workspaces/modules/core-auth0/main.tf line 10, in data "tfe_github_app_installation" "gha_installation":
│   10: data "tfe_github_app_installation" "gha_installation" {

What am I missing so that I that terraform refresh again? The token I use for export GITHUB_TOKEN= is github personal access token with all permissions.

Thanks for any guidance, got really stuck on this one.

Upvotes: 0

Views: 301

Answers (1)

GrandVizier
GrandVizier

Reputation: 639

I was experiencing the same issue, and resolved it by exporting TFE_TOKEN (which was the value as TF_TOKEN_app_terraform_io)

Upvotes: 1

Related Questions