Skip to content

Conversation

@elliotwms
Copy link

@elliotwms elliotwms commented Jan 20, 2026

Resolves #3102


Before the change?

  • It was not possible to provide a repositories argument to the github_app_token data source

After the change?

  • It is now possible to provide a repositories argument to the github_app_token data source

Proof of work

Tested using examples/github_app_token:

  • Created an output to get the token
  • Used the token to fetch a scoped repo ✅
  • Used the token to fetch a non-scoped repo ❌
➜  app_token git:(token-repositories) ✗ terraform plan
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - integrations/github in /Users/elliot/go/bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
data.github_app_token.this: Reading...
data.github_app_token.scoped[0]: Reading...
data.github_app_token.this: Read complete after 0s [id=id]
data.github_app_token.scoped[0]: Read complete after 0s [id=id]

Changes to Outputs:
  + token = "***"

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.
➜  app_token git:(token-repositories) ✗ curl -s -H "Authorization: token ***" https://api.github.com/repos/elliotwms/emojistats -w "%{http_code}"
{
  ...
}
200%                                                                                                                                                                                                                                                                                                               ➜  app_token git:(token-repositories) ✗

➜  app_token git:(token-repositories) ✗ curl -s -H "Authorization: token ***" https://api.github.com/repos/elliotwms/infra -w "%{http_code}"
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/repos/repos#get-a-repository",
  "status": "404"
}
404%

Pull request checklist

  • Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

elliotwms and others added 3 commits January 20, 2026 01:10
Allow scoping installation access tokens to specific repositories
by passing the optional repositories parameter to the GitHub API.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@elliotwms elliotwms marked this pull request as ready for review January 20, 2026 18:45
Copy link
Collaborator

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @elliotwms, I've added a couple of review comments.


variable "repositories" {
type = list(string)
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure all your files have valid line endings.

Comment on lines +59 to +64
var repositories []string
if v, ok := d.GetOk("repositories"); ok {
for _, repo := range v.([]any) {
repositories = append(repositories, repo.(string))
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var repositories []string
if v, ok := d.GetOk("repositories"); ok {
for _, repo := range v.([]any) {
repositories = append(repositories, repo.(string))
}
}
var repos []string
if v, ok := d.GetOk("repositories"); ok {
if a, ok := v.([]any); ok {
repos := make([]string, len(a))
for i, r := range a {
if repo, ok := r.(string); ok {
repos[i] = repo
}
}
}
}

This would be a safer pattern.

@deiga deiga added the Type: Feature New feature or request label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add repository scope to github_app_token data source

3 participants