Skip to content

feat: add data sources for listing GitHub App installations in an organization#2573

Merged
stevehipwell merged 1 commit intointegrations:mainfrom
atilsensalduz:main
Feb 20, 2026
Merged

feat: add data sources for listing GitHub App installations in an organization#2573
stevehipwell merged 1 commit intointegrations:mainfrom
atilsensalduz:main

Conversation

@atilsensalduz
Copy link
Copy Markdown
Contributor

@atilsensalduz atilsensalduz commented Feb 23, 2025

Resolves #2966
Resolves #2570


This PR introduces a new data source, github_app_installations, to enable listing all installed GitHub Apps within an organization. This addition enhances integration with existing resources such as github_app_installation_repository, providing better automation and management capabilities for GitHub App permissions.

What's New?
New Data Source: github_app_installations
Allows fetching all installed GitHub Apps in an organization:

data "github_organization_app_installations" "all_apps" {}

Example Use Case:
This data source can be integrated with the github_app_installation_repository resource to manage app permissions on specific repositories:

# Local value to find the correct app installation by slug
locals {
  # Find the index of the desired app by its slug
  app_index = index(
    data.github_organization_app_installations.all_apps.installations[*].slug,
    "desired-app-name"  # Replace with your actual app slug
  )
  
  # Get the app_id using the found index
  app_installation_id = data.github_organization_app_installations.all_apps.installations[local.app_index].id
}

# Link the repository to the app installation
resource "github_app_installation_repository" "some_app_repo" {
  installation_id = local.app_installation_id
  repository     = github_repository.some_repo.name
}

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

Related Issue: #2570

@atilsensalduz atilsensalduz changed the title feat: Add data sources for listing GitHub App installations in an organization feat: add data sources for listing GitHub App installations in an organization Feb 23, 2025
@nickfloyd nickfloyd moved this from 🆕 Triage to 👀 In review in 🧰 Octokit Active Feb 27, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Dec 6, 2025

👋 Hey Friends, this pull request 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!

@github-actions github-actions Bot added the Status: Stale Used by stalebot to clean house label Dec 6, 2025
Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

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

Hey 👋

Thank you for your contribution!

I've requested a few changes to make this fit into the provider even better :)

Comment thread github/data_source_github_organization_app_installations.go
Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations.go
@github-project-automation github-project-automation Bot moved this from 👀 In review to 🏗 In progress in 🧰 Octokit Active Dec 10, 2025
@deiga
Copy link
Copy Markdown
Collaborator

deiga commented Jan 15, 2026

@atilsensalduz Please rebase and go through the comments

@atilsensalduz
Copy link
Copy Markdown
Contributor Author

@atilsensalduz Please rebase and go through the comments

Hey @deiga , apologies for the late reply. I somehow missed this PR. Thanks so much for the review! I’ve worked through your suggestions.

@atilsensalduz
Copy link
Copy Markdown
Contributor Author

Hi @deiga , I've changed the PR according to your suggestions. Could you please take a look again when you have time? Thanks in advance.

@atilsensalduz atilsensalduz requested a review from deiga January 16, 2026 11:41
Comment thread github/data_source_github_organization_app_installations.go
Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations_test.go Outdated
Comment thread github/data_source_github_organization_app_installations_test.go Outdated
@atilsensalduz atilsensalduz requested a review from deiga January 16, 2026 13:37
@stevehipwell stevehipwell added this to the v6.11.0 Release milestone Jan 16, 2026
@stevehipwell stevehipwell added Type: Feature New feature or request New data source and removed Status: Stale Used by stalebot to clean house labels Jan 16, 2026
diofeher
diofeher previously approved these changes Jan 16, 2026
@stevehipwell
Copy link
Copy Markdown
Collaborator

@atilsensalduz could you please rebase this PR?

@atilsensalduz atilsensalduz force-pushed the main branch 2 times, most recently from e627a5e to 932e047 Compare January 30, 2026 14:30
Copy link
Copy Markdown
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 @atilsensalduz, I've added a couple of comments. Could you also add support for single_file_paths, created_at & updated_at.

Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations.go Outdated
Comment thread github/data_source_github_organization_app_installations.go Outdated
@stevehipwell
Copy link
Copy Markdown
Collaborator

@atilsensalduz this is looking good. Have you run the test locally, if so could you please attach a screenshot of the output?

@atilsensalduz
Copy link
Copy Markdown
Contributor Author

@atilsensalduz this is looking good. Have you run the test locally, if so could you please attach a screenshot of the output?

Hi @stevehipwell, I've added test outputs as a screenshot.

image image image

@deiga deiga requested a review from stevehipwell February 10, 2026 10:08
@deiga
Copy link
Copy Markdown
Collaborator

deiga commented Feb 14, 2026

Please rebase

@atilsensalduz atilsensalduz force-pushed the main branch 2 times, most recently from adc05f1 to dfc63ea Compare February 14, 2026 12:13
@atilsensalduz
Copy link
Copy Markdown
Contributor Author

Please rebase

Hey @deiga , I've rebased now.

@deiga
Copy link
Copy Markdown
Collaborator

deiga commented Feb 14, 2026

Please run tests and linters and fix any issues

@atilsensalduz
Copy link
Copy Markdown
Contributor Author

Please run tests and linters and fix any issues

Hey @deiga , I ran tests and linters, everything looks good in my local

Comment thread github/data_source_github_organization_app_installations_test.go Outdated
Copy link
Copy Markdown
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.

LGTM

Comment thread github/data_source_github_organization_app_installations_test.go Outdated
@atilsensalduz
Copy link
Copy Markdown
Contributor Author

atilsensalduz commented Feb 17, 2026

Hey @stevehipwell , thanks for the suggestion to use getTestMeta(). I wasn't aware of this function. It was really helpful for adding a proper pre-check that skips the test when no GitHub App installations are found in the org, instead of relying on an implicit assumption.

=== RUN   TestAccGithubOrganizationAppInstallations
=== RUN   TestAccGithubOrganizationAppInstallations/basic
    data_source_github_organization_app_installations_test.go:18: Skipping because no GitHub App installations found in the test organization
--- PASS: TestAccGithubOrganizationAppInstallations (0.73s)
    --- SKIP: TestAccGithubOrganizationAppInstallations/basic (0.73s)
PASS
ok      github.com/integrations/terraform-provider-github/v6/github     1.445s

Copy link
Copy Markdown
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 @atilsensalduz, nearly there.

Comment thread github/data_source_github_organization_app_installations_test.go Outdated
@atilsensalduz atilsensalduz force-pushed the main branch 2 times, most recently from 34d65c3 to 9989ff0 Compare February 17, 2026 12:37
stevehipwell
stevehipwell previously approved these changes Feb 17, 2026
Copy link
Copy Markdown
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.

LGTM

@atilsensalduz
Copy link
Copy Markdown
Contributor Author

I've fixed linting issue. Could you please rerun the CI? @stevehipwell

Copy link
Copy Markdown
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.

LGTM

@stevehipwell stevehipwell merged commit 8646f3c into integrations:main Feb 20, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in 🧰 Octokit Active Feb 20, 2026
@stevehipwell stevehipwell linked an issue Feb 20, 2026 that may be closed by this pull request
1 task
JiayangZhou pushed a commit to JiayangZhou/terraform-provider-github that referenced this pull request Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New data source Type: Feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: github_app data source should obtain the app installation ID [FEAT]: List installed GitHub Apps in an organization

5 participants