Skip to content

feat: add github_copilot_organization_seat_assignment and github_copilot_team_seat_assignment resources#3462

Open
nitinjain999 wants to merge 4 commits into
integrations:mainfrom
nitinjain999:feat/copilot-seat-assignment
Open

feat: add github_copilot_organization_seat_assignment and github_copilot_team_seat_assignment resources#3462
nitinjain999 wants to merge 4 commits into
integrations:mainfrom
nitinjain999:feat/copilot-seat-assignment

Conversation

@nitinjain999
Copy link
Copy Markdown

@nitinjain999 nitinjain999 commented May 30, 2026

Closes #1629


Before the change?

There was no way to manage or inspect GitHub Copilot configuration via this provider. Organisations had to assign seats and check settings manually through the GitHub UI or call the API directly.

After the change?

Two new resources (require seat management set to assign_selected):

github_copilot_organization_seat_assignment — assigns a Copilot seat to a specific org member:

resource "github_copilot_organization_seat_assignment" "example" {
  username = "someuser"
}

Computed attributes: created_at, pending_cancellation_date, last_activity_at, last_activity_editor, plan_type.

github_copilot_team_seat_assignment — assigns Copilot seats to all members of a team:

resource "github_copilot_team_seat_assignment" "example" {
  team = github_team.example.slug
}

One new data source (works for any org with Copilot enabled, no assign_selected required):

github_copilot_organization_settings — reads org-level Copilot billing settings:

data "github_copilot_organization_settings" "org" {}

output "seat_management" {
  value = data.github_copilot_organization_settings.org.seat_management_setting
}

Attributes: seat_management_setting, public_code_suggestions, seat_breakdown (total, active, pending, etc.).

The data source exists because the GitHub API has no write endpoint for org Copilot settings — they can only be changed via the GitHub UI.

Known limitation — team Read performance: The GitHub API has no single-team Copilot seat lookup endpoint. github_copilot_team_seat_assignment Read paginates through all org seats to find the team entry. For large orgs with many Copilot seats this adds latency on every plan/refresh. This is a GitHub API constraint — if a dedicated endpoint is added in future it can be adopted without a breaking change.

Testing

  • github_copilot_organization_settings data source: acceptance test passes against a real Copilot-enabled org (nitin-sv)
  • github_copilot_organization_seat_assignment and github_copilot_team_seat_assignment: acceptance tests skip automatically when seat management is not set to assign_selected, with a clear message

Pull request checklist

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

Does this introduce a breaking change?

  • Yes
  • No

…lot_team_seat_assignment resources

Closes integrations#1629

Adds two new resources for managing GitHub Copilot seat assignments
when the organization has seat management set to "assign_selected":

- github_copilot_organization_seat_assignment — assigns a Copilot seat
  to a specific org member via AddCopilotUsers / RemoveCopilotUsers
- github_copilot_team_seat_assignment — assigns Copilot seats to all
  members of a team via AddCopilotTeams / RemoveCopilotTeams

Read gracefully handles seats removed outside Terraform by removing
the resource from state. Acceptance tests skip automatically when the
org does not have seat management set to assign_selected.
@github-actions
Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@github-actions github-actions Bot added the Type: Feature New feature or request label May 30, 2026
Nitin Jain added 2 commits May 30, 2026 22:43
…_assignment

Add created_at, pending_cancellation_date, last_activity_at,
last_activity_editor, and plan_type as computed attributes sourced
from GetSeatDetails. Useful for auditing seat usage.
@nitinjain999 nitinjain999 marked this pull request as ready for review May 30, 2026 20:46
Exposes read-only Copilot billing settings for the provider org via
GET /orgs/{org}/copilot/billing: seat_management_setting,
public_code_suggestions, and the full seat_breakdown block.

The GitHub API has no write endpoint for these settings so a resource
is not possible — a data source is the correct primitive here.
Acceptance test verified against a real Copilot-enabled org.
@nitinjain999
Copy link
Copy Markdown
Author

Test results

github_copilot_organization_settings data source — acceptance test passes against a real Copilot Business org.

github_copilot_organization_seat_assignment and github_copilot_team_seat_assignment resources — tests skip automatically when the org's seat management is not set to assign_selected. This is intentional and expected — the GitHub API returns a 422 for seat operations when the org uses "All members" mode.


Instructions to fully verify the seat assignment resources

Prerequisites:

  • A GitHub org with Copilot Business or Enterprise
  • Seat management set to Selected members only: https://github.com/organizations/<your-org>/settings/copilot/seat_management
  • A PAT or gh auth token with admin:org + read:org + repo scopes
  • A member in the org to use as GH_TEST_ORG_USER
export TF_ACC=1
export GH_TEST_AUTH_MODE=organization
export GITHUB_OWNER=<your-org>
export GITHUB_USERNAME=<your-username>
export GITHUB_TOKEN=$(gh auth token)   # or a PAT
export GH_TEST_ORG_USER=<an-org-member>

make testacc T=TestAccGithubCopilot

Expected output when fully configured:

--- PASS: TestAccGithubCopilotOrganizationSeatAssignment/assigns_and_removes_a_Copilot_seat_for_a_user
--- PASS: TestAccGithubCopilotTeamSeatAssignment/assigns_and_removes_Copilot_seats_for_a_team

If seat management is not set to assign_selected the tests will skip with:

Skipping: Copilot seat management is "unconfigured", must be "assign_selected"

@nitinjain999 nitinjain999 force-pushed the feat/copilot-seat-assignment branch from 040d60b to e74f2c6 Compare June 3, 2026 08:27
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]: Support Org Copilot settings

2 participants