@cloudsnorkel/cdk-github-runners 0.9.5 → 0.9.6

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 (39) hide show
  1. package/.gitattributes +2 -0
  2. package/.jsii +27 -27
  3. package/API.md +12 -12
  4. package/README.md +120 -63
  5. package/assets/image-builders/aws-image-builder/reaper.lambda/index.js +163 -0
  6. package/cdk.json +10 -0
  7. package/lib/access.js +1 -1
  8. package/lib/image-builders/api.js +1 -1
  9. package/lib/image-builders/aws-image-builder/builder.d.ts +1 -1
  10. package/lib/image-builders/aws-image-builder/builder.js +60 -21
  11. package/lib/image-builders/aws-image-builder/deprecated/ami.d.ts +2 -2
  12. package/lib/image-builders/aws-image-builder/deprecated/ami.js +4 -4
  13. package/lib/image-builders/aws-image-builder/deprecated/container.d.ts +2 -2
  14. package/lib/image-builders/aws-image-builder/deprecated/container.js +4 -4
  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/aws-image-builder/reaper-function.d.ts +13 -0
  18. package/lib/image-builders/aws-image-builder/reaper-function.js +23 -0
  19. package/lib/image-builders/aws-image-builder/reaper.lambda.d.ts +1 -0
  20. package/lib/image-builders/aws-image-builder/reaper.lambda.js +149 -0
  21. package/lib/image-builders/codebuild-deprecated.d.ts +3 -3
  22. package/lib/image-builders/codebuild-deprecated.js +5 -5
  23. package/lib/image-builders/codebuild.d.ts +1 -1
  24. package/lib/image-builders/codebuild.js +20 -18
  25. package/lib/image-builders/common.d.ts +2 -2
  26. package/lib/image-builders/common.js +1 -1
  27. package/lib/image-builders/components.js +4 -4
  28. package/lib/image-builders/static.js +1 -1
  29. package/lib/providers/codebuild.js +2 -2
  30. package/lib/providers/common.js +3 -3
  31. package/lib/providers/ec2.d.ts +1 -1
  32. package/lib/providers/ec2.js +3 -3
  33. package/lib/providers/ecs.js +1 -1
  34. package/lib/providers/fargate.js +2 -2
  35. package/lib/providers/lambda.js +2 -2
  36. package/lib/runner.d.ts +3 -3
  37. package/lib/runner.js +5 -5
  38. package/lib/secrets.js +1 -1
  39. package/package.json +3 -1
package/.gitattributes CHANGED
@@ -22,11 +22,13 @@
22
22
  /.projen/files.json linguist-generated
23
23
  /.projen/tasks.json linguist-generated
24
24
  /API.md linguist-generated
25
+ /cdk.json linguist-generated
25
26
  /LICENSE linguist-generated
26
27
  /package.json linguist-generated
27
28
  /src/delete-runner-function.ts linguist-generated
28
29
  /src/image-builders/aws-image-builder/delete-ami-function.ts linguist-generated
29
30
  /src/image-builders/aws-image-builder/filter-failed-builds-function.ts linguist-generated
31
+ /src/image-builders/aws-image-builder/reaper-function.ts linguist-generated
30
32
  /src/image-builders/aws-image-builder/versioner-function.ts linguist-generated
31
33
  /src/providers/build-image-function.ts linguist-generated
32
34
  /src/providers/update-lambda-function.ts linguist-generated
package/.jsii CHANGED
@@ -3138,7 +3138,7 @@
3138
3138
  },
3139
3139
  "name": "@cloudsnorkel/cdk-github-runners",
3140
3140
  "readme": {
3141
- "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. Confirm you're using CDK v2\n2. Install the appropriate package\n 1. [Python][6]\n ```\n pip install cloudsnorkel.cdk-github-runners\n ```\n 2. [TypeScript or JavaScript][7]\n ```\n npm i @cloudsnorkel/cdk-github-runners\n ```\n 3. [Java][8]\n ```xml\n <dependency>\n <groupId>com.cloudsnorkel</groupId>\n <artifactId>cdk.github.runners</artifactId>\n </dependency>\n ```\n 4. [Go][11]\n ```\n go get github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners\n ```\n 5. [.NET][12]\n ```\n dotnet add package CloudSnorkel.Cdk.Github.Runners\n ```\n3. Use `GitHubRunners` construct in your code (starting with default arguments is fine)\n4. Deploy your stack\n5. Look for the status command output similar to `aws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json`\n6. Execute the status command (you may need to specify `--profile` too) and open the resulting `status.json` file\n7. 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\n8. Run status command again to confirm `github.auth.status` and `github.webhook.status` are OK\n9. Trigger a GitHub action that has a `self-hosted` label with `runs-on: [self-hosted, linux, codebuild]` or similar\n10. 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 label: 'my-codebuild',\n vpc: vpc,\n securityGroup: 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 = CodeBuildRunnerProvider.imageBuilder(this, 'image builder', {\n dockerfilePath: FargateRunner.LINUX_X64_DOCKERFILE_PATH,\n runnerVersion: RunnerVersion.specific('2.291.0'),\n rebuildInterval: Duration.days(14),\n});\nmyBuilder.addComponent(\n RunnerImageComponent.custom({ commands: ['apt install -y nginx xz-utils'] })\n);\n\nconst myProvider = new FargateRunnerProvider(this, 'fargate runner', {\n label: 'customized-fargate',\n vpc: vpc,\n securityGroup: runnerSg,\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 runnerVersion: RunnerVersion.specific('2.291.0'),\n rebuildInterval: Duration.days(14),\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 label: 'customized-windows-fargate',\n vpc: vpc,\n securityGroup: runnerSg,\n imageBuidler: 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 imageBuidler: FargateRunnerProvider.imageBuilder(this, 'image builder', {\n architecture: Architecture.ARM64,\n os: Os.LINUX,\n }),\n }),\n ],\n});\n```\n\n## Architecture\n\n![Architecture diagram](architecture.svg)\n\n## Troubleshooting\n\n1. Always start with the status function, make sure no errors are reported, and confirm all status codes are OK\n2. If jobs are stuck on pending:\n 1. Make sure `runs-on` in the workflow matches the expected labels set in the runner provider\n 2. If jobs get stuck often and take a long time to start, cancel the pending jobs and start them again\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 installation in `github.auth.app.installations`\n6. Check execution details of the orchestrator step function by visiting the URL in `troubleshooting.stepFunctionUrl` from `status.json`\n 1. Use the details tab to find the specific execution of the provider (Lambda, CodeBuild, Fargate, etc.)\n 2. Every step function execution should be successful, even if the runner action inside it failed\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-action-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://search.maven.org/search?q=g:%22com.cloudsnorkel%22%20AND%20a:%22cdk.github.runners%22\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"
3141
+ "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 = CodeBuildRunnerProvider.imageBuilder(this, 'image builder', {\n dockerfilePath: FargateRunner.LINUX_X64_DOCKERFILE_PATH,\n runnerVersion: RunnerVersion.specific('2.291.0'),\n rebuildInterval: Duration.days(14),\n});\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 vpc: vpc,\n securityGroups: [runnerSg],\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 runnerVersion: RunnerVersion.specific('2.291.0'),\n rebuildInterval: Duration.days(14),\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 vpc: vpc,\n securityGroups: [runnerSg],\n imageBuidler: 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 imageBuidler: 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\n1. Always start with the status function, make sure no errors are reported, and confirm all status codes are OK\n2. If jobs are stuck on pending:\n 1. Make sure `runs-on` in the workflow matches the expected labels set in the runner provider\n 2. If jobs get stuck often and take a long time to start, cancel the pending jobs and start them again\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 installation in `github.auth.app.installations`\n6. Check execution details of the orchestrator step function by visiting the URL in `troubleshooting.stepFunctionUrl` from `status.json`\n 1. Use the details tab to find the specific execution of the provider (Lambda, CodeBuild, Fargate, etc.)\n 2. Every step function execution should be successful, even if the runner action inside it failed\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-action-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"
3142
3142
  },
3143
3143
  "repository": {
3144
3144
  "type": "git",
@@ -3174,7 +3174,7 @@
3174
3174
  "base": "constructs.Construct",
3175
3175
  "docs": {
3176
3176
  "deprecated": "use RunnerImageBuilder",
3177
- "remarks": "Builders can be used with {@link Ec2Runner }.\n\nEach builder re-runs automatically at a set interval to make sure the AMIs contain the latest versions of everything.\n\nYou can create an instance of this construct to customize the AMI used to spin-up runners. Some runner providers may require custom components. Check the runner provider documentation.\n\nFor example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the EC2 provider, use:\n\n```\nconst builder = new AmiBuilder(this, 'Builder', {\n runnerVersion: RunnerVersion.specific('2.293.0'),\n rebuildInterval: Duration.days(14),\n});\nbuilder.addComponent(new ImageBuilderComponent(scope, id, {\n platform: 'Linux',\n displayName: 'p7zip',\n description: 'Install some more packages',\n commands: [\n 'apt-get install p7zip',\n ],\n}));\nnew Ec2Runner(this, 'EC2 provider', {\n label: 'custom-ec2',\n amiBuilder: builder,\n});\n```",
3177
+ "remarks": "Builders can be used with {@link Ec2Runner }.\n\nEach builder re-runs automatically at a set interval to make sure the AMIs contain the latest versions of everything.\n\nYou can create an instance of this construct to customize the AMI used to spin-up runners. Some runner providers may require custom components. Check the runner provider documentation.\n\nFor example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the EC2 provider, use:\n\n```\nconst builder = new AmiBuilder(this, 'Builder', {\n runnerVersion: RunnerVersion.specific('2.293.0'),\n rebuildInterval: Duration.days(14),\n});\nbuilder.addComponent(new ImageBuilderComponent(scope, id, {\n platform: 'Linux',\n displayName: 'p7zip',\n description: 'Install some more packages',\n commands: [\n 'apt-get install p7zip',\n ],\n}));\nnew Ec2RunnerProvider(this, 'EC2 provider', {\n labels: ['custom-ec2'],\n amiBuilder: builder,\n});\n```",
3178
3178
  "stability": "deprecated",
3179
3179
  "summary": "An AMI builder that uses AWS Image Builder to build AMIs pre-baked with all the GitHub Actions runner requirements."
3180
3180
  },
@@ -4070,7 +4070,7 @@
4070
4070
  "kind": "interface",
4071
4071
  "locationInModule": {
4072
4072
  "filename": "src/image-builders/aws-image-builder/builder.ts",
4073
- "line": 32
4073
+ "line": 33
4074
4074
  },
4075
4075
  "name": "AwsImageBuilderRunnerImageBuilderProps",
4076
4076
  "properties": [
@@ -4084,7 +4084,7 @@
4084
4084
  "immutable": true,
4085
4085
  "locationInModule": {
4086
4086
  "filename": "src/image-builders/aws-image-builder/builder.ts",
4087
- "line": 38
4087
+ "line": 39
4088
4088
  },
4089
4089
  "name": "instanceType",
4090
4090
  "optional": true,
@@ -4100,7 +4100,7 @@
4100
4100
  "base": "constructs.Construct",
4101
4101
  "docs": {
4102
4102
  "deprecated": "use RunnerImageBuilder",
4103
- "remarks": "Builders can be used with runner providers.\n\nEach builder re-runs automatically at a set interval to make sure the images contain the latest versions of everything.\n\nYou can create an instance of this construct to customize the image used to spin-up runners. Each provider has its own requirements for what an image should do. That's why they each provide their own Dockerfile.\n\nFor example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the Fargate provider, use:\n\n```\nconst builder = new CodeBuildImageBuilder(this, 'Builder', {\n dockerfilePath: FargateProvider.LINUX_X64_DOCKERFILE_PATH,\n runnerVersion: RunnerVersion.specific('2.293.0'),\n rebuildInterval: Duration.days(14),\n});\nbuilder.setBuildArg('EXTRA_PACKAGES', 'nginx xz-utils');\nnew FargateRunner(this, 'Fargate provider', {\n label: 'customized-fargate',\n imageBuilder: builder,\n});\n```",
4103
+ "remarks": "Builders can be used with runner providers.\n\nEach builder re-runs automatically at a set interval to make sure the images contain the latest versions of everything.\n\nYou can create an instance of this construct to customize the image used to spin-up runners. Each provider has its own requirements for what an image should do. That's why they each provide their own Dockerfile.\n\nFor example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the Fargate provider, use:\n\n```\nconst builder = new CodeBuildImageBuilder(this, 'Builder', {\n dockerfilePath: FargateRunnerProvider.LINUX_X64_DOCKERFILE_PATH,\n runnerVersion: RunnerVersion.specific('2.293.0'),\n rebuildInterval: Duration.days(14),\n});\nbuilder.setBuildArg('EXTRA_PACKAGES', 'nginx xz-utils');\nnew FargateRunnerProvider(this, 'Fargate provider', {\n labels: ['customized-fargate'],\n imageBuilder: builder,\n});\n```",
4104
4104
  "stability": "deprecated",
4105
4105
  "summary": "An image builder that uses CodeBuild to build Docker images pre-baked with all the GitHub Actions runner requirements."
4106
4106
  },
@@ -5358,7 +5358,7 @@
5358
5358
  "base": "constructs.Construct",
5359
5359
  "docs": {
5360
5360
  "deprecated": "use RunnerImageBuilder",
5361
- "remarks": "Builders can be used with runner providers.\n\nThe CodeBuild builder is better and faster. Only use this one if you have no choice. For example, if you need Windows containers.\n\nEach builder re-runs automatically at a set interval to make sure the images contain the latest versions of everything.\n\nYou can create an instance of this construct to customize the image used to spin-up runners. Some runner providers may require custom components. Check the runner provider documentation. The default components work with CodeBuild and Fargate.\n\nFor example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the Fargate provider, use:\n\n```\nconst builder = new ContainerImageBuilder(this, 'Builder', {\n runnerVersion: RunnerVersion.specific('2.293.0'),\n rebuildInterval: Duration.days(14),\n});\nnew CodeBuildRunner(this, 'CodeBuild provider', {\n label: 'custom-codebuild',\n imageBuilder: builder,\n});\n```",
5361
+ "remarks": "Builders can be used with runner providers.\n\nThe CodeBuild builder is better and faster. Only use this one if you have no choice. For example, if you need Windows containers.\n\nEach builder re-runs automatically at a set interval to make sure the images contain the latest versions of everything.\n\nYou can create an instance of this construct to customize the image used to spin-up runners. Some runner providers may require custom components. Check the runner provider documentation. The default components work with CodeBuild and Fargate.\n\nFor example, to set a specific runner version, rebuild the image every 2 weeks, and add a few packages for the Fargate provider, use:\n\n```\nconst builder = new ContainerImageBuilder(this, 'Builder', {\n runnerVersion: RunnerVersion.specific('2.293.0'),\n rebuildInterval: Duration.days(14),\n});\nnew CodeBuildRunnerProvider(this, 'CodeBuild provider', {\n labels: ['custom-codebuild'],\n imageBuilder: builder,\n});\n```",
5362
5362
  "stability": "deprecated",
5363
5363
  "summary": "An image builder that uses AWS Image Builder to build Docker images pre-baked with all the GitHub Actions runner requirements."
5364
5364
  },
@@ -6435,7 +6435,7 @@
6435
6435
  {
6436
6436
  "abstract": true,
6437
6437
  "docs": {
6438
- "default": "Ec2ProviderProps.imageBuilder()",
6438
+ "default": "Ec2RunnerProvider.imageBuilder()",
6439
6439
  "remarks": "The image builder determines the OS and architecture of the runner.",
6440
6440
  "stability": "experimental",
6441
6441
  "summary": "Runner image builder used to build AMI containing GitHub Runner and all requirements."
@@ -8115,7 +8115,7 @@
8115
8115
  "assembly": "@cloudsnorkel/cdk-github-runners",
8116
8116
  "base": "constructs.Construct",
8117
8117
  "docs": {
8118
- "remarks": "It creates a webhook, secrets, and a step function to orchestrate all runs. Secrets are not automatically filled. See README.md for instructions on how to setup GitHub integration.\n\nBy default, this will create a runner provider of each available type with the defaults. This is good enough for the initial setup stage when you just want to get GitHub integration working.\n\n```typescript\nnew GitHubRunners(this, 'runners');\n```\n\nUsually you'd want to configure the runner providers so the runners can run in a certain VPC or have certain permissions.\n\n```typescript\nconst vpc = ec2.Vpc.fromLookup(this, 'vpc', { vpcId: 'vpc-1234567' });\nconst runnerSg = new ec2.SecurityGroup(this, 'runner security group', { vpc: vpc });\nconst dbSg = ec2.SecurityGroup.fromSecurityGroupId(this, 'database security group', 'sg-1234567');\nconst bucket = new s3.Bucket(this, 'runner bucket');\n\n// create a custom CodeBuild provider\nconst myProvider = new CodeBuildRunner(\n this, 'codebuild runner',\n {\n label: 'my-codebuild',\n vpc: vpc,\n securityGroup: runnerSg,\n },\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(\n this,\n 'runners',\n {\n providers: [myProvider],\n }\n);\n```",
8118
+ "remarks": "It creates a webhook, secrets, and a step function to orchestrate all runs. Secrets are not automatically filled. See README.md for instructions on how to setup GitHub integration.\n\nBy default, this will create a runner provider of each available type with the defaults. This is good enough for the initial setup stage when you just want to get GitHub integration working.\n\n```typescript\nnew GitHubRunners(this, 'runners');\n```\n\nUsually you'd want to configure the runner providers so the runners can run in a certain VPC or have certain permissions.\n\n```typescript\nconst vpc = ec2.Vpc.fromLookup(this, 'vpc', { vpcId: 'vpc-1234567' });\nconst runnerSg = new ec2.SecurityGroup(this, 'runner security group', { vpc: vpc });\nconst dbSg = ec2.SecurityGroup.fromSecurityGroupId(this, 'database security group', 'sg-1234567');\nconst bucket = new s3.Bucket(this, 'runner bucket');\n\n// create a custom CodeBuild provider\nconst myProvider = new CodeBuildRunnerProvider(\n this, 'codebuild runner',\n {\n labels: ['my-codebuild'],\n vpc: vpc,\n securityGroups: [runnerSg],\n },\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(\n this,\n 'runners',\n {\n providers: [myProvider],\n }\n);\n```",
8119
8119
  "stability": "experimental",
8120
8120
  "summary": "Create all the required infrastructure to provide self-hosted GitHub runners."
8121
8121
  },
@@ -9048,7 +9048,7 @@
9048
9048
  "kind": "interface",
9049
9049
  "locationInModule": {
9050
9050
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9051
- "line": 44
9051
+ "line": 45
9052
9052
  },
9053
9053
  "name": "ImageBuilderAsset",
9054
9054
  "properties": [
@@ -9061,7 +9061,7 @@
9061
9061
  "immutable": true,
9062
9062
  "locationInModule": {
9063
9063
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9064
- "line": 53
9064
+ "line": 54
9065
9065
  },
9066
9066
  "name": "asset",
9067
9067
  "type": {
@@ -9077,7 +9077,7 @@
9077
9077
  "immutable": true,
9078
9078
  "locationInModule": {
9079
9079
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9080
- "line": 48
9080
+ "line": 49
9081
9081
  },
9082
9082
  "name": "path",
9083
9083
  "type": {
@@ -9103,7 +9103,7 @@
9103
9103
  },
9104
9104
  "locationInModule": {
9105
9105
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9106
- "line": 127
9106
+ "line": 128
9107
9107
  },
9108
9108
  "parameters": [
9109
9109
  {
@@ -9129,7 +9129,7 @@
9129
9129
  "kind": "class",
9130
9130
  "locationInModule": {
9131
9131
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9132
- "line": 114
9132
+ "line": 115
9133
9133
  },
9134
9134
  "methods": [
9135
9135
  {
@@ -9139,7 +9139,7 @@
9139
9139
  },
9140
9140
  "locationInModule": {
9141
9141
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9142
- "line": 229
9142
+ "line": 230
9143
9143
  },
9144
9144
  "name": "grantAssetsRead",
9145
9145
  "parameters": [
@@ -9157,7 +9157,7 @@
9157
9157
  },
9158
9158
  "locationInModule": {
9159
9159
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9160
- "line": 235
9160
+ "line": 236
9161
9161
  },
9162
9162
  "name": "prefixCommandsWithErrorHandling",
9163
9163
  "parameters": [
@@ -9237,7 +9237,7 @@
9237
9237
  "immutable": true,
9238
9238
  "locationInModule": {
9239
9239
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9240
- "line": 118
9240
+ "line": 119
9241
9241
  },
9242
9242
  "name": "arn",
9243
9243
  "type": {
@@ -9252,7 +9252,7 @@
9252
9252
  "immutable": true,
9253
9253
  "locationInModule": {
9254
9254
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9255
- "line": 123
9255
+ "line": 124
9256
9256
  },
9257
9257
  "name": "platform",
9258
9258
  "type": {
@@ -9273,7 +9273,7 @@
9273
9273
  "kind": "interface",
9274
9274
  "locationInModule": {
9275
9275
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9276
- "line": 59
9276
+ "line": 60
9277
9277
  },
9278
9278
  "name": "ImageBuilderComponentProperties",
9279
9279
  "properties": [
@@ -9287,7 +9287,7 @@
9287
9287
  "immutable": true,
9288
9288
  "locationInModule": {
9289
9289
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9290
- "line": 80
9290
+ "line": 81
9291
9291
  },
9292
9292
  "name": "commands",
9293
9293
  "type": {
@@ -9308,7 +9308,7 @@
9308
9308
  "immutable": true,
9309
9309
  "locationInModule": {
9310
9310
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9311
- "line": 73
9311
+ "line": 74
9312
9312
  },
9313
9313
  "name": "description",
9314
9314
  "type": {
@@ -9324,7 +9324,7 @@
9324
9324
  "immutable": true,
9325
9325
  "locationInModule": {
9326
9326
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9327
- "line": 68
9327
+ "line": 69
9328
9328
  },
9329
9329
  "name": "displayName",
9330
9330
  "type": {
@@ -9341,7 +9341,7 @@
9341
9341
  "immutable": true,
9342
9342
  "locationInModule": {
9343
9343
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9344
- "line": 63
9344
+ "line": 64
9345
9345
  },
9346
9346
  "name": "platform",
9347
9347
  "type": {
@@ -9357,7 +9357,7 @@
9357
9357
  "immutable": true,
9358
9358
  "locationInModule": {
9359
9359
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9360
- "line": 85
9360
+ "line": 86
9361
9361
  },
9362
9362
  "name": "assets",
9363
9363
  "optional": true,
@@ -9380,7 +9380,7 @@
9380
9380
  "immutable": true,
9381
9381
  "locationInModule": {
9382
9382
  "filename": "src/image-builders/aws-image-builder/builder.ts",
9383
- "line": 92
9383
+ "line": 93
9384
9384
  },
9385
9385
  "name": "reboot",
9386
9386
  "optional": true,
@@ -11507,7 +11507,7 @@
11507
11507
  {
11508
11508
  "abstract": true,
11509
11509
  "docs": {
11510
- "default": "OS.LINUX",
11510
+ "default": "OS.LINUX_UBUNTU",
11511
11511
  "stability": "experimental",
11512
11512
  "summary": "Image OS."
11513
11513
  },
@@ -12940,6 +12940,6 @@
12940
12940
  "symbolId": "src/image-builders/aws-image-builder/deprecated/windows-components:WindowsComponents"
12941
12941
  }
12942
12942
  },
12943
- "version": "0.9.5",
12944
- "fingerprint": "V+KyphB/VHigagS07H6ZFAsLHZDxDcwHuUU2M43SHDw="
12943
+ "version": "0.9.6",
12944
+ "fingerprint": "dXLB8R7bVjXz9NvFFt0Yd2eBeyqrjen4wC9L+uovCr0="
12945
12945
  }
package/API.md CHANGED
@@ -29,8 +29,8 @@ builder.addComponent(new ImageBuilderComponent(scope, id, {
29
29
  'apt-get install p7zip',
30
30
  ],
31
31
  }));
32
- new Ec2Runner(this, 'EC2 provider', {
33
- label: 'custom-ec2',
32
+ new Ec2RunnerProvider(this, 'EC2 provider', {
33
+ labels: ['custom-ec2'],
34
34
  amiBuilder: builder,
35
35
  });
36
36
  ```
@@ -240,13 +240,13 @@ For example, to set a specific runner version, rebuild the image every 2 weeks,
240
240
 
241
241
  ```
242
242
  const builder = new CodeBuildImageBuilder(this, 'Builder', {
243
- dockerfilePath: FargateProvider.LINUX_X64_DOCKERFILE_PATH,
243
+ dockerfilePath: FargateRunnerProvider.LINUX_X64_DOCKERFILE_PATH,
244
244
  runnerVersion: RunnerVersion.specific('2.293.0'),
245
245
  rebuildInterval: Duration.days(14),
246
246
  });
247
247
  builder.setBuildArg('EXTRA_PACKAGES', 'nginx xz-utils');
248
- new FargateRunner(this, 'Fargate provider', {
249
- label: 'customized-fargate',
248
+ new FargateRunnerProvider(this, 'Fargate provider', {
249
+ labels: ['customized-fargate'],
250
250
  imageBuilder: builder,
251
251
  });
252
252
  ```
@@ -1221,8 +1221,8 @@ const builder = new ContainerImageBuilder(this, 'Builder', {
1221
1221
  runnerVersion: RunnerVersion.specific('2.293.0'),
1222
1222
  rebuildInterval: Duration.days(14),
1223
1223
  });
1224
- new CodeBuildRunner(this, 'CodeBuild provider', {
1225
- label: 'custom-codebuild',
1224
+ new CodeBuildRunnerProvider(this, 'CodeBuild provider', {
1225
+ labels: ['custom-codebuild'],
1226
1226
  imageBuilder: builder,
1227
1227
  });
1228
1228
  ```
@@ -3039,12 +3039,12 @@ const dbSg = ec2.SecurityGroup.fromSecurityGroupId(this, 'database security grou
3039
3039
  const bucket = new s3.Bucket(this, 'runner bucket');
3040
3040
 
3041
3041
  // create a custom CodeBuild provider
3042
- const myProvider = new CodeBuildRunner(
3042
+ const myProvider = new CodeBuildRunnerProvider(
3043
3043
  this, 'codebuild runner',
3044
3044
  {
3045
- label: 'my-codebuild',
3045
+ labels: ['my-codebuild'],
3046
3046
  vpc: vpc,
3047
- securityGroup: runnerSg,
3047
+ securityGroups: [runnerSg],
3048
3048
  },
3049
3049
  );
3050
3050
  // grant some permissions to the provider
@@ -5693,7 +5693,7 @@ public readonly imageBuilder: IRunnerImageBuilder;
5693
5693
  ```
5694
5694
 
5695
5695
  - *Type:* <a href="#@cloudsnorkel/cdk-github-runners.IRunnerImageBuilder">IRunnerImageBuilder</a>
5696
- - *Default:* Ec2ProviderProps.imageBuilder()
5696
+ - *Default:* Ec2RunnerProvider.imageBuilder()
5697
5697
 
5698
5698
  Runner image builder used to build AMI containing GitHub Runner and all requirements.
5699
5699
 
@@ -7545,7 +7545,7 @@ public readonly os: Os;
7545
7545
  ```
7546
7546
 
7547
7547
  - *Type:* <a href="#@cloudsnorkel/cdk-github-runners.Os">Os</a>
7548
- - *Default:* OS.LINUX
7548
+ - *Default:* OS.LINUX_UBUNTU
7549
7549
 
7550
7550
  Image OS.
7551
7551
 
package/README.md CHANGED
@@ -55,39 +55,96 @@ You can also create your own provider by implementing `IRunnerProvider`.
55
55
 
56
56
  ## Installation
57
57
 
58
- 1. Confirm you're using CDK v2
59
- 2. Install the appropriate package
60
- 1. [Python][6]
61
- ```
62
- pip install cloudsnorkel.cdk-github-runners
63
- ```
64
- 2. [TypeScript or JavaScript][7]
65
- ```
66
- npm i @cloudsnorkel/cdk-github-runners
67
- ```
68
- 3. [Java][8]
69
- ```xml
70
- <dependency>
58
+ 1. Install and use the appropriate package
59
+ <details><summary>Python</summary>
60
+
61
+ ### Install
62
+ Available on [PyPI][6].
63
+ ```bash
64
+ pip install cloudsnorkel.cdk-github-runners
65
+ ```
66
+ ### Use
67
+ ```python
68
+ from cloudsnorkel.cdk_github_runners import GitHubRunners
69
+
70
+ GitHubRunners(self, "runners")
71
+ ```
72
+ </details>
73
+ <details><summary>TypeScript or JavaScript</summary>
74
+
75
+ ### Install
76
+ Available on [npm][7].
77
+ ```bash
78
+ npm i @cloudsnorkel/cdk-github-runners
79
+ ```
80
+ ### Use
81
+ ```typescript
82
+ import { GitHubRunners } from '@cloudsnorkel/cdk-github-runners';
83
+
84
+ new GitHubRunners(this, "runners");
85
+ ```
86
+ </details>
87
+ <details><summary>Java</summary>
88
+
89
+ ### Install
90
+ Available on [Maven][8].
91
+ ```xml
92
+ <dependency>
71
93
  <groupId>com.cloudsnorkel</groupId>
72
94
  <artifactId>cdk.github.runners</artifactId>
73
- </dependency>
74
- ```
75
- 4. [Go][11]
76
- ```
77
- go get github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners
78
- ```
79
- 5. [.NET][12]
80
- ```
81
- dotnet add package CloudSnorkel.Cdk.Github.Runners
82
- ```
83
- 3. Use `GitHubRunners` construct in your code (starting with default arguments is fine)
84
- 4. Deploy your stack
85
- 5. Look for the status command output similar to `aws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json`
86
- 6. Execute the status command (you may need to specify `--profile` too) and open the resulting `status.json` file
87
- 7. 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
88
- 8. Run status command again to confirm `github.auth.status` and `github.webhook.status` are OK
89
- 9. Trigger a GitHub action that has a `self-hosted` label with `runs-on: [self-hosted, linux, codebuild]` or similar
90
- 10. If the action is not successful, see [troubleshooting](#Troubleshooting)
95
+ </dependency>
96
+ ```
97
+ ### Use
98
+ ```java
99
+ import com.cloudsnorkel.cdk.github.runners.GitHubRunners;
100
+
101
+ GitHubRunners.Builder.create(this, "runners").build();
102
+ ```
103
+ </details>
104
+ <details><summary>Go</summary>
105
+
106
+ ### Install
107
+ Available on [GitHub][11].
108
+ ```bash
109
+ go get github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners
110
+ ```
111
+ ### Use
112
+ ```go
113
+ import "github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners"
114
+
115
+ NewGitHubRunners(this, jsii.String("runners"))
116
+ ```
117
+ </details>
118
+ <details><summary>.NET</summary>
119
+
120
+ ### Install
121
+ Available on [Nuget][12].
122
+ ```bash
123
+ dotnet add package CloudSnorkel.Cdk.Github.Runners
124
+ ```
125
+ ### Use
126
+ ```csharp
127
+ using CloudSnorkel;
128
+
129
+ new GitHubRunners(this, "runners");
130
+ ```
131
+ </details>
132
+ 2. Use `GitHubRunners` construct in your code (starting with default arguments is fine)
133
+ 3. Deploy your stack
134
+ 4. Look for the status command output similar to `aws --region us-east-1 lambda invoke --function-name status-XYZ123 status.json`
135
+ ```
136
+ ✅ github-runners-test
137
+
138
+ ✨ Deployment time: 260.01s
139
+
140
+ Outputs:
141
+ github-runners-test.runnersstatuscommand4A30F0F5 = aws --region us-east-1 lambda invoke --function-name github-runners-test-runnersstatus1A5771C0-mvttg8oPQnQS status.json
142
+ ```
143
+ 5. Execute the status command (you may need to specify `--profile` too) and open the resulting `status.json` file
144
+ 6. 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
145
+ 7. Run status command again to confirm `github.auth.status` and `github.webhook.status` are OK
146
+ 8. Trigger a GitHub action that has a `self-hosted` label with `runs-on: [self-hosted, linux, codebuild]` or similar
147
+ 9. If the action is not successful, see [troubleshooting](#Troubleshooting)
91
148
 
92
149
  [![Demo](demo-thumbnail.jpg)](https://youtu.be/wlyv_3V8lIw)
93
150
 
@@ -104,10 +161,10 @@ let dbSg: ec2.SecurityGroup;
104
161
  let bucket: s3.Bucket;
105
162
 
106
163
  // create a custom CodeBuild provider
107
- const myProvider = new CodeBuildRunnerProvider(this, 'codebuild runner', {
108
- label: 'my-codebuild',
109
- vpc: vpc,
110
- securityGroup: runnerSg,
164
+ const myProvider = new CodeBuildRunnerProvider(this, 'codebuild runner', {
165
+ labels: ['my-codebuild'],
166
+ vpc: vpc,
167
+ securityGroups: [runnerSg],
111
168
  });
112
169
  // grant some permissions to the provider
113
170
  bucket.grantReadWrite(myProvider);
@@ -132,9 +189,9 @@ myBuilder.addComponent(
132
189
  );
133
190
 
134
191
  const myProvider = new FargateRunnerProvider(this, 'fargate runner', {
135
- label: 'customized-fargate',
192
+ labels: ['customized-fargate'],
136
193
  vpc: vpc,
137
- securityGroup: runnerSg,
194
+ securityGroups: [runnerSg],
138
195
  imageBuilder: myBuilder,
139
196
  });
140
197
 
@@ -160,31 +217,31 @@ Windows images can also be customized the same way.
160
217
 
161
218
  ```typescript
162
219
  const myWindowsBuilder = FargateRunnerProvider.imageBuilder(this, 'Windows image builder', {
163
- architecture: Architecture.X86_64,
164
- os: Os.WINDOWS,
165
- runnerVersion: RunnerVersion.specific('2.291.0'),
166
- rebuildInterval: Duration.days(14),
220
+ architecture: Architecture.X86_64,
221
+ os: Os.WINDOWS,
222
+ runnerVersion: RunnerVersion.specific('2.291.0'),
223
+ rebuildInterval: Duration.days(14),
167
224
  });
168
225
  myWindowsBuilder.addComponent(
169
- RunnerImageComponent.custom({
170
- name: 'Ninja',
171
- commands: [
172
- 'Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip" -OutFile ninja.zip',
173
- 'Expand-Archive ninja.zip -DestinationPath C:\\actions',
174
- 'del ninja.zip',
175
- ],
176
- })
226
+ RunnerImageComponent.custom({
227
+ name: 'Ninja',
228
+ commands: [
229
+ 'Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip" -OutFile ninja.zip',
230
+ 'Expand-Archive ninja.zip -DestinationPath C:\\actions',
231
+ 'del ninja.zip',
232
+ ],
233
+ })
177
234
  );
178
235
 
179
236
  const myProvider = new FargateRunnerProvider(this, 'fargate runner', {
180
- label: 'customized-windows-fargate',
181
- vpc: vpc,
182
- securityGroup: runnerSg,
183
- imageBuidler: myWindowsBuilder,
237
+ labels: ['customized-windows-fargate'],
238
+ vpc: vpc,
239
+ securityGroups: [runnerSg],
240
+ imageBuidler: myWindowsBuilder,
184
241
  });
185
242
 
186
243
  new GitHubRunners(this, 'runners', {
187
- providers: [myProvider],
244
+ providers: [myProvider],
188
245
  });
189
246
  ```
190
247
 
@@ -192,15 +249,15 @@ The runner OS and architecture is determined by the image it is set to use. For
192
249
 
193
250
  ```typescript
194
251
  new GitHubRunners(this, 'runners', {
195
- providers: [
196
- new FargateRunnerProvider(this, 'fargate runner', {
197
- labels: ['arm64', 'fargate'],
198
- imageBuidler: FargateRunnerProvider.imageBuilder(this, 'image builder', {
199
- architecture: Architecture.ARM64,
200
- os: Os.LINUX,
252
+ providers: [
253
+ new FargateRunnerProvider(this, 'fargate runner', {
254
+ labels: ['arm64', 'fargate'],
255
+ imageBuidler: FargateRunnerProvider.imageBuilder(this, 'image builder', {
256
+ architecture: Architecture.ARM64,
257
+ os: Os.LINUX_UBUNTU,
258
+ }),
201
259
  }),
202
- }),
203
- ],
260
+ ],
204
261
  });
205
262
  ```
206
263
 
@@ -247,7 +304,7 @@ Other useful metrics to track:
247
304
  [5]: https://github.com/actions/runner
248
305
  [6]: https://pypi.org/project/cloudsnorkel.cdk-github-runners
249
306
  [7]: https://www.npmjs.com/package/@cloudsnorkel/cdk-github-runners
250
- [8]: https://search.maven.org/search?q=g:%22com.cloudsnorkel%22%20AND%20a:%22cdk.github.runners%22
307
+ [8]: https://central.sonatype.com/artifact/com.cloudsnorkel/cdk.github.runners/
251
308
  [9]: https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps
252
309
  [10]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
253
310
  [11]: https://pkg.go.dev/github.com/CloudSnorkel/cdk-github-runners-go/cloudsnorkelcdkgithubrunners