Skip to content

[BLOCK]: github_app_installation_repository does not work with fine grained personal access tokens #2103

Open

Description

@audunsolemdal

Expected Behavior

Managing github app installations should work fine with fine-grained Github tokens

Actual Behavior

Fine-grained Github tokens do not work with managing app installations. Running Terraform plan works fine if the resource does not already exist, but fails with 403 Resource not accessible by personal access token [] on terraform apply. If the resource is already in terraform state the 403 error is returned when running terraform plan

The same resources work fine with a classic PAT with org:read and repo:write permissions. It is not clear to me if the fine-grained tokens supports generating a user access token , or if the terraform provider needs an update.

Terraform Version

Terraform v1.6.6
on windows_amd64

  • provider registry.terraform.io/integrations/github v5.44.0

Affected Resource(s)

  • github_app_installation_repositories
  • github_app_installation_repository

Terraform Configuration Files

locals {
  app_installation_id = "123456789"
}

provider "github" {
  owner = "solomno"
  token = var.github_token
}

variable "github_token" {
  type = string
  default = "github_pat_xxxxxxxxxxxxxxxxxx" 
}

resource "github_app_installation_repositories" "sync_infra_app" {
  installation_id       = local.app_installation_id 
  selected_repositories = ["sharing"]
}

resource "github_app_installation_repository" "sync_infra_app2" {
  installation_id = local.app_installation_id
  repository = "sharing"
}

Steps to Reproduce

  1. Generate fine-grained access token with access to a github organization. Allow all repos. Add as much permissions as you like, it will still fail
terraform apply

Debug Output

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # github_app_installation_repositories.sync_infra_app will be created
  + resource "github_app_installation_repositories" "sync_infra_app" {
      + id                    = (known after apply)
      + installation_id       = "123456789"
      + selected_repositories = [
          + "sharing",
        ]
    }

  # github_app_installation_repository.sync_infra_app2 will be created
  + resource "github_app_installation_repository" "sync_infra_app2" {
      + id              = (known after apply)
      + installation_id = "123456789"
      + repo_id         = (known after apply)
      + repository      = "sharing"
    }

Plan: 2 to add, 0 to change, 0 to destroy.
2024-01-16T10:23:23.372+0100 [DEBUG] command: asking for input: "\nDo you want to perform these actions?"

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

2024-01-16T10:23:24.179+0100 [INFO]  backend/local: apply calling Apply
2024-01-16T10:23:24.179+0100 [DEBUG] Building and walking apply graph for NormalMode plan
2024-01-16T10:23:24.179+0100 [DEBUG] Resource state not found for node "github_app_installation_repository.sync_infra_app2", instance github_app_installation_repository.sync_infra_app2
2024-01-16T10:23:24.179+0100 [DEBUG] Resource state not found for node "github_app_installation_repositories.sync_infra_app", instance github_app_installation_repositories.sync_infra_app
2024-01-16T10:23:24.179+0100 [DEBUG] ProviderTransformer: "github_app_installation_repository.sync_infra_app2" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/integrations/github"]
2024-01-16T10:23:24.180+0100 [DEBUG] ProviderTransformer: "github_app_installation_repositories.sync_infra_app" (*terraform.NodeApplyableResourceInstance) needs provider["registry.terraform.io/integrations/github"]
2024-01-16T10:23:24.180+0100 [DEBUG] ProviderTransformer: "github_app_installation_repositories.sync_infra_app (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/integrations/github"]
2024-01-16T10:23:24.180+0100 [DEBUG] ProviderTransformer: "github_app_installation_repository.sync_infra_app2 (expand)" (*terraform.nodeExpandApplyableResource) needs provider["registry.terraform.io/integrations/github"]
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "var.github_token" references: []
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "github_app_installation_repository.sync_infra_app2" references: [local.app_installation_id (expand)]
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "github_app_installation_repositories.sync_infra_app (expand)" references: [local.app_installation_id (expand)]
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "github_app_installation_repository.sync_infra_app2 (expand)" references: [local.app_installation_id (expand)]
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "local.ne1net_app_installation_id (expand)" references: []
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "local.scanitizer_app_installation_id (expand)" references: []
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "local.app_installation_id (expand)" references: []
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "github_app_installation_repositories.sync_infra_app" references: [local.app_installation_id (expand)]
2024-01-16T10:23:24.180+0100 [DEBUG] ReferenceTransformer: "provider[\"registry.terraform.io/integrations/github\"]" references: [var.github_token]
2024-01-16T10:23:24.180+0100 [DEBUG] pruneUnusedNodes: local.scanitizer_app_installation_id (expand) is no longer needed, removing
2024-01-16T10:23:24.180+0100 [DEBUG] pruneUnusedNodes: local.ne1net_app_installation_id (expand) is no longer needed, removing
2024-01-16T10:23:24.181+0100 [DEBUG] Starting graph walk: walkApply
2024-01-16T10:23:24.181+0100 [DEBUG] created provider logger: level=debug
2024-01-16T10:23:24.181+0100 [INFO]  provider: configuring client automatic mTLS
2024-01-16T10:23:24.184+0100 [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/integrations/github/5.44.0/windows_amd64/terraform-provider-github_v5.44.0.exe args=[".terraform/providers/registry.terraform.io/integrations/github/5.44.0/windows_amd64/terraform-provider-github_v5.44.0.exe"]
2024-01-16T10:23:24.187+0100 [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/integrations/github/5.44.0/windows_amd64/terraform-provider-github_v5.44.0.exe pid=37912
2024-01-16T10:23:24.187+0100 [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/integrations/github/5.44.0/windows_amd64/terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.204+0100 [INFO]  provider.terraform-provider-github_v5.44.0.exe: configuring server automatic mTLS: timestamp="2024-01-16T10:23:24.204+0100"
2024-01-16T10:23:24.213+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: plugin address: address=127.0.0.1:10000 network=tcp timestamp="2024-01-16T10:23:24.213+0100"
2024-01-16T10:23:24.213+0100 [DEBUG] provider: using plugin: version=5
2024-01-16T10:23:24.225+0100 [DEBUG] No provider meta schema returned
2024-01-16T10:23:24.230+0100 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/integrations/github\"]" changed the config value, but that value is unused
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [INFO] Selecting owner  from GITHUB_OWNER environment variable
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [INFO] Setting write_delay_ms to 1000
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [DEBUG] Setting read_delay_ms to 0
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [DEBUG] Setting parallel_requests to false
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [DEBUG] GitHub API Request Details:
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ REQUEST ]---------------------------------------
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: GET /orgs/solomno HTTP/1.1
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Host: api.github.com
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: User-Agent: go-github/v57.0.0
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept: application/vnd.github.surtur-preview+json,application/vnd.github.stone-crop-preview+json
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Api-Version: 2022-11-28
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept-Encoding: gzip
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.231+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:24.623+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [DEBUG] GitHub API Response Details:
2024-01-16T10:23:24.623+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ RESPONSE ]--------------------------------------
2024-01-16T10:23:24.624+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: HTTP/2.0 200 OK
(- REDACTED - Success )
2024-01-16T10:23:24.628+0100 [INFO]  Starting apply for github_app_installation_repository.sync_infra_app2
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: }
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:24.629+0100 [DEBUG] github_app_installation_repositories.sync_infra_app: applying the planned Create change
2024-01-16T10:23:24.629+0100 [DEBUG] github_app_installation_repository.sync_infra_app2: applying the planned Create change
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [DEBUG] GitHub API Request Details:
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ REQUEST ]---------------------------------------
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: GET /repos/solomno/sharing HTTP/1.1
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Host: api.github.com
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: User-Agent: go-github/v57.0.0
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept: application/vnd.github.scarlet-witch-preview+json, application/vnd.github.mercy-preview+json, application/vnd.github.baptiste-preview+json, application/vnd.github.nebula-preview+json,application/vnd.github.stone-crop-preview+json
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Api-Version: 2022-11-28
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept-Encoding: gzip
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:24 [DEBUG] GitHub API Request Details:
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ REQUEST ]---------------------------------------
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: GET /user/installations/123456789/repositories?per_page=100 HTTP/1.1
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Host: api.github.com
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: User-Agent: go-github/v57.0.0
2024-01-16T10:23:24.629+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept: application/vnd.github.mercy-preview+json, application/vnd.github.nebula-preview+json, application/vnd.github.baptiste-preview+json,application/vnd.github.stone-crop-preview+json
2024-01-16T10:23:24.630+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Api-Version: 2022-11-28
2024-01-16T10:23:24.630+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept-Encoding: gzip
2024-01-16T10:23:24.630+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.630+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:24.630+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:25.000+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:25 [DEBUG] GitHub API Response Details:
2024-01-16T10:23:25.000+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ RESPONSE ]--------------------------------------
2024-01-16T10:23:25.000+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: HTTP/2.0 200 OK
(- REDACTED - Succcess)
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:25 [DEBUG] GitHub API Request Details:
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ REQUEST ]---------------------------------------
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: PUT /user/installations/123456789/repositories/705227863 HTTP/1.1
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Host: api.github.com
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: User-Agent: go-github/v57.0.0
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Content-Length: 0
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept: application/vnd.github.v3+json,application/vnd.github.stone-crop-preview+json
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Api-Version: 2022-11-28
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Accept-Encoding: gzip
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:25.007+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:25.164+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:25 [DEBUG] GitHub API Response Details:
2024-01-16T10:23:25.164+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ RESPONSE ]--------------------------------------
2024-01-16T10:23:25.165+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: HTTP/2.0 403 Forbidden
2024-01-16T10:23:25.165+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Access-Control-Allow-Origin: *
2024-01-16T10:23:25.165+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
2024-01-16T10:23:25.165+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Content-Security-Policy: default-src 'none'
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Content-Type: application/json; charset=utf-8
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Date: Tue, 16 Jan 2024 09:23:25 GMT
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Github-Authentication-Token-Expiration: 2024-02-15 10:05:03 +0100
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Server: GitHub.com
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Vary: Accept-Encoding, Accept, X-Requested-With
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Accepted-Github-Permissions: metadata=read
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Content-Type-Options: nosniff
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Frame-Options: deny
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Api-Version-Selected: 2022-11-28
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Media-Type: github.mercy-preview; param=nebula-preview.baptiste-preview; format=json, github.stone-crop-preview; format=json
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Request-Id: 7533:3E649A:31838A6:322CD59:65A64B0D
2024-01-16T10:23:25.166+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Limit: 5000
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Remaining: 4871
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Reset: 1705399023
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Resource: core
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Used: 129
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Xss-Protection: 0
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: {
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe:  "message": "Resource not accessible by personal access token",
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe:  "documentation_url": "https://docs.github.com/rest/apps/installations#list-repositories-accessible-to-the-user-access-token"
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: }
2024-01-16T10:23:25.167+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:25.170+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-01-16T10:23:25.170+0100 [ERROR] vertex "github_app_installation_repositories.sync_infra_app" error: GET https://api.github.com/user/installations/123456789/repositories?per_page=100: 403 Resource not accessible by personal access token []
2024-01-16T10:23:25.428+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: 2024/01/16 10:23:25 [DEBUG] GitHub API Response Details:
2024-01-16T10:23:25.428+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: ---[ RESPONSE ]--------------------------------------
2024-01-16T10:23:25.428+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: HTTP/2.0 403 Forbidden
2024-01-16T10:23:25.428+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Access-Control-Allow-Origin: *
2024-01-16T10:23:25.429+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
2024-01-16T10:23:25.429+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Content-Security-Policy: default-src 'none'
2024-01-16T10:23:25.429+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Content-Type: application/json; charset=utf-8
2024-01-16T10:23:25.429+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Date: Tue, 16 Jan 2024 09:23:25 GMT
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Github-Authentication-Token-Expiration: 2024-02-15 10:05:03 +0100
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Server: GitHub.com
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: Vary: Accept-Encoding, Accept, X-Requested-With
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Content-Type-Options: nosniff
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Frame-Options: deny
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Api-Version-Selected: 2022-11-28
2024-01-16T10:23:25.430+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Media-Type: github.v3; format=json, github.stone-crop-preview; format=json
2024-01-16T10:23:25.431+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Github-Request-Id: 7533:3E649A:318397C:322CE1F:65A64B0D
2024-01-16T10:23:25.431+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Limit: 5000
2024-01-16T10:23:25.431+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Remaining: 4870
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Reset: 1705399023
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Resource: core
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Ratelimit-Used: 130
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: X-Xss-Protection: 0
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: {
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe:  "message": "Resource not accessible by personal access token",
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe:  "documentation_url": "https://docs.github.com/rest/apps/installations#add-a-repository-to-an-app-installation"
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: }
2024-01-16T10:23:25.432+0100 [DEBUG] provider.terraform-provider-github_v5.44.0.exe: -----------------------------------------------------
2024-01-16T10:23:25.433+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-01-16T10:23:25.433+0100 [ERROR] vertex "github_app_installation_repository.sync_infra_app2" error: PUT https://api.github.com/user/installations/123456789/repositories/705227863: 403 Resource not accessible by personal access token []
╷
│ Error: GET https://api.github.com/user/installations/123456789/repositories?per_page=100: 403 Resource not accessible by personal access token []
│
│   with github_app_installation_repositories.sync_infra_app,
│   on main.tf line 38, in resource "github_app_installation_repositories" "sync_infra_app":
│   38: resource "github_app_installation_repositories" "sync_infra_app" {
│
╵
╷
│ Error: PUT https://api.github.com/user/installations/123456789/repositories/705227863: 403 Resource not accessible by personal access token []
│
│   with github_app_installation_repository.sync_infra_app2,
│   on main.tf line 43, in resource "github_app_installation_repository" "sync_infra_app2":
│   43: resource "github_app_installation_repository" "sync_infra_app2" {
│
╵
2024-01-16T10:23:25.438+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-01-16T10:23:25.459+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/integrations/github/5.44.0/windows_amd64/terraform-provider-github_v5.44.0.exe pid=37912
2024-01-16T10:23:25.459+0100 [DEBUG] provider: plugin exited

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    Status: Triage
    Type: Bug
    on Jan 16, 2024
  2. kfcampbell commented on Jan 19, 2024

    @kfcampbell
    Contributor

    @audunsolemdal this is an API behavior, not the Terraform provider, though we could certainly stand to document it better here. The API docs say:

    You must use a personal access token (which you can create via the command line or Basic Authentication) to access this endpoint.

  3. added
    Type: Support
    and removed
    Type: Bug
    Status: Triage
    on Jan 19, 2024
  4. audunsolemdal commented on Jan 23, 2024

    @audunsolemdal
    Author

    I am aware that Github apps cannot use this endpoint, but I am using a personal access token. "Fine-grained". I do not think the sentence you refer to in docs directly covers this.

    image
  5. kfcampbell commented on Jan 23, 2024

    @kfcampbell
    Contributor

    Ahh you're right, I've misread, sorry. It still is an API issue, however: fine-grained tokens support only limited Apps endpoints.

  6. moved this from 🆕 Triage to 🛑 Blocked/Awaiting Response in 🧰 Octokit Activeon Feb 5, 2024
  7. brett-swan-sh commented on May 23, 2024

    @brett-swan-sh

    Hey there, wanted to bump this.

    This endpoint's documentation is super frustrating because it explicitly says all the ways you can't authenticate to the endpoint, but makes no mention of how you can actually use the endpoint.

    https://docs.github.com/en/rest/apps/installations?apiVersion=2022-11-28#add-a-repository-to-an-app-installation

    Additionally the current docs for the provider resource make no mention of any of these constraints. Anybody know if it's actually possible to manage app installations on repos through TF right now? I would assume yes since there's a resource for it... but I can't figure it out. Thanks in advance!

  8. iniinikoski commented on Aug 20, 2024

    @iniinikoski

    Good question @brett-swan-sh ! Bumping this as well, as managing GitHub Apps with Terraform would be highly useful.

  9. sota1235 commented on Oct 23, 2024

    @sota1235

    I found other endpoint to get GitHub app installations, but it's for organization.

    https://docs.github.com/ja/rest/orgs/orgs?apiVersion=2022-11-28#list-app-installations-for-an-organization

    In my use case, I wanna manage GitHub App on organization and this endpoint supports IAT(GitHub App installation token and fin-grained PAT). Maybe the resource like github_organization_app_installation_repository should be implemented...?

  10. github-actions commented on Jul 21, 2025

    @github-actions

    👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

  11. added
    Status: Stale
    on Jul 21, 2025
  12. hanikesn commented on Jul 21, 2025

    @hanikesn

    not stale

  13. removed
    Status: Stale
    on Jul 22, 2025
  14. deiga commented on Jan 18, 2026

    @deiga
    Collaborator

    Hey there, wanted to bump this.

    This endpoint's documentation is super frustrating because it explicitly says all the ways you can't authenticate to the endpoint, but makes no mention of how you can actually use the endpoint.

    docs.github.com/en/rest/apps/installations?apiVersion=2022-11-28#add-a-repository-to-an-app-installation

    Additionally the current docs for the provider resource make no mention of any of these constraints. Anybody know if it's actually possible to manage app installations on repos through TF right now? I would assume yes since there's a resource for it... but I can't figure it out. Thanks in advance!

    At least now the API docs clearly state the requirements!

    This endpoint only works for PATs (classic) with the repo scope.

    Fine-grained access tokens for "Add a repository to an app installation"
    This endpoint does not work with GitHub App user access tokens, GitHub App installation access tokens, or fine-grained personal access tokens.

  15. NiklasRosenstein commented on Apr 15, 2026

    @NiklasRosenstein

    Using the PAT with repo scope works to create the resource, but then the read fails with

    │ Error: GET https://api.github.com/user/installations/124008724/repositories?per_page=100: 403 You must authenticate with an access token authorized to a GitHub App, a personal access token, or basic auth in order to list repositories for an installation. []
    │
    │   with github_app_installation_repository.renovate["python-metacontroller-api"],
    │   on repositories.tf line 96, in resource "github_app_installation_repository" "renovate":
    │   96: resource "github_app_installation_repository" "renovate" {
    │
    ╵
    

    I'm confused what kind of token I should be using to use this resource?

  16. deiga commented on Apr 16, 2026

    @deiga
    Collaborator
  17. lowlostrong commented on Jun 3, 2026

    @lowlostrong

    👋
    We're currently using GitHub App auth for most operations, but managing GitHub App installations via Terraform appears to require a classic PAT.

    We recently tried switching to a fine-grained PAT and Terraform failed with:

    403 Resource not accessible by personal access token

    Unfortunately, maintaining a classic PAT is not compatible with our current organizational security policies, so we're trying to understand what the supported path forward is here.

    Am I missing something, or is there currently no supported path for managing GitHub App installations with a fine-grained PAT? If not, is there a recommended alternative approach or any plans to support it in the future?

  18. deiga commented on Jun 3, 2026

    @deiga
    Collaborator

    @lowlostrong Please reach out to GitHub customer support or your company's sales rep to raise this issue.

    On the Terraform provider level we have no influence on the API design of GitHub.
    Even less so, since we don't work for GitHub 😬

  19. pennello commented on Jul 16, 2026

    @pennello

    Ugh, we ran into this as well. We ended up filing a support ticket on GitHub (#4576944, 2026-07-16).

    Same symptoms as #2103 (comment): github_app_installation_repositories fails at plan/import on GET /user/installations/{id}/repositories with 403, using a classic PAT owned by an org owner.

    A little more detail, if it's helpful. The x-accepted-oauth-scopes response header from the endpoint says read:user and user, but a classic PAT with those still fails. 403, "a personal access token" is acceptable, etc. So all of the error message, and the scopes header, and the documentation (which still says PUT/DELETE works with classic PATs + repo) all kind of mislead you. Fine-grained PATs are also rejected ("Resource not accessible by personal access token") because the endpoints aren't explicitly in the supported list.

    What we think: no token type in an org. will be able to work for the read anymore. (Until they fix this… : - )

  20. added
    Status: Blocked
    on Jul 16, 2026
  21. changed the title [-][BUG]: github_app_installation_repository does not work with fine grained personal access tokens[/-] [+][BLOCK]: github_app_installation_repository does not work with fine grained personal access tokens[/+] on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: BlockedType: Support

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions