@cloudsnorkel/cdk-github-runners 0.13.3 → 0.14.0

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.
Files changed (33) hide show
  1. package/.jsii +43 -43
  2. package/API.md +7 -11
  3. package/README.md +20 -5
  4. package/assets/providers/lambda-bootstrap.sh +21 -0
  5. package/assets/providers/lambda-runner.sh +37 -0
  6. package/lib/access.js +1 -1
  7. package/lib/image-builders/api.js +1 -1
  8. package/lib/image-builders/aws-image-builder/builder.d.ts +1 -1
  9. package/lib/image-builders/aws-image-builder/builder.js +3 -3
  10. package/lib/image-builders/aws-image-builder/deprecated/ami.d.ts +1 -1
  11. package/lib/image-builders/aws-image-builder/deprecated/ami.js +2 -2
  12. package/lib/image-builders/aws-image-builder/deprecated/common.js +2 -2
  13. package/lib/image-builders/aws-image-builder/deprecated/container.d.ts +1 -1
  14. package/lib/image-builders/aws-image-builder/deprecated/container.js +2 -2
  15. package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +1 -1
  16. package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
  17. package/lib/image-builders/codebuild-deprecated.js +1 -1
  18. package/lib/image-builders/common.d.ts +1 -1
  19. package/lib/image-builders/common.js +1 -1
  20. package/lib/image-builders/components.js +25 -10
  21. package/lib/image-builders/static.js +1 -1
  22. package/lib/providers/codebuild.js +2 -2
  23. package/lib/providers/common.js +5 -4
  24. package/lib/providers/ec2.d.ts +1 -1
  25. package/lib/providers/ec2.js +20 -4
  26. package/lib/providers/ecs.d.ts +1 -1
  27. package/lib/providers/ecs.js +3 -3
  28. package/lib/providers/fargate.js +2 -2
  29. package/lib/providers/lambda.d.ts +1 -3
  30. package/lib/providers/lambda.js +5 -16
  31. package/lib/runner.js +1 -1
  32. package/lib/secrets.js +1 -1
  33. package/package.json +17 -16
package/.jsii CHANGED
@@ -3675,7 +3675,7 @@
3675
3675
  "stability": "experimental"
3676
3676
  },
3677
3677
  "homepage": "https://github.com/CloudSnorkel/cdk-github-runners.git",
3678
- "jsiiVersion": "5.3.34 (build f4c2317)",
3678
+ "jsiiVersion": "5.3.36 (build 0087b04)",
3679
3679
  "keywords": [
3680
3680
  "aws",
3681
3681
  "aws-cdk",
@@ -3699,7 +3699,7 @@
3699
3699
  },
3700
3700
  "name": "@cloudsnorkel/cdk-github-runners",
3701
3701
  "readme": {
3702
- "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 cloudsnorkel.cdk_github_runners import GitHubRunners\n\n GitHubRunners(self, \"runners\")\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 { GitHubRunners } from '@cloudsnorkel/cdk-github-runners';\n\n new GitHubRunners(this, \"runners\");\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 com.cloudsnorkel.cdk.github.runners.GitHubRunners;\n\n GitHubRunners.Builder.create(this, \"runners\").build();\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 import \"github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\"\n\n NewGitHubRunners(this, jsii.String(\"runners\"))\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 CloudSnorkel;\n\n new GitHubRunners(this, \"runners\");\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, linux, codebuild]` or similar\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## 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## Other Options\n\n1. [philips-labs/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-for-github-actions\n[3]: https://github.com/philips-labs/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"
3702
+ "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 cloudsnorkel.cdk_github_runners import GitHubRunners\n\n GitHubRunners(self, \"runners\")\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 { GitHubRunners } from '@cloudsnorkel/cdk-github-runners';\n\n new GitHubRunners(this, \"runners\");\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 com.cloudsnorkel.cdk.github.runners.GitHubRunners;\n\n GitHubRunners.Builder.create(this, \"runners\").build();\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 import \"github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\"\n\n NewGitHubRunners(this, jsii.String(\"runners\"))\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 CloudSnorkel;\n\n new GitHubRunners(this, \"runners\");\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, linux, codebuild]` or similar\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## 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. [philips-labs/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-for-github-actions\n[3]: https://github.com/philips-labs/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"
3703
3703
  },
3704
3704
  "repository": {
3705
3705
  "type": "git",
@@ -4198,7 +4198,7 @@
4198
4198
  {
4199
4199
  "abstract": true,
4200
4200
  "docs": {
4201
- "default": "m5.large",
4201
+ "default": "m6i.large",
4202
4202
  "stability": "experimental",
4203
4203
  "summary": "The instance type used to build the image."
4204
4204
  },
@@ -4680,7 +4680,7 @@
4680
4680
  {
4681
4681
  "abstract": true,
4682
4682
  "docs": {
4683
- "default": "m5.large",
4683
+ "default": "m6i.large",
4684
4684
  "stability": "experimental",
4685
4685
  "summary": "The instance type used to build the image."
4686
4686
  },
@@ -5487,7 +5487,7 @@
5487
5487
  },
5488
5488
  "locationInModule": {
5489
5489
  "filename": "src/providers/common.ts",
5490
- "line": 490
5490
+ "line": 492
5491
5491
  },
5492
5492
  "name": "labelsFromProperties",
5493
5493
  "parameters": [
@@ -6402,7 +6402,7 @@
6402
6402
  {
6403
6403
  "abstract": true,
6404
6404
  "docs": {
6405
- "default": "m5.large",
6405
+ "default": "m6i.large",
6406
6406
  "stability": "experimental",
6407
6407
  "summary": "The instance type used to build the image."
6408
6408
  },
@@ -6651,7 +6651,7 @@
6651
6651
  "kind": "class",
6652
6652
  "locationInModule": {
6653
6653
  "filename": "src/providers/ec2.ts",
6654
- "line": 562
6654
+ "line": 578
6655
6655
  },
6656
6656
  "name": "Ec2Runner",
6657
6657
  "symbolId": "src/providers/ec2:Ec2Runner"
@@ -6780,7 +6780,7 @@
6780
6780
  },
6781
6781
  "locationInModule": {
6782
6782
  "filename": "src/providers/ec2.ts",
6783
- "line": 502
6783
+ "line": 518
6784
6784
  },
6785
6785
  "name": "grantStateMachine",
6786
6786
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -6799,7 +6799,7 @@
6799
6799
  },
6800
6800
  "locationInModule": {
6801
6801
  "filename": "src/providers/common.ts",
6802
- "line": 490
6802
+ "line": 492
6803
6803
  },
6804
6804
  "name": "labelsFromProperties",
6805
6805
  "parameters": [
@@ -6849,7 +6849,7 @@
6849
6849
  },
6850
6850
  "locationInModule": {
6851
6851
  "filename": "src/providers/ec2.ts",
6852
- "line": 532
6852
+ "line": 548
6853
6853
  },
6854
6854
  "name": "status",
6855
6855
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -6878,7 +6878,7 @@
6878
6878
  "immutable": true,
6879
6879
  "locationInModule": {
6880
6880
  "filename": "src/providers/ec2.ts",
6881
- "line": 554
6881
+ "line": 570
6882
6882
  },
6883
6883
  "name": "connections",
6884
6884
  "overrides": "aws-cdk-lib.aws_ec2.IConnectable",
@@ -7021,7 +7021,7 @@
7021
7021
  {
7022
7022
  "abstract": true,
7023
7023
  "docs": {
7024
- "default": "m5.large",
7024
+ "default": "m6i.large",
7025
7025
  "stability": "experimental",
7026
7026
  "summary": "Instance type for launched runner instances."
7027
7027
  },
@@ -7360,7 +7360,7 @@
7360
7360
  },
7361
7361
  "locationInModule": {
7362
7362
  "filename": "src/providers/common.ts",
7363
- "line": 490
7363
+ "line": 492
7364
7364
  },
7365
7365
  "name": "labelsFromProperties",
7366
7366
  "parameters": [
@@ -7659,7 +7659,7 @@
7659
7659
  {
7660
7660
  "abstract": true,
7661
7661
  "docs": {
7662
- "default": "m5.large or m6g.large",
7662
+ "default": "m6i.large or m6g.large",
7663
7663
  "remarks": "Only used when creating a new cluster.",
7664
7664
  "stability": "experimental",
7665
7665
  "summary": "Instance type of ECS cluster instances."
@@ -8078,7 +8078,7 @@
8078
8078
  },
8079
8079
  "locationInModule": {
8080
8080
  "filename": "src/providers/common.ts",
8081
- "line": 490
8081
+ "line": 492
8082
8082
  },
8083
8083
  "name": "labelsFromProperties",
8084
8084
  "parameters": [
@@ -10384,7 +10384,7 @@
10384
10384
  },
10385
10385
  "locationInModule": {
10386
10386
  "filename": "src/providers/lambda.ts",
10387
- "line": 235
10387
+ "line": 222
10388
10388
  },
10389
10389
  "parameters": [
10390
10390
  {
@@ -10411,7 +10411,7 @@
10411
10411
  "kind": "class",
10412
10412
  "locationInModule": {
10413
10413
  "filename": "src/providers/lambda.ts",
10414
- "line": 471
10414
+ "line": 458
10415
10415
  },
10416
10416
  "name": "LambdaRunner",
10417
10417
  "symbolId": "src/providers/lambda:LambdaRunner"
@@ -10431,7 +10431,7 @@
10431
10431
  },
10432
10432
  "locationInModule": {
10433
10433
  "filename": "src/providers/lambda.ts",
10434
- "line": 235
10434
+ "line": 222
10435
10435
  },
10436
10436
  "parameters": [
10437
10437
  {
@@ -10466,13 +10466,13 @@
10466
10466
  "methods": [
10467
10467
  {
10468
10468
  "docs": {
10469
- "remarks": "You can customize the OS, architecture, VPC, subnet, security groups, etc. by passing in props.\n\nYou can add components to the image builder by calling `imageBuilder.addComponent()`.\n\nThe default OS is Amazon Linux 2 running on x64 architecture.\n\nIncluded components:\n * `RunnerImageComponent.requiredPackages()`\n * `RunnerImageComponent.runnerUser()`\n * `RunnerImageComponent.git()`\n * `RunnerImageComponent.githubCli()`\n * `RunnerImageComponent.awsCli()`\n * `RunnerImageComponent.githubRunner()`\n * `RunnerImageComponent.lambdaEntrypoint()`\n\n Base Docker image: `public.ecr.aws/lambda/nodejs:20-x86_64` or `public.ecr.aws/lambda/nodejs:20-arm64`",
10469
+ "remarks": "You can customize the OS, architecture, VPC, subnet, security groups, etc. by passing in props.\n\nYou can add components to the image builder by calling `imageBuilder.addComponent()`.\n\nThe default OS is Amazon Linux 2023 running on x64 architecture.\n\nIncluded components:\n * `RunnerImageComponent.requiredPackages()`\n * `RunnerImageComponent.runnerUser()`\n * `RunnerImageComponent.git()`\n * `RunnerImageComponent.githubCli()`\n * `RunnerImageComponent.awsCli()`\n * `RunnerImageComponent.githubRunner()`\n * `RunnerImageComponent.lambdaEntrypoint()`",
10470
10470
  "stability": "experimental",
10471
10471
  "summary": "Create new image builder that builds Lambda specific runner images."
10472
10472
  },
10473
10473
  "locationInModule": {
10474
10474
  "filename": "src/providers/lambda.ts",
10475
- "line": 169
10475
+ "line": 167
10476
10476
  },
10477
10477
  "name": "imageBuilder",
10478
10478
  "parameters": [
@@ -10511,7 +10511,7 @@
10511
10511
  },
10512
10512
  "locationInModule": {
10513
10513
  "filename": "src/providers/lambda.ts",
10514
- "line": 327
10514
+ "line": 314
10515
10515
  },
10516
10516
  "name": "getStepFunctionTask",
10517
10517
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -10540,7 +10540,7 @@
10540
10540
  },
10541
10541
  "locationInModule": {
10542
10542
  "filename": "src/providers/lambda.ts",
10543
- "line": 388
10543
+ "line": 375
10544
10544
  },
10545
10545
  "name": "grantStateMachine",
10546
10546
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -10559,7 +10559,7 @@
10559
10559
  },
10560
10560
  "locationInModule": {
10561
10561
  "filename": "src/providers/common.ts",
10562
- "line": 490
10562
+ "line": 492
10563
10563
  },
10564
10564
  "name": "labelsFromProperties",
10565
10565
  "parameters": [
@@ -10609,7 +10609,7 @@
10609
10609
  },
10610
10610
  "locationInModule": {
10611
10611
  "filename": "src/providers/lambda.ts",
10612
- "line": 391
10612
+ "line": 378
10613
10613
  },
10614
10614
  "name": "status",
10615
10615
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -10676,7 +10676,7 @@
10676
10676
  "immutable": true,
10677
10677
  "locationInModule": {
10678
10678
  "filename": "src/providers/lambda.ts",
10679
- "line": 316
10679
+ "line": 303
10680
10680
  },
10681
10681
  "name": "connections",
10682
10682
  "overrides": "aws-cdk-lib.aws_ec2.IConnectable",
@@ -10692,7 +10692,7 @@
10692
10692
  "immutable": true,
10693
10693
  "locationInModule": {
10694
10694
  "filename": "src/providers/lambda.ts",
10695
- "line": 200
10695
+ "line": 187
10696
10696
  },
10697
10697
  "name": "function",
10698
10698
  "type": {
@@ -10707,7 +10707,7 @@
10707
10707
  "immutable": true,
10708
10708
  "locationInModule": {
10709
10709
  "filename": "src/providers/lambda.ts",
10710
- "line": 210
10710
+ "line": 197
10711
10711
  },
10712
10712
  "name": "grantPrincipal",
10713
10713
  "overrides": "aws-cdk-lib.aws_iam.IGrantable",
@@ -10724,7 +10724,7 @@
10724
10724
  "immutable": true,
10725
10725
  "locationInModule": {
10726
10726
  "filename": "src/providers/lambda.ts",
10727
- "line": 215
10727
+ "line": 202
10728
10728
  },
10729
10729
  "name": "image",
10730
10730
  "type": {
@@ -10739,7 +10739,7 @@
10739
10739
  "immutable": true,
10740
10740
  "locationInModule": {
10741
10741
  "filename": "src/providers/lambda.ts",
10742
- "line": 205
10742
+ "line": 192
10743
10743
  },
10744
10744
  "name": "labels",
10745
10745
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -10761,7 +10761,7 @@
10761
10761
  "immutable": true,
10762
10762
  "locationInModule": {
10763
10763
  "filename": "src/providers/lambda.ts",
10764
- "line": 222
10764
+ "line": 209
10765
10765
  },
10766
10766
  "name": "logGroup",
10767
10767
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -10777,7 +10777,7 @@
10777
10777
  "immutable": true,
10778
10778
  "locationInModule": {
10779
10779
  "filename": "src/providers/lambda.ts",
10780
- "line": 224
10780
+ "line": 211
10781
10781
  },
10782
10782
  "name": "retryableErrors",
10783
10783
  "overrides": "@cloudsnorkel/cdk-github-runners.IRunnerProvider",
@@ -12629,7 +12629,7 @@
12629
12629
  },
12630
12630
  "locationInModule": {
12631
12631
  "filename": "src/image-builders/components.ts",
12632
- "line": 355
12632
+ "line": 371
12633
12633
  },
12634
12634
  "name": "docker",
12635
12635
  "returns": {
@@ -12647,7 +12647,7 @@
12647
12647
  },
12648
12648
  "locationInModule": {
12649
12649
  "filename": "src/image-builders/components.ts",
12650
- "line": 431
12650
+ "line": 447
12651
12651
  },
12652
12652
  "name": "dockerInDocker",
12653
12653
  "returns": {
@@ -12665,7 +12665,7 @@
12665
12665
  },
12666
12666
  "locationInModule": {
12667
12667
  "filename": "src/image-builders/components.ts",
12668
- "line": 534
12668
+ "line": 549
12669
12669
  },
12670
12670
  "name": "environmentVariables",
12671
12671
  "parameters": [
@@ -12696,7 +12696,7 @@
12696
12696
  },
12697
12697
  "locationInModule": {
12698
12698
  "filename": "src/image-builders/components.ts",
12699
- "line": 441
12699
+ "line": 457
12700
12700
  },
12701
12701
  "name": "extraCertificates",
12702
12702
  "parameters": [
@@ -12797,7 +12797,7 @@
12797
12797
  },
12798
12798
  "locationInModule": {
12799
12799
  "filename": "src/image-builders/components.ts",
12800
- "line": 491
12800
+ "line": 507
12801
12801
  },
12802
12802
  "name": "lambdaEntrypoint",
12803
12803
  "returns": {
@@ -12849,7 +12849,7 @@
12849
12849
  },
12850
12850
  "locationInModule": {
12851
12851
  "filename": "src/image-builders/components.ts",
12852
- "line": 571
12852
+ "line": 586
12853
12853
  },
12854
12854
  "name": "getAssets",
12855
12855
  "parameters": [
@@ -12886,7 +12886,7 @@
12886
12886
  },
12887
12887
  "locationInModule": {
12888
12888
  "filename": "src/image-builders/components.ts",
12889
- "line": 566
12889
+ "line": 581
12890
12890
  },
12891
12891
  "name": "getCommands",
12892
12892
  "parameters": [
@@ -12922,7 +12922,7 @@
12922
12922
  },
12923
12923
  "locationInModule": {
12924
12924
  "filename": "src/image-builders/components.ts",
12925
- "line": 580
12925
+ "line": 595
12926
12926
  },
12927
12927
  "name": "getDockerCommands",
12928
12928
  "parameters": [
@@ -12957,7 +12957,7 @@
12957
12957
  },
12958
12958
  "locationInModule": {
12959
12959
  "filename": "src/image-builders/components.ts",
12960
- "line": 587
12960
+ "line": 602
12961
12961
  },
12962
12962
  "name": "shouldReboot",
12963
12963
  "parameters": [
@@ -12993,7 +12993,7 @@
12993
12993
  "immutable": true,
12994
12994
  "locationInModule": {
12995
12995
  "filename": "src/image-builders/components.ts",
12996
- "line": 561
12996
+ "line": 576
12997
12997
  },
12998
12998
  "name": "name",
12999
12999
  "type": {
@@ -13893,6 +13893,6 @@
13893
13893
  "symbolId": "src/image-builders/aws-image-builder/deprecated/windows-components:WindowsComponents"
13894
13894
  }
13895
13895
  },
13896
- "version": "0.13.3",
13897
- "fingerprint": "dfYaDfyN7mD42+MHXxkTOor/4hjDsb6hFKCY0wh7b14="
13896
+ "version": "0.14.0",
13897
+ "fingerprint": "7BoZGUvfCNHNp7iRKhLHLvclapxTdkc7B5vqkzJ0rwg="
13898
13898
  }
package/API.md CHANGED
@@ -3876,7 +3876,7 @@ You can customize the OS, architecture, VPC, subnet, security groups, etc. by pa
3876
3876
 
3877
3877
  You can add components to the image builder by calling `imageBuilder.addComponent()`.
3878
3878
 
3879
- The default OS is Amazon Linux 2 running on x64 architecture.
3879
+ The default OS is Amazon Linux 2023 running on x64 architecture.
3880
3880
 
3881
3881
  Included components:
3882
3882
  * `RunnerImageComponent.requiredPackages()`
@@ -3887,8 +3887,6 @@ Included components:
3887
3887
  * `RunnerImageComponent.githubRunner()`
3888
3888
  * `RunnerImageComponent.lambdaEntrypoint()`
3889
3889
 
3890
- Base Docker image: `public.ecr.aws/lambda/nodejs:20-x86_64` or `public.ecr.aws/lambda/nodejs:20-arm64`
3891
-
3892
3890
  ###### `scope`<sup>Required</sup> <a name="scope" id="@cloudsnorkel/cdk-github-runners.LambdaRunner.imageBuilder.parameter.scope"></a>
3893
3891
 
3894
3892
  - *Type:* constructs.Construct
@@ -4242,7 +4240,7 @@ You can customize the OS, architecture, VPC, subnet, security groups, etc. by pa
4242
4240
 
4243
4241
  You can add components to the image builder by calling `imageBuilder.addComponent()`.
4244
4242
 
4245
- The default OS is Amazon Linux 2 running on x64 architecture.
4243
+ The default OS is Amazon Linux 2023 running on x64 architecture.
4246
4244
 
4247
4245
  Included components:
4248
4246
  * `RunnerImageComponent.requiredPackages()`
@@ -4253,8 +4251,6 @@ Included components:
4253
4251
  * `RunnerImageComponent.githubRunner()`
4254
4252
  * `RunnerImageComponent.lambdaEntrypoint()`
4255
4253
 
4256
- Base Docker image: `public.ecr.aws/lambda/nodejs:20-x86_64` or `public.ecr.aws/lambda/nodejs:20-arm64`
4257
-
4258
4254
  ###### `scope`<sup>Required</sup> <a name="scope" id="@cloudsnorkel/cdk-github-runners.LambdaRunnerProvider.imageBuilder.parameter.scope"></a>
4259
4255
 
4260
4256
  - *Type:* constructs.Construct
@@ -4884,7 +4880,7 @@ public readonly instanceType: InstanceType;
4884
4880
  ```
4885
4881
 
4886
4882
  - *Type:* aws-cdk-lib.aws_ec2.InstanceType
4887
- - *Default:* m5.large
4883
+ - *Default:* m6i.large
4888
4884
 
4889
4885
  The instance type used to build the image.
4890
4886
 
@@ -5145,7 +5141,7 @@ public readonly instanceType: InstanceType;
5145
5141
  ```
5146
5142
 
5147
5143
  - *Type:* aws-cdk-lib.aws_ec2.InstanceType
5148
- - *Default:* m5.large
5144
+ - *Default:* m6i.large
5149
5145
 
5150
5146
  The instance type used to build the image.
5151
5147
 
@@ -5701,7 +5697,7 @@ public readonly instanceType: InstanceType;
5701
5697
  ```
5702
5698
 
5703
5699
  - *Type:* aws-cdk-lib.aws_ec2.InstanceType
5704
- - *Default:* m5.large
5700
+ - *Default:* m6i.large
5705
5701
 
5706
5702
  The instance type used to build the image.
5707
5703
 
@@ -5949,7 +5945,7 @@ public readonly instanceType: InstanceType;
5949
5945
  ```
5950
5946
 
5951
5947
  - *Type:* aws-cdk-lib.aws_ec2.InstanceType
5952
- - *Default:* m5.large
5948
+ - *Default:* m6i.large
5953
5949
 
5954
5950
  Instance type for launched runner instances.
5955
5951
 
@@ -6250,7 +6246,7 @@ public readonly instanceType: InstanceType;
6250
6246
  ```
6251
6247
 
6252
6248
  - *Type:* aws-cdk-lib.aws_ec2.InstanceType
6253
- - *Default:* m5.large or m6g.large
6249
+ - *Default:* m6i.large or m6g.large
6254
6250
 
6255
6251
  Instance type of ECS cluster instances.
6256
6252
 
package/README.md CHANGED
@@ -10,11 +10,11 @@
10
10
 
11
11
  Use this CDK construct to create ephemeral [self-hosted GitHub runners][1] on-demand inside your AWS account.
12
12
 
13
- * Easy to configure GitHub integration with a web-based interface
14
- * Customizable runners with decent defaults
15
- * Multiple runner configurations controlled by labels
16
- * Everything fully hosted in your account
17
- * Automatically updated build environment with latest runner version
13
+ * 🧩 Easy to configure GitHub integration with a web-based interface
14
+ * 🧠 Customizable runners with decent defaults
15
+ * 🏃🏻 Multiple runner configurations controlled by labels
16
+ * 🔐 Everything fully hosted in your account
17
+ * 🔃 Automatically updated build environment with latest runner version
18
18
 
19
19
  Self-hosted runners in AWS are useful when:
20
20
 
@@ -292,6 +292,18 @@ Other useful metrics to track:
292
292
  1. Use `GitHubRunners.metricJobCompleted()` to get a metric for the number of completed jobs broken down by labels and job success.
293
293
  2. Use `GitHubRunners.metricTime()` to get a metric for the total time a runner is running. This includes the overhead of starting the runner.
294
294
 
295
+ ## Contributing
296
+
297
+ If you use and love this project, please consider contributing.
298
+
299
+ 1. 🪳 If you see something, say something. [Issues][16] help improve the quality of the project.
300
+ * Include relevant logs and package versions for bugs.
301
+ * When possible, describe the use-case behind feature requests.
302
+ 1. 🛠️ [Pull requests][17] are welcome.
303
+ * Run `npm run build` before submitting to make sure all tests pass.
304
+ * Allow edits from maintainers so small adjustments can be made easily.
305
+ 1. 💵 Consider [sponsoring][15] the project to show your support and optionally get your name listed below.
306
+
295
307
  ## Other Options
296
308
 
297
309
  1. [philips-labs/terraform-aws-github-runner][3] if you're using Terraform
@@ -312,3 +324,6 @@ Other useful metrics to track:
312
324
  [12]: https://www.nuget.org/packages/CloudSnorkel.Cdk.Github.Runners/
313
325
  [13]: https://constructs.dev/packages/@cloudsnorkel/cdk-github-runners/
314
326
  [14]: https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#using-ephemeral-runners-for-autoscaling
327
+ [15]: https://github.com/sponsors/CloudSnorkel
328
+ [16]: https://github.com/CloudSnorkel/cdk-github-runners/issues
329
+ [17]: https://github.com/CloudSnorkel/cdk-github-runners/pulls
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ while true
6
+ do
7
+ # get data from lambda
8
+ HEADERS="$(mktemp)"
9
+ EVENT_DATA=$(curl -sS -LD "$HEADERS" "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next")
10
+ REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
11
+
12
+ # execute runner and respond
13
+ if bash /runner.sh "$EVENT_DATA"; then
14
+ curl "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d ""
15
+ else
16
+ curl "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/error" -d "{\"errorMessage\": \"Runner failed with exit code $?\", \"errorType\": \"Error\", \"stackTrace\": []}"
17
+ fi
18
+
19
+ # cleanup
20
+ find /tmp -mindepth 1 -maxdepth 1 -exec rm -rf '{}' \;
21
+ done
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ # workaround for "Cannot get required symbol EVP_rc2_cbc from libssl"
6
+ # lambda docker image for node.js comes with stripped down libssl.so pushed in LD_LIBRARY_PATH
7
+ if [ -f /var/lang/lib/libssl.so ]; then
8
+ export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH
9
+ fi
10
+
11
+ # extract parameters
12
+ OWNER=$(echo "$1" | jq -r .owner)
13
+ REPO=$(echo "$1" | jq -r .repo)
14
+ GITHUB_DOMAIN=$(echo "$1" | jq -r .githubDomain)
15
+ RUNNER_TOKEN=$(echo "$1" | jq -r .token)
16
+ RUNNER_NAME=$(echo "$1" | jq -r .runnerName)
17
+ RUNNER_LABEL=$(echo "$1" | jq -r .label)
18
+ REGISTRATION_URL=$(echo "$1" | jq -r .registrationUrl)
19
+
20
+ # copy runner code (it needs a writable directory)
21
+ cp -r /home/runner /tmp/
22
+ cd /tmp/runner
23
+
24
+ # setup home directory
25
+ mkdir /tmp/home
26
+ export HOME=/tmp/home
27
+
28
+ # start runner
29
+ if [ "${RUNNER_VERSION}" = "latest" ]; then RUNNER_FLAGS=""; else RUNNER_FLAGS="--disableupdate"; fi
30
+ ./config.sh --unattended --url "${REGISTRATION_URL}" --token "${RUNNER_TOKEN}" --ephemeral --work _work --labels "${RUNNER_LABEL},cdkghr:started:`date +%s`" --name "${RUNNER_NAME}" ${RUNNER_FLAGS}
31
+ echo Config done
32
+ ./run.sh
33
+ echo Run done
34
+
35
+ # print status for metrics
36
+ STATUS=$(grep -Phors "finish job request for job [0-9a-f\-]+ with result: \K.*" _diag/ | tail -n1)
37
+ [ -n "$STATUS" ] && echo CDKGHA JOB DONE "$RUNNER_LABEL" "$STATUS"
package/lib/access.js CHANGED
@@ -59,7 +59,7 @@ class LambdaAccess {
59
59
  }
60
60
  exports.LambdaAccess = LambdaAccess;
61
61
  _a = JSII_RTTI_SYMBOL_1;
62
- LambdaAccess[_a] = { fqn: "@cloudsnorkel/cdk-github-runners.LambdaAccess", version: "0.13.3" };
62
+ LambdaAccess[_a] = { fqn: "@cloudsnorkel/cdk-github-runners.LambdaAccess", version: "0.14.0" };
63
63
  /**
64
64
  * @internal
65
65
  */
@@ -43,5 +43,5 @@ class RunnerImageBuilder extends common_1.RunnerImageBuilderBase {
43
43
  }
44
44
  exports.RunnerImageBuilder = RunnerImageBuilder;
45
45
  _a = JSII_RTTI_SYMBOL_1;
46
- RunnerImageBuilder[_a] = { fqn: "@cloudsnorkel/cdk-github-runners.RunnerImageBuilder", version: "0.13.3" };
46
+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ZvciAke29zLm5hbWV9YCk7XG4gICAgfVxuICB9XG59XG4iXX0=
@@ -8,7 +8,7 @@ export interface AwsImageBuilderRunnerImageBuilderProps {
8
8
  /**
9
9
  * The instance type used to build the image.
10
10
  *
11
- * @default m5.large
11
+ * @default m6i.large
12
12
  */
13
13
  readonly instanceType?: ec2.InstanceType;
14
14
  /**