|
| 1 | +# Ephemeral Multi-Architecture Prebuilt Runners |
| 2 | + |
| 3 | +This example demonstrates how to create GitHub action runners with the following features: |
| 4 | + |
| 5 | +- **Ephemeral Runners**: Runners are used for one job only and terminated after completion |
| 6 | +- **Multi-Architecture Support**: Configures both x64 and ARM64 runners |
| 7 | +- **Prebuilt AMIs**: Uses custom prebuilt AMIs for faster startup times |
| 8 | +- **DynamoDB Storage**: Uses DynamoDB instead of Parameter Store to avoid rate limiting issues |
| 9 | +- **Cleanup for Offline Runners**: Includes a lambda to clean up registered offline runners from the organization |
| 10 | + |
| 11 | +## Usages |
| 12 | + |
| 13 | +Steps for the full setup, such as creating a GitHub app can be found in the [docs](https://github-aws-runners.github.io/terraform-aws-github-runner/getting-started/). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case. |
| 14 | + |
| 15 | +> The default example assumes local built lambda's available. Ensure you have built the lambda's. Alternatively you can download the lambda's. The version needs to be set to a GitHub release version, see https://github.com/github-aws-runners/terraform-aws-github-runner/releases |
| 16 | +
|
| 17 | +```bash |
| 18 | +cd ../lambdas-download |
| 19 | +terraform init |
| 20 | +terraform apply -var=module_version=<VERSION> |
| 21 | +cd - |
| 22 | +``` |
| 23 | + |
| 24 | + |
| 25 | +### Packer Images |
| 26 | + |
| 27 | +You will need to build your images for both x64 and ARM64 architectures. This example deployment uses the images in `/images/linux-al2023`. You must build these images with packer in your AWS account first. Once you have built them, you need to provide your owner ID as a variable. |
| 28 | + |
| 29 | +### Deploy |
| 30 | + |
| 31 | +Before running Terraform, ensure the GitHub app is configured. See the [configuration details](https://github-aws-runners.github.io/terraform-aws-github-runner/configuration/#ephemeral-runners) for more details. |
| 32 | + |
| 33 | +```bash |
| 34 | +terraform init |
| 35 | +terraform apply |
| 36 | +``` |
| 37 | + |
| 38 | + |
| 39 | +The module will try to update the GitHub App webhook and secret (only linux/mac). You can receive the webhook details by running: |
| 40 | + |
| 41 | +```bash |
| 42 | +terraform output webhook_secret |
| 43 | +``` |
| 44 | + |
| 45 | + |
| 46 | +## Features |
| 47 | + |
| 48 | +### Ephemeral Runners |
| 49 | + |
| 50 | +Ephemeral runners are used for one job only. Each job requires a fresh instance. This feature should be used in combination with the `workflow_job` event. See GitHub webhook endpoint configuration in the documentation. |
| 51 | + |
| 52 | +### Multi-Architecture Support |
| 53 | + |
| 54 | +This example configures both x64 and ARM64 runners with appropriate labels. The module will decide the runner for the workflow job based on the match in the labels defined in the workflow job and runner configuration. |
| 55 | + |
| 56 | +### DynamoDB Storage |
| 57 | + |
| 58 | +This example uses DynamoDB instead of Parameter Store to store runner configuration and state. This helps avoid rate limiting issues that can occur with Parameter Store when managing many runners. |
| 59 | + |
| 60 | +### Cleanup for Offline Runners |
| 61 | + |
| 62 | +The example includes a lambda function that periodically checks for and removes registered offline runners from the organization. This is particularly useful for handling cases where spot instances are terminated by AWS while still running a job. |
| 63 | + |
| 64 | +<!-- BEGIN_TF_DOCS --> |
| 65 | +## Requirements |
| 66 | + |
| 67 | +| Name | Version | |
| 68 | +|------|---------| |
| 69 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 | |
| 70 | +| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.27 | |
| 71 | +| <a name="requirement_local"></a> [local](#requirement\_local) | ~> 2.0 | |
| 72 | +| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.0 | |
| 73 | + |
| 74 | +## Providers |
| 75 | + |
| 76 | +| Name | Version | |
| 77 | +|------|---------| |
| 78 | +| <a name="provider_random"></a> [random](#provider\_random) | 3.6.3 | |
| 79 | + |
| 80 | +## Modules |
| 81 | + |
| 82 | +| Name | Source | Version | |
| 83 | +|------|--------|---------| |
| 84 | +| <a name="module_base"></a> [base](#module\_base) | ../base | n/a | |
| 85 | +| <a name="module_runners"></a> [runners](#module\_runners) | ../../modules/multi-runner | n/a | |
| 86 | +| <a name="module_webhook_github_app"></a> [webhook\_github\_app](#module\_webhook\_github\_app) | ../../modules/webhook-github-app | n/a | |
| 87 | + |
| 88 | +## Resources |
| 89 | + |
| 90 | +| Name | Type | |
| 91 | +|------|------| |
| 92 | +| [random_id.random](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource | |
| 93 | + |
| 94 | +## Inputs |
| 95 | + |
| 96 | +| Name | Description | Type | Default | Required | |
| 97 | +|------|-------------|------|---------|:--------:| |
| 98 | +| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region to deploy to | `string` | `"eu-west-1"` | no | |
| 99 | +| <a name="input_environment"></a> [environment](#input\_environment) | Environment name, used as prefix | `string` | `null` | no | |
| 100 | +| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub for API usages. | <pre>object({<br/> id = string<br/> key_base64 = string<br/> })</pre> | n/a | yes | |
| 101 | + |
| 102 | +## Outputs |
| 103 | + |
| 104 | +| Name | Description | |
| 105 | +|------|-------------| |
| 106 | +| <a name="output_webhook_endpoint"></a> [webhook\_endpoint](#output\_webhook\_endpoint) | n/a | |
| 107 | +| <a name="output_webhook_secret"></a> [webhook\_secret](#output\_webhook\_secret) | n/a | |
| 108 | +<!-- END_TF_DOCS --> |
0 commit comments