Skip to content

feat: Enterprise-level runners#5096

Open
dmitrykiselev27 wants to merge 2 commits intogithub-aws-runners:mainfrom
dmitrykiselev27:enterprise-level-runner
Open

feat: Enterprise-level runners#5096
dmitrykiselev27 wants to merge 2 commits intogithub-aws-runners:mainfrom
dmitrykiselev27:enterprise-level-runner

Conversation

@dmitrykiselev27
Copy link
Copy Markdown
Contributor

Description

Adds enterprise-level runner registration support. Previously, runners could only be registered at the repository or organization level using GitHub App authentication. This PR introduces a third registration level — enterprise — using PAT-based authentication against the GitHub Enterprise runner management APIs.

Key changes

Terraform

  • New runner_registration_level variable ("repo" | "org" | "enterprise") replaces the boolean enable_organization_runners
  • New enterprise_slug and enterprise_pat variables for enterprise configuration. Supports comma-separated multiple PATs for rate limit distribution.
  • github_app no longer requires key_base64 or id when runner_registration_level = "enterprise" — only webhook_secret is needed. No GitHub App creation required for enterprise runners.

Lambda functions

  • Enterprise code paths added for runner registration, listing, busy-state checks, de-registration, and termination — all using raw client.request() since Octokit's typed helpers don't cover enterprise endpoints
  • New createEnterprisePATClient() in auth.ts reads PAT from SSM and randomly selects one token from a comma-separated list per invocation
  • New resolveRunnerType() helper reads RUNNER_REGISTRATION_LEVEL env var with backward-compatible fallback to the legacy ENABLE_ORGANIZATION_RUNNERS

Test Plan

  1. Create PAT with the manage_runners:enterprise scope.
  2. Create webhook on Enterprise level. Events: select Workflow jobs only
  3. Set required Terraform variables:
runner_registration_level = "enterprise"
enterprise_slug = "<your-enterprise-slug>"   
enterprise_pat = {
  pat = "<your-PAT>"                                  
}
  1. Deploy the module
  2. Trigger GHA workflow to test

Related Issues

@dmitrykiselev27 dmitrykiselev27 force-pushed the enterprise-level-runner branch 3 times, most recently from 669630b to 1313567 Compare April 8, 2026 16:42
@edersonbrilhante
Copy link
Copy Markdown
Contributor

What is the rate limit for this type of pat? Maybe allow multiple pat and set some round robin logic. There is an open pr to support multiple apps for this reason.

@dmitrykiselev27
Copy link
Copy Markdown
Contributor Author

@edersonbrilhante as usual, 5000 requests/hour. For this reason, in this implementation pat string can be a comma-separated list.

When a function creates EnterprisePATClient it takes a random token from the list.
It's not the most clever logic, I know, but to properly implement round robin logic, I would need to store some state outside of Lambda function (there is no guarantee Lambda will reuse container for the next execution, also there may be multiple concurrent executions). But I'm open to feedback on this topic

@dmitrykiselev27 dmitrykiselev27 force-pushed the enterprise-level-runner branch from 36fd927 to 8b9e1c7 Compare April 9, 2026 08:44
@dmitrykiselev27 dmitrykiselev27 marked this pull request as ready for review April 9, 2026 09:20
@dmitrykiselev27 dmitrykiselev27 requested review from a team as code owners April 9, 2026 09:20
@Brend-Smits
Copy link
Copy Markdown
Contributor

What's the reason for supporting PAT's and not just enterprise github app's?

@dmitrykiselev27
Copy link
Copy Markdown
Contributor Author

@Brend-Smits unfortunately, GitHub App on enterprise level does not allow to manage runners.

image

@Brend-Smits
Copy link
Copy Markdown
Contributor

@Brend-Smits unfortunately, GitHub App on enterprise level does not allow to manage runners.

image

Okay thanks! I will try to arrange a test enterprise to be able to test this and get back to you 👍🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants