@cloudsnorkel/cdk-github-runners 0.14.22 β†’ 0.14.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.jsii CHANGED
@@ -3858,7 +3858,7 @@
3858
3858
  },
3859
3859
  "name": "@cloudsnorkel/cdk-github-runners",
3860
3860
  "readme": {
3861
- "markdown": "# GitHub Self-Hosted Runners CDK Constructs\n\n[![NPM](https://img.shields.io/npm/v/@cloudsnorkel/cdk-github-runners?label=npm&logo=npm)][7]\n[![PyPI](https://img.shields.io/pypi/v/cloudsnorkel.cdk-github-runners?label=pypi&logo=pypi)][6]\n[![Maven Central](https://img.shields.io/maven-central/v/com.cloudsnorkel/cdk.github.runners.svg?label=Maven%20Central&logo=apachemaven)][8]\n[![Go](https://img.shields.io/github/v/tag/CloudSnorkel/cdk-github-runners?color=red&label=go&logo=go)][11]\n[![Nuget](https://img.shields.io/nuget/v/CloudSnorkel.Cdk.Github.Runners?color=red&&logo=nuget)][12]\n[![Release](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml/badge.svg)](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/CloudSnorkel/cdk-github-runners/blob/main/LICENSE)\n\nUse this CDK construct to create ephemeral [self-hosted GitHub runners][1] on-demand inside your AWS account.\n\n* 🧩 Easy to configure GitHub integration with a web-based interface\n* 🧠 Customizable runners with decent defaults\n* πŸƒπŸ» Multiple runner configurations controlled by labels\n* πŸ” Everything fully hosted in your account\n* πŸ”ƒ Automatically updated build environment with latest runner version\n\nSelf-hosted runners in AWS are useful when:\n\n* You need easy access to internal resources in your actions\n* You want to pre-install some software for your actions\n* You want to provide some basic AWS API access (but [aws-actions/configure-aws-credentials][2] has more security controls)\n* You are using GitHub Enterprise Server\n\nEphemeral (or on-demand) runners are the [recommended way by GitHub][14] for auto-scaling, and they make sure all jobs run with a clean image. Runners are started on-demand. You don't pay unless a job is running.\n\n## API\n\nThe best way to browse API documentation is on [Constructs Hub][13]. It is available in all supported programming languages.\n\n## Providers\n\nA runner provider creates compute resources on-demand and uses [actions/runner][5] to start a runner.\n\n| | EC2 | CodeBuild | Fargate | ECS | Lambda |\n|------------------|-------------------|----------------------------|----------------|----------------|---------------|\n| **Time limit** | Unlimited | 8 hours | Unlimited | Unlimited | 15 minutes |\n| **vCPUs** | Unlimited | 2, 4, 8, or 72 | 0.25 to 4 | Unlimited | 1 to 6 |\n| **RAM** | Unlimited | 3gb, 7gb, 15gb, or 145gb | 512mb to 30gb | Unlimited | 128mb to 10gb |\n| **Storage** | Unlimited | 50gb to 824gb | 20gb to 200gb | Unlimited | Up to 10gb |\n| **Architecture** | x86_64, ARM64 | x86_64, ARM64 | x86_64, ARM64 | x86_64, ARM64 | x86_64, ARM64 |\n| **sudo** | βœ” | βœ” | βœ” | βœ” | ❌ |\n| **Docker** | βœ” | βœ” (Linux only) | ❌ | βœ” | ❌ |\n| **Spot pricing** | βœ” | ❌ | βœ” | βœ” | ❌ |\n| **OS** | Linux, Windows | Linux, Windows | Linux, Windows | Linux, Windows | Linux |\n\nThe best provider to use mostly depends on your current infrastructure. When in doubt, CodeBuild is always a good choice. Execution history and logs are easy to view, and it has no restrictive limits unless you need to run for more than 8 hours.\n\n* EC2 is useful when you want runners to have complete access to the host\n* ECS is useful when you want to control the infrastructure, like leaving the runner host running for faster startups\n* Lambda is useful for short jobs that can work within time, size and readonly system constraints\n\nYou can also create your own provider by implementing `IRunnerProvider`.\n\n## Installation\n\n1. Install and use the appropriate package\n <details><summary>Python</summary>\n\n ### Install\n Available on [PyPI][6].\n ```bash\n pip install cloudsnorkel.cdk-github-runners\n ```\n ### Use\n ```python\n from aws_cdk import App, Stack\n from cloudsnorkel.cdk_github_runners import GitHubRunners\n\n app = App()\n stack = Stack(app, \"github-runners\")\n GitHubRunners(stack, \"runners\")\n\n app.synth()\n ```\n </details>\n <details><summary>TypeScript or JavaScript</summary>\n\n ### Install\n Available on [npm][7].\n ```bash\n npm i @cloudsnorkel/cdk-github-runners\n ```\n ### Use\n ```typescript\n import { App, Stack } from 'aws-cdk-lib';\n import { GitHubRunners } from '@cloudsnorkel/cdk-github-runners';\n\n const app = new App();\n const stack = new Stack(app, 'github-runners');\n new GitHubRunners(stack, 'runners');\n\n app.synth();\n ```\n </details>\n <details><summary>Java</summary>\n\n ### Install\n Available on [Maven][8].\n ```xml\n <dependency>\n <groupId>com.cloudsnorkel</groupId>\n <artifactId>cdk.github.runners</artifactId>\n </dependency>\n ```\n ### Use\n ```java\n import software.amazon.awscdk.App;\n import software.amazon.awscdk.Stack;\n import com.cloudsnorkel.cdk.github.runners.GitHubRunners;\n\n public class Example {\n public static void main(String[] args){\n App app = new App();\n Stack stack = new Stack(app, \"github-runners\");\n GitHubRunners.Builder.create(stack, \"runners\").build();\n\n app.synth();\n }\n }\n ```\n </details>\n <details><summary>Go</summary>\n\n ### Install\n Available on [GitHub][11].\n ```bash\n go get github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\n ```\n ### Use\n ```go\n package main\n\n import (\n \"github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\"\n \"github.com/aws/aws-cdk-go/awscdk/v2\"\n \"github.com/aws/jsii-runtime-go\"\n )\n\n func main() {\n app := awscdk.NewApp(nil)\n stack := awscdk.NewStack(app, jsii.String(\"github-runners\"), &awscdk.StackProps{})\n cloudsnorkelcdkgithubrunners.NewGitHubRunners(stack, jsii.String(\"runners\"), &cloudsnorkelcdkgithubrunners.GitHubRunnersProps{})\n\n app.Synth(nil)\n }\n ```\n </details>\n <details><summary>.NET</summary>\n\n ### Install\n Available on [Nuget][12].\n ```bash\n dotnet add package CloudSnorkel.Cdk.Github.Runners\n ```\n ### Use\n ```csharp\n using Amazon.CDK;\n using CloudSnorkel;\n\n namespace Example\n {\n sealed class Program\n {\n public static void Main(string[] args)\n {\n var app = new App();\n var stack = new Stack(app, \"github-runners\");\n new GitHubRunners(stack, \"runners\");\n app.Synth();\n }\n }\n }\n ```\n </details>\n2. Use `GitHubRunners` construct in your code (starting with default arguments is fine)\n3. Deploy your stack\n4. Look for the status command output similar to `aws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json`\n ```\n βœ… github-runners-test\n\n ✨ Deployment time: 260.01s\n\n Outputs:\n github-runners-test.runnersstatuscommand4A30F0F5 = aws --region us-east-1 lambda invoke --function-name github-runners-test-runnersstatus1A5771C0-mvttg8oPQnQS status.json\n ```\n5. Execute the status command (you may need to specify `--profile` too) and open the resulting `status.json` file\n6. Open the URL in `github.setup.url` from `status.json` or [manually setup GitHub](SETUP_GITHUB.md) integration as an app or with personal access token\n7. Run status command again to confirm `github.auth.status` and `github.webhook.status` are OK\n8. Trigger a GitHub action that has a `self-hosted` label with `runs-on: [self-hosted, codebuild]` (or non-default labels you set in step 2)\n9. If the action is not successful, see [troubleshooting](#Troubleshooting)\n\n[![Demo](demo-thumbnail.jpg)](https://youtu.be/wlyv_3V8lIw)\n\n## Customizing\n\nThe default providers configured by `GitHubRunners` are useful for testing but probably not too much for actual production work. They run in the default VPC or no VPC and have no added IAM permissions. You would usually want to configure the providers yourself.\n\nFor example:\n\n```typescript\nlet vpc: ec2.Vpc;\nlet runnerSg: ec2.SecurityGroup;\nlet dbSg: ec2.SecurityGroup;\nlet bucket: s3.Bucket;\n\n// create a custom CodeBuild provider\nconst myProvider = new CodeBuildRunnerProvider(this, 'codebuild runner', {\n labels: ['my-codebuild'],\n vpc: vpc,\n securityGroups: [runnerSg],\n});\n// grant some permissions to the provider\nbucket.grantReadWrite(myProvider);\ndbSg.connections.allowFrom(runnerSg, ec2.Port.tcp(3306), 'allow runners to connect to MySQL database');\n\n// create the runner infrastructure\nnew GitHubRunners(this, 'runners', {\n providers: [myProvider],\n});\n```\n\nAnother way to customize runners is by modifying the image used to spin them up. The image contains the [runner][5], any required dependencies, and integration code with the provider. You may choose to customize this image by adding more packages, for example.\n\n```typescript\nconst myBuilder = FargateRunnerProvider.imageBuilder(this, 'image builder');\nmyBuilder.addComponent(\n RunnerImageComponent.custom({ commands: ['apt install -y nginx xz-utils'] }),\n);\n\nconst myProvider = new FargateRunnerProvider(this, 'fargate runner', {\n labels: ['customized-fargate'],\n imageBuilder: myBuilder,\n});\n\n// create the runner infrastructure\nnew GitHubRunners(this, 'runners', {\n providers: [myProvider],\n});\n```\n\nYour workflow will then look like:\n\n```yaml\nname: self-hosted example\non: push\njobs:\n self-hosted:\n runs-on: [self-hosted, customized-fargate]\n steps:\n - run: echo hello world\n```\n\nWindows images can also be customized the same way.\n\n```typescript\nconst myWindowsBuilder = FargateRunnerProvider.imageBuilder(this, 'Windows image builder', {\n architecture: Architecture.X86_64,\n os: Os.WINDOWS,\n});\nmyWindowsBuilder.addComponent(\n RunnerImageComponent.custom({\n name: 'Ninja',\n commands: [\n 'Invoke-WebRequest -UseBasicParsing -Uri \"https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip\" -OutFile ninja.zip',\n 'Expand-Archive ninja.zip -DestinationPath C:\\\\actions',\n 'del ninja.zip',\n ],\n }),\n);\n\nconst myProvider = new FargateRunnerProvider(this, 'fargate runner', {\n labels: ['customized-windows-fargate'],\n imageBuilder: myWindowsBuilder,\n});\n\nnew GitHubRunners(this, 'runners', {\n providers: [myProvider],\n});\n```\n\nThe runner OS and architecture is determined by the image it is set to use. For example, to create a Fargate runner provider for ARM64 set the `architecture` property for the image builder to `Architecture.ARM64` in the image builder properties.\n\n```typescript\nnew GitHubRunners(this, 'runners', {\n providers: [\n new FargateRunnerProvider(this, 'fargate runner', {\n labels: ['arm64', 'fargate'],\n imageBuilder: FargateRunnerProvider.imageBuilder(this, 'image builder', {\n architecture: Architecture.ARM64,\n os: Os.LINUX_UBUNTU,\n }),\n }),\n ],\n});\n```\n\n### Composite Providers\n\nComposite providers allow you to combine multiple runner providers with different strategies. There are two types:\n\n**Fallback Strategy**: Try providers in order until one succeeds. Useful for trying spot instances first, then falling back to on-demand if spot capacity is unavailable.\n\n```typescript\n// Try spot instances first, fall back to on-demand if spot is unavailable\nconst ecsFallback = CompositeProvider.fallback(this, 'ECS Fallback', [\n new EcsRunnerProvider(this, 'ECS Spot', {\n labels: ['ecs', 'linux', 'x64'],\n spot: true,\n // ... other config\n }),\n new EcsRunnerProvider(this, 'ECS On-Demand', {\n labels: ['ecs', 'linux', 'x64'],\n spot: false,\n // ... other config\n }),\n]);\n\nnew GitHubRunners(this, 'runners', {\n providers: [ecsFallback],\n});\n```\n\n**Weighted Distribution Strategy**: Randomly select a provider based on weights. Useful for distributing load across multiple availability zones or instance types.\n\n```typescript\n// Distribute 60% of traffic to AZ-1, 40% to AZ-2\nconst distributedProvider = CompositeProvider.distribute(this, 'Fargate Distribution', [\n {\n weight: 3, // 3/(3+2) = 60%\n provider: new FargateRunnerProvider(this, 'Fargate AZ-1', {\n labels: ['fargate', 'linux', 'x64'],\n subnetSelection: vpc.selectSubnets({\n availabilityZones: [vpc.availabilityZones[0]],\n }),\n // ... other config\n }),\n },\n {\n weight: 2, // 2/(3+2) = 40%\n provider: new FargateRunnerProvider(this, 'Fargate AZ-2', {\n labels: ['fargate', 'linux', 'x64'],\n subnetSelection: vpc.selectSubnets({\n availabilityZones: [vpc.availabilityZones[1]],\n }),\n // ... other config\n }),\n },\n]);\n\nnew GitHubRunners(this, 'runners', {\n providers: [distributedProvider],\n});\n```\n\n**Important**: All providers in a composite must have the exact same labels. This ensures any provisioned runner can match the labels requested by the GitHub workflow job.\n\n### Custom Provider Selection\n\nBy default, providers are selected based on label matching: the first provider that has all the labels requested by the job is selected. You can customize this behavior using a provider selector Lambda function to:\n\n* Filter out certain jobs (prevent runner provisioning)\n* Dynamically select a provider based on job characteristics (repository, branch, time of day, etc.)\n* Customize labels for the runner (add, remove, or modify labels dynamically)\n\nThe selector function receives the full GitHub webhook payload, a map of all available providers and their labels, and the default provider/labels that would have been selected. It returns the provider to use (or `undefined` to skip runner creation) and the labels to assign to the runner.\n\n**Example: Route jobs to different providers based on repository**\n\n```typescript\nimport { ComputeType } from 'aws-cdk-lib/aws-codebuild';\nimport { Function, Code, Runtime } from 'aws-cdk-lib/aws-lambda';\nimport { GitHubRunners, CodeBuildRunnerProvider } from '@cloudsnorkel/cdk-github-runners';\n\nconst defaultProvider = new CodeBuildRunnerProvider(this, 'default', {\n labels: ['custom-runner', 'default'],\n});\nconst productionProvider = new CodeBuildRunnerProvider(this, 'production', {\n labels: ['custom-runner', 'production'],\n computeType: ComputeType.LARGE,\n});\n\nconst providerSelector = new Function(this, 'provider-selector', {\n runtime: Runtime.NODEJS_LATEST,\n handler: 'index.handler',\n code: Code.fromInline(`\n exports.handler = async (event) => {\n const { payload, providers, defaultProvider, defaultLabels } = event;\n\n // Route production repos to dedicated provider\n if (payload.repository.name.includes('prod')) {\n return {\n provider: '${productionProvider.node.path}',\n labels: ['custom-runner', 'production', 'modified-via-selector'],\n };\n }\n\n // Filter out draft PRs\n if (payload.workflow_job.head_branch?.startsWith('draft/')) {\n return { provider: undefined }; // Skip runner provisioning\n }\n\n // Use default for everything else\n return {\n provider: defaultProvider,\n labels: defaultLabels,\n };\n };\n `),\n});\n\nnew GitHubRunners(this, 'runners', {\n providers: [defaultProvider, productionProvider],\n providerSelector: providerSelector,\n});\n```\n\n**Example: Add dynamic labels based on job metadata**\n\n```typescript\nconst providerSelector = new Function(this, 'provider-selector', {\n runtime: Runtime.NODEJS_LATEST,\n handler: 'index.handler',\n code: Code.fromInline(`\n exports.handler = async (event) => {\n const { payload, defaultProvider, defaultLabels } = event;\n\n // Add branch name as a label\n const branch = payload.workflow_job.head_branch || 'unknown';\n const labels = [...(defaultLabels || []), 'branch:' + branch];\n\n return {\n provider: defaultProvider,\n labels: labels,\n };\n };\n `),\n});\n```\n\n**Important considerations:**\n\n* ⚠️ **Label matching responsibility**: You are responsible for ensuring the selected provider's labels match what the job requires. If labels don't match, the runner will be provisioned but GitHub Actions won't assign the job to it.\n* ⚠️ **No guarantee of assignment**: Provider selection only determines which provider will provision a runner. GitHub Actions may still route the job to any available runner with matching labels. For reliable provider assignment, consider repo-level runner registration (the default).\n* ⚑ **Performance**: The selector runs synchronously during webhook processing. Keep it fast and efficientβ€”the webhook has a 30-second timeout total.\n\n## Examples\n\nWe provide comprehensive examples in the [`examples/`](examples/) folder to help you get started quickly:\n\n### Getting Started\n- **[Simple CodeBuild](examples/typescript/simple-codebuild/)** - Basic setup with just a CodeBuild provider (also available in [Python](examples/python/simple-codebuild/))\n\n### Provider Configuration\n- **[Composite Provider](examples/typescript/composite-provider/)** - Fallback and weighted distribution strategies (also available in [Python](examples/python/composite-provider/))\n- **[Provider Selector](examples/typescript/provider-selector/)** - Custom provider selection with Lambda function (also available in [Python](examples/python/provider-selector/))\n- **[EC2 Windows Provider](examples/typescript/ec2-windows-provider/)** - EC2 configuration for Windows runners (also available in [Python](examples/python/ec2-windows-provider/))\n- **[Split Stacks](examples/typescript/split-stacks/)** - Split image builders and providers across multiple stacks (also available in [Python](examples/python/split-stacks/))\n\n### Compute & Performance\n- **[Compute Options](examples/typescript/compute-options/)** - Configure CPU, memory, and instance types for different providers (also available in [Python](examples/python/compute-options/))\n- **[Spot Instances](examples/typescript/spot-instances/)** - Use spot instances for cost savings across EC2, Fargate, and ECS (also available in [Python](examples/python/spot-instances/))\n- **[Storage Options](examples/typescript/storage-options/)** - Custom EBS storage options for EC2 runners (also available in [Python](examples/python/storage-options/))\n- **[ECS Scaling](examples/typescript/ecs-scaling/)** - Custom autoscaling group scaling policies for ECS providers (also available in [Python](examples/python/ecs-scaling/))\n\n### Security & Access\n- **[IAM Permissions](examples/typescript/iam-permissions/)** - Grant AWS IAM permissions to runners (also available in [Python](examples/python/iam-permissions/))\n- **[Network Access](examples/typescript/network-access/)** - Configure network access with VPCs and security groups (also available in [Python](examples/python/network-access/))\n- **[Access Control](examples/typescript/access-control/)** - Configure access control for webhook and setup functions (also available in [Python](examples/python/access-control/))\n\n### Customization\n- **[Add Software](examples/typescript/add-software/)** - Add custom software to runner images (also available in [Python](examples/python/add-software/))\n\n### Enterprise & Monitoring\n- **[GHES](examples/typescript/ghes/)** - Configure runners for GitHub Enterprise Server (also available in [Python](examples/python/ghes/))\n- **[Monitoring](examples/typescript/monitoring/)** - Set up CloudWatch alarms and SNS notifications (also available in [Python](examples/python/monitoring/))\n\nEach example is self-contained with its own dependencies and README. Start with the simple examples and work your way up to more advanced configurations.\n\nAnother good and very full example is the [integration test](test/default.integ.ts).\n\nIf you have more to share, please open a PR adding examples to the `examples` folder.\n\n## Architecture\n\n![Architecture diagram](architecture.svg)\n\n## Troubleshooting\n\nRunners are started in response to a webhook coming in from GitHub. If there are any issues starting the runner like missing capacity or transient API issues, the provider will keep retrying for 24 hours. Configuration issue related errors like pointing to a missing AMI will not be retried. GitHub itself will cancel the job if it can't find a runner for 24 hours. If your jobs don't start, follow the steps below to examine all parts of this workflow.\n\n1. Always start with the status function, make sure no errors are reported, and confirm all status codes are OK\n2. Make sure `runs-on` in the workflow matches the expected labels set in the runner provider\n3. Diagnose relevant executions of the orchestrator step function by visiting the URL in `troubleshooting.stepFunctionUrl` from `status.json`\n 1. If the execution failed, check your runner provider configuration for errors\n 2. If the execution is still running for a long time, check the execution events to see why runner starting is being retried\n 3. If there are no relevant executions, move to the next step\n4. Confirm the webhook Lambda was called by visiting the URL in `troubleshooting.webhookHandlerUrl` from `status.json`\n 1. If it's not called or logs errors, confirm the webhook settings on the GitHub side\n 2. If you see too many errors, make sure you're only sending `workflow_job` events\n5. When using GitHub app, make sure there are active installations in `github.auth.app.installations`\n\nAll logs are saved in CloudWatch.\n* Log group names can be found in `status.json` for each provider, image builder, and other parts of the system\n* Some useful Logs Insights queries can be enabled with `GitHubRunners.createLogsInsightsQueries()`\n\nTo get `status.json`, check out the CloudFormation stack output for a command that generates it. The command looks like:\n\n```\naws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json\n```\n\n## Monitoring\n\nThere are two important ways to monitor your runners:\n\n1. Make sure runners don't fail to start. When that happens, jobs may sit and wait. Use `GitHubRunners.metricFailed()` to get a metric for the number of failed runner starts. You should use this metric to trigger an alarm.\n2. Make sure runner images don't fail to build. Failed runner image builds mean you will get stuck with out-of-date software on your runners. It may lead to security vulnerabilities, or it may lead to slower runner start-ups as the runner software itself needs to be updated. Use `GitHubRunners.failedImageBuildsTopic()` to get SNS topic that gets notified of failed runner image builds. You should subscribe to this topic.\n\nOther useful metrics to track:\n\n1. Use `GitHubRunners.metricJobCompleted()` to get a metric for the number of completed jobs broken down by labels and job success.\n2. Use `GitHubRunners.metricTime()` to get a metric for the total time a runner is running. This includes the overhead of starting the runner.\n\n## Contributing\n\nIf you use and love this project, please consider contributing.\n\n1. πŸͺ³ If you see something, say something. [Issues][16] help improve the quality of the project.\n * Include relevant logs and package versions for bugs.\n * When possible, describe the use-case behind feature requests.\n1. πŸ› οΈ [Pull requests][17] are welcome.\n * Run `npm run build` before submitting to make sure all tests pass.\n * Allow edits from maintainers so small adjustments can be made easily.\n1. πŸ’΅ Consider [sponsoring][15] the project to show your support and optionally get your name listed below.\n\n## Other Options\n\n1. [github-aws-runners/terraform-aws-github-runner][3] if you're using Terraform\n2. [actions/actions-runner-controller][4] if you're using Kubernetes\n\n\n[1]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners\n[2]: https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions\n[3]: https://github.com/github-aws-runners/terraform-aws-github-runner\n[4]: https://github.com/actions/actions-runner-controller\n[5]: https://github.com/actions/runner\n[6]: https://pypi.org/project/cloudsnorkel.cdk-github-runners\n[7]: https://www.npmjs.com/package/@cloudsnorkel/cdk-github-runners\n[8]: https://central.sonatype.com/artifact/com.cloudsnorkel/cdk.github.runners/\n[9]: https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps\n[10]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token\n[11]: https://pkg.go.dev/github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\n[12]: https://www.nuget.org/packages/CloudSnorkel.Cdk.Github.Runners/\n[13]: https://constructs.dev/packages/@cloudsnorkel/cdk-github-runners/\n[14]: https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling\n[15]: https://github.com/sponsors/CloudSnorkel\n[16]: https://github.com/CloudSnorkel/cdk-github-runners/issues\n[17]: https://github.com/CloudSnorkel/cdk-github-runners/pulls\n"
3861
+ "markdown": "# GitHub Self-Hosted Runners CDK Constructs\n\n[![NPM](https://img.shields.io/npm/v/@cloudsnorkel/cdk-github-runners?label=npm&logo=npm)][7]\n[![PyPI](https://img.shields.io/pypi/v/cloudsnorkel.cdk-github-runners?label=pypi&logo=pypi)][6]\n[![Maven Central](https://img.shields.io/maven-central/v/com.cloudsnorkel/cdk.github.runners.svg?label=Maven%20Central&logo=apachemaven)][8]\n[![Go](https://img.shields.io/github/v/tag/CloudSnorkel/cdk-github-runners?color=red&label=go&logo=go)][11]\n[![Nuget](https://img.shields.io/nuget/v/CloudSnorkel.Cdk.Github.Runners?color=red&&logo=nuget)][12]\n[![Release](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml/badge.svg)](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml)\n[![Discord](https://img.shields.io/badge/Discord-5865F2?logo=discord&logoColor=white)][20]\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/CloudSnorkel/cdk-github-runners/blob/main/LICENSE)\n\nUse this CDK construct to create ephemeral [self-hosted GitHub runners][1] on-demand inside your AWS account.\n\n* 🧩 Easy to configure GitHub integration with a web-based interface\n* 🧠 Customizable runners with decent defaults\n* πŸƒπŸ» Multiple runner configurations controlled by labels\n* πŸ” Everything fully hosted in your account\n* πŸ”ƒ Automatically updated build environment with latest runner version\n\nSelf-hosted runners in AWS are useful when:\n\n* You need easy access to internal resources in your actions\n* You want to pre-install some software for your actions\n* You want to provide some basic AWS API access (but [aws-actions/configure-aws-credentials][2] has more security controls)\n* You are using GitHub Enterprise Server\n\nEphemeral (or on-demand) runners are the [recommended way by GitHub][14] for auto-scaling, and they make sure all jobs run with a clean image. Runners are started on-demand. You don't pay unless a job is running.\n\n## Table of Contents\n\n- [API](#api)\n- [Providers](#providers)\n- [Installation](#installation)\n- [Customizing](#customizing)\n - [Composite Providers](#composite-providers)\n - [Custom Provider Selection](#custom-provider-selection)\n- [Examples](#examples)\n- [Architecture](#architecture)\n- [Troubleshooting](#troubleshooting)\n- [Monitoring](#monitoring)\n- [Getting Help](#getting-help)\n- [Contributing](#contributing)\n- [Sponsors](#sponsors)\n- [Other Options](#other-options)\n\n## API\n\nThe best way to browse API documentation is on [Constructs Hub][13]. It is available in all supported programming languages.\n\n## Providers\n\nA runner provider creates compute resources on-demand and uses [actions/runner][5] to start a runner.\n\n| | EC2 | CodeBuild | Fargate | ECS | Lambda |\n|------------------|-------------------|----------------------------|----------------|----------------|---------------|\n| **Time limit** | Unlimited | 8 hours | Unlimited | Unlimited | 15 minutes |\n| **vCPUs** | Unlimited | 2, 4, 8, or 72 | 0.25 to 4 | Unlimited | 1 to 6 |\n| **RAM** | Unlimited | 3gb, 7gb, 15gb, or 145gb | 512mb to 30gb | Unlimited | 128mb to 10gb |\n| **Storage** | Unlimited | 50gb to 824gb | 20gb to 200gb | Unlimited | Up to 10gb |\n| **Architecture** | x86_64, ARM64 | x86_64, ARM64 | x86_64, ARM64 | x86_64, ARM64 | x86_64, ARM64 |\n| **sudo** | βœ” | βœ” | βœ” | βœ” | ❌ |\n| **Docker** | βœ” | βœ” (Linux only) | ❌ | βœ” | ❌ |\n| **Spot pricing** | βœ” | ❌ | βœ” | βœ” | ❌ |\n| **OS** | Linux, Windows | Linux, Windows | Linux, Windows | Linux, Windows | Linux |\n\nThe best provider to use mostly depends on your current infrastructure. When in doubt, CodeBuild is always a good choice. Execution history and logs are easy to view, and it has no restrictive limits unless you need to run for more than 8 hours.\n\n* EC2 is useful when you want runners to have complete access to the host\n* ECS is useful when you want to control the infrastructure, like leaving the runner host running for faster startups\n* Lambda is useful for short jobs that can work within time, size and readonly system constraints\n\nYou can also create your own provider by implementing `IRunnerProvider`.\n\n## Installation\n\n1. Install and use the appropriate package\n <details><summary>Python</summary>\n\n ### Install\n Available on [PyPI][6].\n ```bash\n pip install cloudsnorkel.cdk-github-runners\n ```\n ### Use\n ```python\n from aws_cdk import App, Stack\n from cloudsnorkel.cdk_github_runners import GitHubRunners\n\n app = App()\n stack = Stack(app, \"github-runners\")\n GitHubRunners(stack, \"runners\")\n\n app.synth()\n ```\n </details>\n <details><summary>TypeScript or JavaScript</summary>\n\n ### Install\n Available on [npm][7].\n ```bash\n npm i @cloudsnorkel/cdk-github-runners\n ```\n ### Use\n ```typescript\n import { App, Stack } from 'aws-cdk-lib';\n import { GitHubRunners } from '@cloudsnorkel/cdk-github-runners';\n\n const app = new App();\n const stack = new Stack(app, 'github-runners');\n new GitHubRunners(stack, 'runners');\n\n app.synth();\n ```\n </details>\n <details><summary>Java</summary>\n\n ### Install\n Available on [Maven][8].\n ```xml\n <dependency>\n <groupId>com.cloudsnorkel</groupId>\n <artifactId>cdk.github.runners</artifactId>\n </dependency>\n ```\n ### Use\n ```java\n import software.amazon.awscdk.App;\n import software.amazon.awscdk.Stack;\n import com.cloudsnorkel.cdk.github.runners.GitHubRunners;\n\n public class Example {\n public static void main(String[] args){\n App app = new App();\n Stack stack = new Stack(app, \"github-runners\");\n GitHubRunners.Builder.create(stack, \"runners\").build();\n\n app.synth();\n }\n }\n ```\n </details>\n <details><summary>Go</summary>\n\n ### Install\n Available on [GitHub][11].\n ```bash\n go get github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\n ```\n ### Use\n ```go\n package main\n\n import (\n \"github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\"\n \"github.com/aws/aws-cdk-go/awscdk/v2\"\n \"github.com/aws/jsii-runtime-go\"\n )\n\n func main() {\n app := awscdk.NewApp(nil)\n stack := awscdk.NewStack(app, jsii.String(\"github-runners\"), &awscdk.StackProps{})\n cloudsnorkelcdkgithubrunners.NewGitHubRunners(stack, jsii.String(\"runners\"), &cloudsnorkelcdkgithubrunners.GitHubRunnersProps{})\n\n app.Synth(nil)\n }\n ```\n </details>\n <details><summary>.NET</summary>\n\n ### Install\n Available on [Nuget][12].\n ```bash\n dotnet add package CloudSnorkel.Cdk.Github.Runners\n ```\n ### Use\n ```csharp\n using Amazon.CDK;\n using CloudSnorkel;\n\n namespace Example\n {\n sealed class Program\n {\n public static void Main(string[] args)\n {\n var app = new App();\n var stack = new Stack(app, \"github-runners\");\n new GitHubRunners(stack, \"runners\");\n app.Synth();\n }\n }\n }\n ```\n </details>\n2. Use `GitHubRunners` construct in your code (starting with default arguments is fine)\n3. Deploy your stack\n4. Look for the status command output similar to `aws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json`\n ```\n βœ… github-runners-test\n\n ✨ Deployment time: 260.01s\n\n Outputs:\n github-runners-test.runnersstatuscommand4A30F0F5 = aws --region us-east-1 lambda invoke --function-name github-runners-test-runnersstatus1A5771C0-mvttg8oPQnQS status.json\n ```\n5. Execute the status command (you may need to specify `--profile` too) and open the resulting `status.json` file\n6. Open the URL in `github.setup.url` from `status.json` or [manually setup GitHub](SETUP_GITHUB.md) integration as an app or with personal access token\n7. Run status command again to confirm `github.auth.status` and `github.webhook.status` are OK\n8. Trigger a GitHub action that has a `self-hosted` label with `runs-on: [self-hosted, codebuild]` (or non-default labels you set in step 2)\n9. If the action is not successful, see [troubleshooting](#Troubleshooting)\n\n[![Demo](demo-thumbnail.jpg)](https://youtu.be/wlyv_3V8lIw)\n\n## Customizing\n\nThe default providers configured by `GitHubRunners` are useful for testing but probably not too much for actual production work. They run in the default VPC or no VPC and have no added IAM permissions. You would usually want to configure the providers yourself.\n\nFor example:\n\n```typescript\nlet vpc: ec2.Vpc;\nlet runnerSg: ec2.SecurityGroup;\nlet dbSg: ec2.SecurityGroup;\nlet bucket: s3.Bucket;\n\n// create a custom CodeBuild provider\nconst myProvider = new CodeBuildRunnerProvider(this, 'codebuild runner', {\n labels: ['my-codebuild'],\n vpc: vpc,\n securityGroups: [runnerSg],\n});\n// grant some permissions to the provider\nbucket.grantReadWrite(myProvider);\ndbSg.connections.allowFrom(runnerSg, ec2.Port.tcp(3306), 'allow runners to connect to MySQL database');\n\n// create the runner infrastructure\nnew GitHubRunners(this, 'runners', {\n providers: [myProvider],\n});\n```\n\nAnother way to customize runners is by modifying the image used to spin them up. The image contains the [runner][5], any required dependencies, and integration code with the provider. You may choose to customize this image by adding more packages, for example.\n\n```typescript\nconst myBuilder = FargateRunnerProvider.imageBuilder(this, 'image builder');\nmyBuilder.addComponent(\n RunnerImageComponent.custom({ commands: ['apt install -y nginx xz-utils'] }),\n);\n\nconst myProvider = new FargateRunnerProvider(this, 'fargate runner', {\n labels: ['customized-fargate'],\n imageBuilder: myBuilder,\n});\n\n// create the runner infrastructure\nnew GitHubRunners(this, 'runners', {\n providers: [myProvider],\n});\n```\n\nYour workflow will then look like:\n\n```yaml\nname: self-hosted example\non: push\njobs:\n self-hosted:\n runs-on: [self-hosted, customized-fargate]\n steps:\n - run: echo hello world\n```\n\nWindows images can also be customized the same way.\n\n```typescript\nconst myWindowsBuilder = FargateRunnerProvider.imageBuilder(this, 'Windows image builder', {\n architecture: Architecture.X86_64,\n os: Os.WINDOWS,\n});\nmyWindowsBuilder.addComponent(\n RunnerImageComponent.custom({\n name: 'Ninja',\n commands: [\n 'Invoke-WebRequest -UseBasicParsing -Uri \"https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip\" -OutFile ninja.zip',\n 'Expand-Archive ninja.zip -DestinationPath C:\\\\actions',\n 'del ninja.zip',\n ],\n }),\n);\n\nconst myProvider = new FargateRunnerProvider(this, 'fargate runner', {\n labels: ['customized-windows-fargate'],\n imageBuilder: myWindowsBuilder,\n});\n\nnew GitHubRunners(this, 'runners', {\n providers: [myProvider],\n});\n```\n\nThe runner OS and architecture is determined by the image it is set to use. For example, to create a Fargate runner provider for ARM64 set the `architecture` property for the image builder to `Architecture.ARM64` in the image builder properties.\n\n```typescript\nnew GitHubRunners(this, 'runners', {\n providers: [\n new FargateRunnerProvider(this, 'fargate runner', {\n labels: ['arm64', 'fargate'],\n imageBuilder: FargateRunnerProvider.imageBuilder(this, 'image builder', {\n architecture: Architecture.ARM64,\n os: Os.LINUX_UBUNTU,\n }),\n }),\n ],\n});\n```\n\n### Composite Providers\n\nComposite providers allow you to combine multiple runner providers with different strategies. There are two types:\n\n**Fallback Strategy**: Try providers in order until one succeeds. Useful for trying spot instances first, then falling back to on-demand if spot capacity is unavailable.\n\n```typescript\n// Try spot instances first, fall back to on-demand if spot is unavailable\nconst ecsFallback = CompositeProvider.fallback(this, 'ECS Fallback', [\n new EcsRunnerProvider(this, 'ECS Spot', {\n labels: ['ecs', 'linux', 'x64'],\n spot: true,\n // ... other config\n }),\n new EcsRunnerProvider(this, 'ECS On-Demand', {\n labels: ['ecs', 'linux', 'x64'],\n spot: false,\n // ... other config\n }),\n]);\n\nnew GitHubRunners(this, 'runners', {\n providers: [ecsFallback],\n});\n```\n\n**Weighted Distribution Strategy**: Randomly select a provider based on weights. Useful for distributing load across multiple availability zones or instance types.\n\n```typescript\n// Distribute 60% of traffic to AZ-1, 40% to AZ-2\nconst distributedProvider = CompositeProvider.distribute(this, 'Fargate Distribution', [\n {\n weight: 3, // 3/(3+2) = 60%\n provider: new FargateRunnerProvider(this, 'Fargate AZ-1', {\n labels: ['fargate', 'linux', 'x64'],\n subnetSelection: vpc.selectSubnets({\n availabilityZones: [vpc.availabilityZones[0]],\n }),\n // ... other config\n }),\n },\n {\n weight: 2, // 2/(3+2) = 40%\n provider: new FargateRunnerProvider(this, 'Fargate AZ-2', {\n labels: ['fargate', 'linux', 'x64'],\n subnetSelection: vpc.selectSubnets({\n availabilityZones: [vpc.availabilityZones[1]],\n }),\n // ... other config\n }),\n },\n]);\n\nnew GitHubRunners(this, 'runners', {\n providers: [distributedProvider],\n});\n```\n\n**Important**: All providers in a composite must have the exact same labels. This ensures any provisioned runner can match the labels requested by the GitHub workflow job.\n\n### Custom Provider Selection\n\nBy default, providers are selected based on label matching: the first provider that has all the labels requested by the job is selected. You can customize this behavior using a provider selector Lambda function to:\n\n* Filter out certain jobs (prevent runner provisioning)\n* Dynamically select a provider based on job characteristics (repository, branch, time of day, etc.)\n* Customize labels for the runner (add, remove, or modify labels dynamically)\n\nThe selector function receives the full GitHub webhook payload, a map of all available providers and their labels, and the default provider/labels that would have been selected. It returns the provider to use (or `undefined` to skip runner creation) and the labels to assign to the runner.\n\n**Example: Route jobs to different providers based on repository**\n\n```typescript\nimport { ComputeType } from 'aws-cdk-lib/aws-codebuild';\nimport { Function, Code, Runtime } from 'aws-cdk-lib/aws-lambda';\nimport { GitHubRunners, CodeBuildRunnerProvider } from '@cloudsnorkel/cdk-github-runners';\n\nconst defaultProvider = new CodeBuildRunnerProvider(this, 'default', {\n labels: ['custom-runner', 'default'],\n});\nconst productionProvider = new CodeBuildRunnerProvider(this, 'production', {\n labels: ['custom-runner', 'production'],\n computeType: ComputeType.LARGE,\n});\n\nconst providerSelector = new Function(this, 'provider-selector', {\n runtime: Runtime.NODEJS_LATEST,\n handler: 'index.handler',\n code: Code.fromInline(`\n exports.handler = async (event) => {\n const { payload, providers, defaultProvider, defaultLabels } = event;\n\n // Route production repos to dedicated provider\n if (payload.repository.name.includes('prod')) {\n return {\n provider: '${productionProvider.node.path}',\n labels: ['custom-runner', 'production', 'modified-via-selector'],\n };\n }\n\n // Filter out draft PRs\n if (payload.workflow_job.head_branch?.startsWith('draft/')) {\n return { provider: undefined }; // Skip runner provisioning\n }\n\n // Use default for everything else\n return {\n provider: defaultProvider,\n labels: defaultLabels,\n };\n };\n `),\n});\n\nnew GitHubRunners(this, 'runners', {\n providers: [defaultProvider, productionProvider],\n providerSelector: providerSelector,\n});\n```\n\n**Example: Add dynamic labels based on job metadata**\n\n```typescript\nconst providerSelector = new Function(this, 'provider-selector', {\n runtime: Runtime.NODEJS_LATEST,\n handler: 'index.handler',\n code: Code.fromInline(`\n exports.handler = async (event) => {\n const { payload, defaultProvider, defaultLabels } = event;\n\n // Add branch name as a label\n const branch = payload.workflow_job.head_branch || 'unknown';\n const labels = [...(defaultLabels || []), 'branch:' + branch];\n\n return {\n provider: defaultProvider,\n labels: labels,\n };\n };\n `),\n});\n```\n\n**Important considerations:**\n\n* ⚠️ **Label matching responsibility**: You are responsible for ensuring the selected provider's labels match what the job requires. If labels don't match, the runner will be provisioned but GitHub Actions won't assign the job to it.\n* ⚠️ **No guarantee of assignment**: Provider selection only determines which provider will provision a runner. GitHub Actions may still route the job to any available runner with matching labels. For reliable provider assignment, consider repo-level runner registration (the default).\n* ⚑ **Performance**: The selector runs synchronously during webhook processing. Keep it fast and efficientβ€”the webhook has a 30-second timeout total.\n\n## Examples\n\nWe provide comprehensive examples in the [`examples/`](examples/) folder to help you get started quickly:\n\n### Getting Started\n- **[Simple CodeBuild](examples/typescript/simple-codebuild/)** - Basic setup with just a CodeBuild provider (also available in [Python](examples/python/simple-codebuild/))\n\n### Provider Configuration\n- **[Composite Provider](examples/typescript/composite-provider/)** - Fallback and weighted distribution strategies (also available in [Python](examples/python/composite-provider/))\n- **[Provider Selector](examples/typescript/provider-selector/)** - Custom provider selection with Lambda function (also available in [Python](examples/python/provider-selector/))\n- **[EC2 Windows Provider](examples/typescript/ec2-windows-provider/)** - EC2 configuration for Windows runners (also available in [Python](examples/python/ec2-windows-provider/))\n- **[Split Stacks](examples/typescript/split-stacks/)** - Split image builders and providers across multiple stacks (also available in [Python](examples/python/split-stacks/))\n\n### Compute & Performance\n- **[Compute Options](examples/typescript/compute-options/)** - Configure CPU, memory, and instance types for different providers (also available in [Python](examples/python/compute-options/))\n- **[Spot Instances](examples/typescript/spot-instances/)** - Use spot instances for cost savings across EC2, Fargate, and ECS (also available in [Python](examples/python/spot-instances/))\n- **[Storage Options](examples/typescript/storage-options/)** - Custom EBS storage options for EC2 runners (also available in [Python](examples/python/storage-options/))\n- **[ECS Scaling](examples/typescript/ecs-scaling/)** - Custom autoscaling group scaling policies for ECS providers (also available in [Python](examples/python/ecs-scaling/))\n\n### Security & Access\n- **[IAM Permissions](examples/typescript/iam-permissions/)** - Grant AWS IAM permissions to runners (also available in [Python](examples/python/iam-permissions/))\n- **[Network Access](examples/typescript/network-access/)** - Configure network access with VPCs and security groups (also available in [Python](examples/python/network-access/))\n- **[Access Control](examples/typescript/access-control/)** - Configure access control for webhook and setup functions (also available in [Python](examples/python/access-control/))\n\n### Customization\n- **[Add Software](examples/typescript/add-software/)** - Add custom software to runner images (also available in [Python](examples/python/add-software/))\n\n### Enterprise & Monitoring\n- **[GHES](examples/typescript/ghes/)** - Configure runners for GitHub Enterprise Server (also available in [Python](examples/python/ghes/))\n- **[Monitoring](examples/typescript/monitoring/)** - Set up CloudWatch alarms and SNS notifications (also available in [Python](examples/python/monitoring/))\n\nEach example is self-contained with its own dependencies and README. Start with the simple examples and work your way up to more advanced configurations.\n\nAnother good and very full example is the [integration test](test/default.integ.ts).\n\nIf you have more to share, please open a PR adding examples to the `examples` folder.\n\n## Architecture\n\n![Architecture diagram](architecture.svg)\n\n## Troubleshooting\n\nRunners are started in response to a webhook coming in from GitHub. If there are any issues starting the runner like missing capacity or transient API issues, the provider will keep retrying for 24 hours. Configuration issue related errors like pointing to a missing AMI will not be retried. GitHub itself will cancel the job if it can't find a runner for 24 hours. If your jobs don't start, follow the steps below to examine all parts of this workflow.\n\n1. Always start with the status function, make sure no errors are reported, and confirm all status codes are OK\n2. Make sure `runs-on` in the workflow matches the expected labels set in the runner provider\n3. Diagnose relevant executions of the orchestrator step function by visiting the URL in `troubleshooting.stepFunctionUrl` from `status.json`\n 1. If the execution failed, check your runner provider configuration for errors\n 2. If the execution is still running for a long time, check the execution events to see why runner starting is being retried\n 3. If there are no relevant executions, move to the next step\n4. Confirm the webhook Lambda was called by visiting the URL in `troubleshooting.webhookHandlerUrl` from `status.json`\n 1. If it's not called or logs errors, confirm the webhook settings on the GitHub side\n 2. If you see too many errors, make sure you're only sending `workflow_job` events\n5. When using GitHub app, make sure there are active installations in `github.auth.app.installations`\n\nAll logs are saved in CloudWatch.\n* Log group names can be found in `status.json` for each provider, image builder, and other parts of the system\n* Some useful Logs Insights queries can be enabled with `GitHubRunners.createLogsInsightsQueries()`\n\nTo get `status.json`, check out the CloudFormation stack output for a command that generates it. The command looks like:\n\n```\naws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json\n```\n\n## Monitoring\n\nThere are two important ways to monitor your runners:\n\n1. Make sure runners don't fail to start. When that happens, jobs may sit and wait. Use `GitHubRunners.metricFailed()` to get a metric for the number of failed runner starts. You should use this metric to trigger an alarm.\n2. Make sure runner images don't fail to build. Failed runner image builds mean you will get stuck with out-of-date software on your runners. It may lead to security vulnerabilities, or it may lead to slower runner start-ups as the runner software itself needs to be updated. Use `GitHubRunners.failedImageBuildsTopic()` to get SNS topic that gets notified of failed runner image builds. You should subscribe to this topic.\n\nOther useful metrics to track:\n\n1. Use `GitHubRunners.metricJobCompleted()` to get a metric for the number of completed jobs broken down by labels and job success.\n2. Use `GitHubRunners.metricTime()` to get a metric for the total time a runner is running. This includes the overhead of starting the runner.\n\n## Getting Help\n\nNeed help? We're here for you!\n\n* πŸ’¬ **GitHub Discussions**: Ask questions, share ideas, or get help from the community by opening a [discussion][18]\n* πŸ› **GitHub Issues**: Report bugs or request features by opening an [issue][16]\n* πŸ’¬ **Discord**: Join our [Discord community][20] for real-time help and discussions\n\n## Contributing\n\nIf you use and love this project, please consider contributing.\n\n1. πŸͺ³ If you see something, say something. [Issues][16] help improve the quality of the project.\n * Include relevant logs and package versions for bugs.\n * When possible, describe the use-case behind feature requests.\n1. πŸ› οΈ [Pull requests][17] are welcome.\n * Run `npm run build` before submitting to make sure all tests pass.\n * Allow edits from maintainers so small adjustments can be made easily.\n1. πŸ’΅ Consider [sponsoring][15] the project to show your support and optionally get your name listed below.\n\n## Sponsors\n\nThanks to our generous sponsors who helped make this project possible!\n\n<table>\n <tr>\n <td align=\"center\">\n <a href=\"https://github.com/threat-down\">\n <img src=\"https://github.com/threat-down.png?size=100\" width=\"100\" height=\"100\" alt=\"ThreatDown\" />\n <br />\n <sub><b>ThreatDown</b></sub>\n </a>\n </td>\n <td align=\"center\">\n <a href=\"https://github.com/magicbell\">\n <img src=\"https://github.com/magicbell.png?size=100\" width=\"100\" height=\"100\" alt=\"MagicBell\" />\n <br />\n <sub><b>MagicBell</b></sub>\n </a>\n </td>\n <td align=\"center\">\n <a href=\"https://github.com/fragment-dev\">\n <img src=\"https://github.com/fragment-dev.png?size=100\" width=\"100\" height=\"100\" alt=\"Fragment\" />\n <br />\n <sub><b>Fragment</b></sub>\n </a>\n </td>\n <td align=\"center\">\n <a href=\"https://github.com/andresionek91\">\n <img src=\"https://github.com/andresionek91.png?size=100\" width=\"100\" height=\"100\" alt=\"Andre Sionek\" />\n <br />\n <sub><b>Andre Sionek</b></sub>\n </a>\n </td>\n </tr>\n</table>\n\n## Other Options\n\n1. [github-aws-runners/terraform-aws-github-runner][3] if you're using Terraform\n2. [actions/actions-runner-controller][4] if you're using Kubernetes\n\n\n[1]: https://docs.github.com/en/actions/hosting-your-own-runners/about-self-hosted-runners\n[2]: https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions\n[3]: https://github.com/github-aws-runners/terraform-aws-github-runner\n[4]: https://github.com/actions/actions-runner-controller\n[5]: https://github.com/actions/runner\n[6]: https://pypi.org/project/cloudsnorkel.cdk-github-runners\n[7]: https://www.npmjs.com/package/@cloudsnorkel/cdk-github-runners\n[8]: https://central.sonatype.com/artifact/com.cloudsnorkel/cdk.github.runners/\n[9]: https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps\n[10]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token\n[11]: https://pkg.go.dev/github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\n[12]: https://www.nuget.org/packages/CloudSnorkel.Cdk.Github.Runners/\n[13]: https://constructs.dev/packages/@cloudsnorkel/cdk-github-runners/\n[14]: https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling\n[15]: https://github.com/sponsors/CloudSnorkel\n[16]: https://github.com/CloudSnorkel/cdk-github-runners/issues\n[17]: https://github.com/CloudSnorkel/cdk-github-runners/pulls\n[18]: https://github.com/CloudSnorkel/cdk-github-runners/discussions\n[20]: https://discord.gg/vdrTUTqQKv\n"
3862
3862
  },
3863
3863
  "repository": {
3864
3864
  "type": "git",
@@ -9765,21 +9765,33 @@
9765
9765
  },
9766
9766
  "locationInModule": {
9767
9767
  "filename": "src/runner.ts",
9768
- "line": 902
9768
+ "line": 909
9769
9769
  },
9770
9770
  "name": "createLogsInsightsQueries"
9771
9771
  },
9772
9772
  {
9773
9773
  "docs": {
9774
- "remarks": "Runner images are rebuilt every week by default. This provides the latest GitHub Runner version and software updates.\n\nIf you want to be sure you are using the latest runner version, you can use this topic to be notified when a build fails.",
9774
+ "remarks": "Runner images are rebuilt every week by default. This provides the latest GitHub Runner version and software updates.\n\nIf you want to be sure you are using the latest runner version, you can use this topic to be notified when a build fails.\n\nWhen the image builder is defined in a separate stack (e.g. in a split-stacks setup), pass that stack or construct\nas the optional scope so the topic and failure-notification aspects are created in the same stack as the image\nbuilder. Otherwise the aspects may not find the image builder resources.",
9775
9775
  "stability": "experimental",
9776
9776
  "summary": "Creates a topic for notifications when a runner image build fails."
9777
9777
  },
9778
9778
  "locationInModule": {
9779
9779
  "filename": "src/runner.ts",
9780
- "line": 882
9780
+ "line": 888
9781
9781
  },
9782
9782
  "name": "failedImageBuildsTopic",
9783
+ "parameters": [
9784
+ {
9785
+ "docs": {
9786
+ "summary": "Optional scope (e.g. the image builder stack) where the topic and aspects will be created. Defaults to this construct."
9787
+ },
9788
+ "name": "scope",
9789
+ "optional": true,
9790
+ "type": {
9791
+ "fqn": "constructs.Construct"
9792
+ }
9793
+ }
9794
+ ],
9783
9795
  "returns": {
9784
9796
  "type": {
9785
9797
  "fqn": "aws-cdk-lib.aws_sns.Topic"
@@ -13934,7 +13946,7 @@
13934
13946
  "kind": "class",
13935
13947
  "locationInModule": {
13936
13948
  "filename": "src/image-builders/components.ts",
13937
- "line": 42
13949
+ "line": 73
13938
13950
  },
13939
13951
  "methods": [
13940
13952
  {
@@ -13944,9 +13956,21 @@
13944
13956
  },
13945
13957
  "locationInModule": {
13946
13958
  "filename": "src/image-builders/components.ts",
13947
- "line": 184
13959
+ "line": 217
13948
13960
  },
13949
13961
  "name": "awsCli",
13962
+ "parameters": [
13963
+ {
13964
+ "docs": {
13965
+ "summary": "Software version to install (e.g. '2.15.0'). Default: latest."
13966
+ },
13967
+ "name": "version",
13968
+ "optional": true,
13969
+ "type": {
13970
+ "primitive": "string"
13971
+ }
13972
+ }
13973
+ ],
13950
13974
  "returns": {
13951
13975
  "type": {
13952
13976
  "fqn": "@cloudsnorkel/cdk-github-runners.RunnerImageComponent"
@@ -13961,7 +13985,7 @@
13961
13985
  },
13962
13986
  "locationInModule": {
13963
13987
  "filename": "src/image-builders/components.ts",
13964
- "line": 110
13988
+ "line": 141
13965
13989
  },
13966
13990
  "name": "cloudWatchAgent",
13967
13991
  "returns": {
@@ -13979,7 +14003,7 @@
13979
14003
  },
13980
14004
  "locationInModule": {
13981
14005
  "filename": "src/image-builders/components.ts",
13982
- "line": 52
14006
+ "line": 83
13983
14007
  },
13984
14008
  "name": "custom",
13985
14009
  "parameters": [
@@ -14005,9 +14029,21 @@
14005
14029
  },
14006
14030
  "locationInModule": {
14007
14031
  "filename": "src/image-builders/components.ts",
14008
- "line": 402
14032
+ "line": 477
14009
14033
  },
14010
14034
  "name": "docker",
14035
+ "parameters": [
14036
+ {
14037
+ "docs": {
14038
+ "summary": "Software version to install (e.g. '29.1.5'). Default: latest. Only used on Windows; on Linux (Ubuntu, Amazon Linux 2 and Amazon Linux 2023) the package version format is not reliably predictable so latest is always used."
14039
+ },
14040
+ "name": "version",
14041
+ "optional": true,
14042
+ "type": {
14043
+ "primitive": "string"
14044
+ }
14045
+ }
14046
+ ],
14011
14047
  "returns": {
14012
14048
  "type": {
14013
14049
  "fqn": "@cloudsnorkel/cdk-github-runners.RunnerImageComponent"
@@ -14023,9 +14059,21 @@
14023
14059
  },
14024
14060
  "locationInModule": {
14025
14061
  "filename": "src/image-builders/components.ts",
14026
- "line": 480
14062
+ "line": 576
14027
14063
  },
14028
14064
  "name": "dockerInDocker",
14065
+ "parameters": [
14066
+ {
14067
+ "docs": {
14068
+ "summary": "Software version to install (e.g. '29.1.5'). Default: latest."
14069
+ },
14070
+ "name": "version",
14071
+ "optional": true,
14072
+ "type": {
14073
+ "primitive": "string"
14074
+ }
14075
+ }
14076
+ ],
14029
14077
  "returns": {
14030
14078
  "type": {
14031
14079
  "fqn": "@cloudsnorkel/cdk-github-runners.RunnerImageComponent"
@@ -14041,7 +14089,7 @@
14041
14089
  },
14042
14090
  "locationInModule": {
14043
14091
  "filename": "src/image-builders/components.ts",
14044
- "line": 597
14092
+ "line": 693
14045
14093
  },
14046
14094
  "name": "environmentVariables",
14047
14095
  "parameters": [
@@ -14072,7 +14120,7 @@
14072
14120
  },
14073
14121
  "locationInModule": {
14074
14122
  "filename": "src/image-builders/components.ts",
14075
- "line": 490
14123
+ "line": 586
14076
14124
  },
14077
14125
  "name": "extraCertificates",
14078
14126
  "parameters": [
@@ -14105,13 +14153,25 @@
14105
14153
  {
14106
14154
  "docs": {
14107
14155
  "stability": "experimental",
14108
- "summary": "A component to install the GitHub CLI."
14156
+ "summary": "A component to install Git."
14109
14157
  },
14110
14158
  "locationInModule": {
14111
14159
  "filename": "src/image-builders/components.ts",
14112
- "line": 263
14160
+ "line": 321
14113
14161
  },
14114
14162
  "name": "git",
14163
+ "parameters": [
14164
+ {
14165
+ "docs": {
14166
+ "summary": "Software version to install (e.g. '2.43.0.windows.1'). Default: latest. Only used on Windows; on Linux the package manager is used."
14167
+ },
14168
+ "name": "version",
14169
+ "optional": true,
14170
+ "type": {
14171
+ "primitive": "string"
14172
+ }
14173
+ }
14174
+ ],
14115
14175
  "returns": {
14116
14176
  "type": {
14117
14177
  "fqn": "@cloudsnorkel/cdk-github-runners.RunnerImageComponent"
@@ -14126,9 +14186,21 @@
14126
14186
  },
14127
14187
  "locationInModule": {
14128
14188
  "filename": "src/image-builders/components.ts",
14129
- "line": 220
14189
+ "line": 262
14130
14190
  },
14131
14191
  "name": "githubCli",
14192
+ "parameters": [
14193
+ {
14194
+ "docs": {
14195
+ "summary": "Software version to install (e.g. '2.40.0'). Default: latest. Only used on Windows (x64/windows_amd64); on Linux the package manager is used."
14196
+ },
14197
+ "name": "version",
14198
+ "optional": true,
14199
+ "type": {
14200
+ "primitive": "string"
14201
+ }
14202
+ }
14203
+ ],
14132
14204
  "returns": {
14133
14205
  "type": {
14134
14206
  "fqn": "@cloudsnorkel/cdk-github-runners.RunnerImageComponent"
@@ -14144,7 +14216,7 @@
14144
14216
  },
14145
14217
  "locationInModule": {
14146
14218
  "filename": "src/image-builders/components.ts",
14147
- "line": 307
14219
+ "line": 380
14148
14220
  },
14149
14221
  "name": "githubRunner",
14150
14222
  "parameters": [
@@ -14173,7 +14245,7 @@
14173
14245
  },
14174
14246
  "locationInModule": {
14175
14247
  "filename": "src/image-builders/components.ts",
14176
- "line": 554
14248
+ "line": 650
14177
14249
  },
14178
14250
  "name": "lambdaEntrypoint",
14179
14251
  "returns": {
@@ -14190,7 +14262,7 @@
14190
14262
  },
14191
14263
  "locationInModule": {
14192
14264
  "filename": "src/image-builders/components.ts",
14193
- "line": 77
14265
+ "line": 108
14194
14266
  },
14195
14267
  "name": "requiredPackages",
14196
14268
  "returns": {
@@ -14207,7 +14279,7 @@
14207
14279
  },
14208
14280
  "locationInModule": {
14209
14281
  "filename": "src/image-builders/components.ts",
14210
- "line": 153
14282
+ "line": 184
14211
14283
  },
14212
14284
  "name": "runnerUser",
14213
14285
  "returns": {
@@ -14225,7 +14297,7 @@
14225
14297
  },
14226
14298
  "locationInModule": {
14227
14299
  "filename": "src/image-builders/components.ts",
14228
- "line": 634
14300
+ "line": 730
14229
14301
  },
14230
14302
  "name": "getAssets",
14231
14303
  "parameters": [
@@ -14262,7 +14334,7 @@
14262
14334
  },
14263
14335
  "locationInModule": {
14264
14336
  "filename": "src/image-builders/components.ts",
14265
- "line": 629
14337
+ "line": 725
14266
14338
  },
14267
14339
  "name": "getCommands",
14268
14340
  "parameters": [
@@ -14298,7 +14370,7 @@
14298
14370
  },
14299
14371
  "locationInModule": {
14300
14372
  "filename": "src/image-builders/components.ts",
14301
- "line": 643
14373
+ "line": 739
14302
14374
  },
14303
14375
  "name": "getDockerCommands",
14304
14376
  "parameters": [
@@ -14333,7 +14405,7 @@
14333
14405
  },
14334
14406
  "locationInModule": {
14335
14407
  "filename": "src/image-builders/components.ts",
14336
- "line": 650
14408
+ "line": 746
14337
14409
  },
14338
14410
  "name": "shouldReboot",
14339
14411
  "parameters": [
@@ -14369,7 +14441,7 @@
14369
14441
  "immutable": true,
14370
14442
  "locationInModule": {
14371
14443
  "filename": "src/image-builders/components.ts",
14372
- "line": 624
14444
+ "line": 720
14373
14445
  },
14374
14446
  "name": "name",
14375
14447
  "type": {
@@ -15431,6 +15503,6 @@
15431
15503
  "symbolId": "src/image-builders/aws-image-builder/deprecated/windows-components:WindowsComponents"
15432
15504
  }
15433
15505
  },
15434
- "version": "0.14.22",
15435
- "fingerprint": "mCYvlyOxAFOZMBmW79uTiGH8rhQ9x1oCJpBAET46Zjo="
15506
+ "version": "0.14.23",
15507
+ "fingerprint": "k/cf/LtmtGrjO9Wb3LPmW/SG5vve+R83JPKDGMJvZus="
15436
15508
  }
package/API.md CHANGED
@@ -3447,7 +3447,7 @@ Creates CloudWatch Logs Insights saved queries that can be used to debug issues
3447
3447
  ##### `failedImageBuildsTopic` <a name="failedImageBuildsTopic" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.failedImageBuildsTopic"></a>
3448
3448
 
3449
3449
  ```typescript
3450
- public failedImageBuildsTopic(): Topic
3450
+ public failedImageBuildsTopic(scope?: Construct): Topic
3451
3451
  ```
3452
3452
 
3453
3453
  Creates a topic for notifications when a runner image build fails.
@@ -3456,6 +3456,18 @@ Runner images are rebuilt every week by default. This provides the latest GitHub
3456
3456
 
3457
3457
  If you want to be sure you are using the latest runner version, you can use this topic to be notified when a build fails.
3458
3458
 
3459
+ When the image builder is defined in a separate stack (e.g. in a split-stacks setup), pass that stack or construct
3460
+ as the optional scope so the topic and failure-notification aspects are created in the same stack as the image
3461
+ builder. Otherwise the aspects may not find the image builder resources.
3462
+
3463
+ ###### `scope`<sup>Optional</sup> <a name="scope" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.failedImageBuildsTopic.parameter.scope"></a>
3464
+
3465
+ - *Type:* constructs.Construct
3466
+
3467
+ Optional scope (e.g. the image builder stack) where the topic and aspects will be created. Defaults to this construct.
3468
+
3469
+ ---
3470
+
3459
3471
  ##### `metricFailed` <a name="metricFailed" id="@cloudsnorkel/cdk-github-runners.GitHubRunners.metricFailed"></a>
3460
3472
 
3461
3473
  ```typescript
@@ -10437,7 +10449,7 @@ Returns true if the image builder should be rebooted after this component is ins
10437
10449
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.dockerInDocker">dockerInDocker</a></code> | A component to install Docker-in-Docker. |
10438
10450
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.environmentVariables">environmentVariables</a></code> | A component to add environment variables for jobs the runner executes. |
10439
10451
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.extraCertificates">extraCertificates</a></code> | A component to add a trusted certificate authority. |
10440
- | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.git">git</a></code> | A component to install the GitHub CLI. |
10452
+ | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.git">git</a></code> | A component to install Git. |
10441
10453
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.githubCli">githubCli</a></code> | A component to install the GitHub CLI. |
10442
10454
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.githubRunner">githubRunner</a></code> | A component to install the GitHub Actions Runner. |
10443
10455
  | <code><a href="#@cloudsnorkel/cdk-github-runners.RunnerImageComponent.lambdaEntrypoint">lambdaEntrypoint</a></code> | A component to set up the required Lambda entrypoint for Lambda runners. |
@@ -10451,11 +10463,19 @@ Returns true if the image builder should be rebooted after this component is ins
10451
10463
  ```typescript
10452
10464
  import { RunnerImageComponent } from '@cloudsnorkel/cdk-github-runners'
10453
10465
 
10454
- RunnerImageComponent.awsCli()
10466
+ RunnerImageComponent.awsCli(version?: string)
10455
10467
  ```
10456
10468
 
10457
10469
  A component to install the AWS CLI.
10458
10470
 
10471
+ ###### `version`<sup>Optional</sup> <a name="version" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.awsCli.parameter.version"></a>
10472
+
10473
+ - *Type:* string
10474
+
10475
+ Software version to install (e.g. '2.15.0'). Default: latest.
10476
+
10477
+ ---
10478
+
10459
10479
  ##### `cloudWatchAgent` <a name="cloudWatchAgent" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.cloudWatchAgent"></a>
10460
10480
 
10461
10481
  ```typescript
@@ -10493,23 +10513,39 @@ Use this to customize the image for the runner.
10493
10513
  ```typescript
10494
10514
  import { RunnerImageComponent } from '@cloudsnorkel/cdk-github-runners'
10495
10515
 
10496
- RunnerImageComponent.docker()
10516
+ RunnerImageComponent.docker(version?: string)
10497
10517
  ```
10498
10518
 
10499
10519
  A component to install Docker.
10500
10520
 
10501
10521
  On Windows this sets up dockerd for Windows containers without Docker Desktop. If you need Linux containers on Windows, you'll need to install Docker Desktop which doesn't seem to play well with servers (PRs welcome).
10502
10522
 
10523
+ ###### `version`<sup>Optional</sup> <a name="version" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.docker.parameter.version"></a>
10524
+
10525
+ - *Type:* string
10526
+
10527
+ Software version to install (e.g. '29.1.5'). Default: latest. Only used on Windows; on Linux (Ubuntu, Amazon Linux 2 and Amazon Linux 2023) the package version format is not reliably predictable so latest is always used.
10528
+
10529
+ ---
10530
+
10503
10531
  ##### ~~`dockerInDocker`~~ <a name="dockerInDocker" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.dockerInDocker"></a>
10504
10532
 
10505
10533
  ```typescript
10506
10534
  import { RunnerImageComponent } from '@cloudsnorkel/cdk-github-runners'
10507
10535
 
10508
- RunnerImageComponent.dockerInDocker()
10536
+ RunnerImageComponent.dockerInDocker(version?: string)
10509
10537
  ```
10510
10538
 
10511
10539
  A component to install Docker-in-Docker.
10512
10540
 
10541
+ ###### `version`<sup>Optional</sup> <a name="version" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.dockerInDocker.parameter.version"></a>
10542
+
10543
+ - *Type:* string
10544
+
10545
+ Software version to install (e.g. '29.1.5'). Default: latest.
10546
+
10547
+ ---
10548
+
10513
10549
  ##### `environmentVariables` <a name="environmentVariables" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.environmentVariables"></a>
10514
10550
 
10515
10551
  ```typescript
@@ -10565,21 +10601,37 @@ unique certificate name to be used on runner file system.
10565
10601
  ```typescript
10566
10602
  import { RunnerImageComponent } from '@cloudsnorkel/cdk-github-runners'
10567
10603
 
10568
- RunnerImageComponent.git()
10604
+ RunnerImageComponent.git(version?: string)
10569
10605
  ```
10570
10606
 
10571
- A component to install the GitHub CLI.
10607
+ A component to install Git.
10608
+
10609
+ ###### `version`<sup>Optional</sup> <a name="version" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.git.parameter.version"></a>
10610
+
10611
+ - *Type:* string
10612
+
10613
+ Software version to install (e.g. '2.43.0.windows.1'). Default: latest. Only used on Windows; on Linux the package manager is used.
10614
+
10615
+ ---
10572
10616
 
10573
10617
  ##### `githubCli` <a name="githubCli" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.githubCli"></a>
10574
10618
 
10575
10619
  ```typescript
10576
10620
  import { RunnerImageComponent } from '@cloudsnorkel/cdk-github-runners'
10577
10621
 
10578
- RunnerImageComponent.githubCli()
10622
+ RunnerImageComponent.githubCli(version?: string)
10579
10623
  ```
10580
10624
 
10581
10625
  A component to install the GitHub CLI.
10582
10626
 
10627
+ ###### `version`<sup>Optional</sup> <a name="version" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.githubCli.parameter.version"></a>
10628
+
10629
+ - *Type:* string
10630
+
10631
+ Software version to install (e.g. '2.40.0'). Default: latest. Only used on Windows (x64/windows_amd64); on Linux the package manager is used.
10632
+
10633
+ ---
10634
+
10583
10635
  ##### `githubRunner` <a name="githubRunner" id="@cloudsnorkel/cdk-github-runners.RunnerImageComponent.githubRunner"></a>
10584
10636
 
10585
10637
  ```typescript