|
| 1 | +# Enterprise Runner Example |
| 2 | + |
| 3 | +This example demonstrates how to deploy GitHub self-hosted runners at the **Enterprise level** using PAT-based authentication. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **GitHub Enterprise Account** — You need a GitHub Enterprise Cloud account with admin access. |
| 8 | +2. **Enterprise PAT** — Create one or more Personal Access Tokens with the `manage_runners:enterprise` scope: |
| 9 | + - Go to your GitHub account settings → Developer settings → Personal access tokens (classic) |
| 10 | + - Create a new token with the `manage_runners:enterprise` scope |
| 11 | + - Save the token securely — you'll need it for the `enterprise_pat` variable |
| 12 | + - **Tip**: To distribute API calls and avoid rate limiting, create multiple PATs (from different accounts if possible) and provide them as a comma-separated string. The Lambda functions will randomly select one PAT per invocation. |
| 13 | +3. **Enterprise Webhook** — Configure an enterprise-level webhook to send `workflow_job` events to the module's webhook endpoint. Choose a random secret for the webhook — you'll need it for the `webhook_secret` parameter. |
| 14 | + |
| 15 | +> **Note**: Enterprise runners do **not** require a GitHub App. Only a webhook secret is needed to verify incoming webhook payloads. The PAT handles all GitHub API interactions. |
| 16 | +
|
| 17 | +## Configuration |
| 18 | + |
| 19 | +```hcl |
| 20 | +module "runners" { |
| 21 | + source = "../../" |
| 22 | +
|
| 23 | + # Enterprise runner registration |
| 24 | + runner_registration_level = "enterprise" |
| 25 | + enterprise_slug = "my-enterprise" |
| 26 | +
|
| 27 | + # Enterprise PAT — stored in AWS SSM Parameter Store as SecureString |
| 28 | + # Single PAT: |
| 29 | + enterprise_pat = { |
| 30 | + pat = var.enterprise_pat |
| 31 | + } |
| 32 | +
|
| 33 | + # Multiple PATs (comma-separated) for rate limit distribution: |
| 34 | + # enterprise_pat = { |
| 35 | + # pat = "ghp_token1,ghp_token2,ghp_token3" |
| 36 | + # } |
| 37 | +
|
| 38 | + # No GitHub App is required for enterprise runners. |
| 39 | + # Only the webhook_secret is needed to verify incoming webhook payloads. |
| 40 | + github_app = { |
| 41 | + webhook_secret = random_id.random.hex |
| 42 | + } |
| 43 | +
|
| 44 | + # ... other configuration |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +## Variables |
| 49 | + |
| 50 | +| Name | Description | Type | Required | |
| 51 | +|------|-------------|------|----------| |
| 52 | +| `enterprise_slug` | The slug of the GitHub Enterprise account | string | Yes | |
| 53 | +| `enterprise_pat` | PAT with `manage_runners:enterprise` scope | string (sensitive) | Yes | |
| 54 | +| `environment` | Environment name prefix | string | No | |
| 55 | +| `aws_region` | AWS region for deployment | string | No | |
| 56 | + |
| 57 | +The `github_app` block only requires `webhook_secret` — the `key_base64` and `id` fields are **not** needed for enterprise runners. |
| 58 | + |
| 59 | +## Verification |
| 60 | + |
| 61 | +After deployment: |
| 62 | + |
| 63 | +1. Check the webhook endpoint in the Terraform outputs |
| 64 | +2. Configure the enterprise webhook to point to the endpoint |
| 65 | +3. Trigger a workflow run in any repository under the enterprise |
| 66 | +4. Verify runners appear in **Enterprise Settings → Actions → Runners** |
| 67 | + |
| 68 | +## Migration from Organization Runners |
| 69 | + |
| 70 | +If you're migrating from organization-level runners: |
| 71 | + |
| 72 | +```hcl |
| 73 | +# Before |
| 74 | +enable_organization_runners = true |
| 75 | +
|
| 76 | +# After |
| 77 | +runner_registration_level = "enterprise" |
| 78 | +enterprise_slug = "my-enterprise" |
| 79 | +enterprise_pat = { |
| 80 | + pat = var.enterprise_pat |
| 81 | +} |
| 82 | +``` |
0 commit comments