@cloudsnorkel/cdk-github-runners 0.10.6 → 0.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +23 -23
- package/README.md +2 -2
- package/assets/delete-failed-runner.lambda/index.js +476 -442
- package/assets/docker-images/codebuild/linux-arm64/Dockerfile +1 -2
- package/assets/docker-images/codebuild/linux-x64/Dockerfile +1 -2
- package/assets/docker-images/fargate/linux-arm64/Dockerfile +1 -2
- package/assets/docker-images/fargate/linux-x64/Dockerfile +1 -2
- package/assets/idle-runner-repear.lambda/index.js +470 -438
- package/assets/image-builders/aws-image-builder/delete-ami.lambda/index.js +16 -2
- package/assets/image-builders/aws-image-builder/filter-failed-builds.lambda/index.js +16 -2
- package/assets/image-builders/aws-image-builder/reaper.lambda/index.js +16 -2
- package/assets/image-builders/aws-image-builder/versioner.lambda/index.js +95 -66
- package/assets/setup.lambda/index.html +1 -1
- package/assets/setup.lambda/index.js +205 -173
- package/assets/status.lambda/index.js +413 -398
- package/assets/token-retriever.lambda/index.js +474 -440
- package/assets/webhook-handler.lambda/index.js +29 -10
- package/lib/access.js +1 -1
- package/lib/delete-failed-runner.lambda.d.ts +2 -1
- package/lib/delete-failed-runner.lambda.js +5 -3
- package/lib/idle-runner-repear.lambda.d.ts +2 -1
- package/lib/idle-runner-repear.lambda.js +5 -3
- package/lib/image-builders/api.js +1 -1
- package/lib/image-builders/aws-image-builder/builder.js +1 -1
- package/lib/image-builders/aws-image-builder/delete-ami.lambda.d.ts +8 -0
- package/lib/image-builders/aws-image-builder/delete-ami.lambda.js +5 -3
- package/lib/image-builders/aws-image-builder/deprecated/ami.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/container.js +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/linux-components.d.ts +1 -1
- package/lib/image-builders/aws-image-builder/deprecated/linux-components.js +11 -12
- package/lib/image-builders/aws-image-builder/deprecated/windows-components.js +1 -1
- package/lib/image-builders/aws-image-builder/filter-failed-builds.lambda.d.ts +2 -1
- package/lib/image-builders/aws-image-builder/filter-failed-builds.lambda.js +5 -3
- package/lib/image-builders/aws-image-builder/reaper.lambda.d.ts +8 -0
- package/lib/image-builders/aws-image-builder/reaper.lambda.js +5 -3
- package/lib/image-builders/aws-image-builder/versioner.lambda.d.ts +5 -0
- package/lib/image-builders/aws-image-builder/versioner.lambda.js +20 -12
- package/lib/image-builders/codebuild-deprecated.js +1 -1
- package/lib/image-builders/components.js +3 -4
- package/lib/image-builders/static.js +1 -1
- package/lib/providers/codebuild.js +2 -2
- package/lib/providers/common.js +3 -3
- package/lib/providers/ec2.js +2 -2
- package/lib/providers/ecs.js +1 -1
- package/lib/providers/fargate.js +2 -2
- package/lib/providers/lambda.js +2 -2
- package/lib/runner.js +1 -1
- package/lib/secrets.js +1 -1
- package/lib/setup.lambda.d.ts +3 -0
- package/lib/setup.lambda.js +5 -3
- package/lib/status.lambda.d.ts +2 -1
- package/lib/status.lambda.js +16 -9
- package/lib/token-retriever.lambda.d.ts +5 -1
- package/lib/token-retriever.lambda.js +5 -3
- package/lib/webhook-handler.lambda.d.ts +7 -1
- package/lib/webhook-handler.lambda.js +20 -11
- package/package.json +14 -13
package/.jsii
CHANGED
|
@@ -3114,7 +3114,7 @@
|
|
|
3114
3114
|
"stability": "experimental"
|
|
3115
3115
|
},
|
|
3116
3116
|
"homepage": "https://github.com/CloudSnorkel/cdk-github-runners.git",
|
|
3117
|
-
"jsiiVersion": "5.0.
|
|
3117
|
+
"jsiiVersion": "5.0.19 (build bf5f37b)",
|
|
3118
3118
|
"keywords": [
|
|
3119
3119
|
"aws",
|
|
3120
3120
|
"aws-cdk",
|
|
@@ -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[][7]\n[][6]\n[][8]\n[][11]\n[][12]\n[](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml)\n[](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[](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\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\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"
|
|
3141
|
+
"markdown": "# GitHub Self-Hosted Runners CDK Constructs\n\n[][7]\n[][6]\n[][8]\n[][11]\n[][12]\n[](https://github.com/CloudSnorkel/cdk-github-runners/actions/workflows/release.yml)\n[](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[](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 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\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\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"
|
|
3142
3142
|
},
|
|
3143
3143
|
"repository": {
|
|
3144
3144
|
"type": "git",
|
|
@@ -10258,7 +10258,7 @@
|
|
|
10258
10258
|
},
|
|
10259
10259
|
"locationInModule": {
|
|
10260
10260
|
"filename": "src/image-builders/aws-image-builder/deprecated/linux-components.ts",
|
|
10261
|
-
"line":
|
|
10261
|
+
"line": 50
|
|
10262
10262
|
},
|
|
10263
10263
|
"name": "awsCli",
|
|
10264
10264
|
"parameters": [
|
|
@@ -10294,7 +10294,7 @@
|
|
|
10294
10294
|
},
|
|
10295
10295
|
"locationInModule": {
|
|
10296
10296
|
"filename": "src/image-builders/aws-image-builder/deprecated/linux-components.ts",
|
|
10297
|
-
"line":
|
|
10297
|
+
"line": 133
|
|
10298
10298
|
},
|
|
10299
10299
|
"name": "docker",
|
|
10300
10300
|
"parameters": [
|
|
@@ -10330,7 +10330,7 @@
|
|
|
10330
10330
|
},
|
|
10331
10331
|
"locationInModule": {
|
|
10332
10332
|
"filename": "src/image-builders/aws-image-builder/deprecated/linux-components.ts",
|
|
10333
|
-
"line":
|
|
10333
|
+
"line": 151
|
|
10334
10334
|
},
|
|
10335
10335
|
"name": "extraCertificates",
|
|
10336
10336
|
"parameters": [
|
|
@@ -10366,7 +10366,7 @@
|
|
|
10366
10366
|
},
|
|
10367
10367
|
"locationInModule": {
|
|
10368
10368
|
"filename": "src/image-builders/aws-image-builder/deprecated/linux-components.ts",
|
|
10369
|
-
"line":
|
|
10369
|
+
"line": 88
|
|
10370
10370
|
},
|
|
10371
10371
|
"name": "git",
|
|
10372
10372
|
"parameters": [
|
|
@@ -10402,7 +10402,7 @@
|
|
|
10402
10402
|
},
|
|
10403
10403
|
"locationInModule": {
|
|
10404
10404
|
"filename": "src/image-builders/aws-image-builder/deprecated/linux-components.ts",
|
|
10405
|
-
"line":
|
|
10405
|
+
"line": 73
|
|
10406
10406
|
},
|
|
10407
10407
|
"name": "githubCli",
|
|
10408
10408
|
"parameters": [
|
|
@@ -10438,7 +10438,7 @@
|
|
|
10438
10438
|
},
|
|
10439
10439
|
"locationInModule": {
|
|
10440
10440
|
"filename": "src/image-builders/aws-image-builder/deprecated/linux-components.ts",
|
|
10441
|
-
"line":
|
|
10441
|
+
"line": 101
|
|
10442
10442
|
},
|
|
10443
10443
|
"name": "githubRunner",
|
|
10444
10444
|
"parameters": [
|
|
@@ -11753,7 +11753,7 @@
|
|
|
11753
11753
|
},
|
|
11754
11754
|
"locationInModule": {
|
|
11755
11755
|
"filename": "src/image-builders/components.ts",
|
|
11756
|
-
"line":
|
|
11756
|
+
"line": 148
|
|
11757
11757
|
},
|
|
11758
11758
|
"name": "awsCli",
|
|
11759
11759
|
"returns": {
|
|
@@ -11797,7 +11797,7 @@
|
|
|
11797
11797
|
},
|
|
11798
11798
|
"locationInModule": {
|
|
11799
11799
|
"filename": "src/image-builders/components.ts",
|
|
11800
|
-
"line":
|
|
11800
|
+
"line": 335
|
|
11801
11801
|
},
|
|
11802
11802
|
"name": "docker",
|
|
11803
11803
|
"returns": {
|
|
@@ -11814,7 +11814,7 @@
|
|
|
11814
11814
|
},
|
|
11815
11815
|
"locationInModule": {
|
|
11816
11816
|
"filename": "src/image-builders/components.ts",
|
|
11817
|
-
"line":
|
|
11817
|
+
"line": 397
|
|
11818
11818
|
},
|
|
11819
11819
|
"name": "dockerInDocker",
|
|
11820
11820
|
"returns": {
|
|
@@ -11832,7 +11832,7 @@
|
|
|
11832
11832
|
},
|
|
11833
11833
|
"locationInModule": {
|
|
11834
11834
|
"filename": "src/image-builders/components.ts",
|
|
11835
|
-
"line":
|
|
11835
|
+
"line": 445
|
|
11836
11836
|
},
|
|
11837
11837
|
"name": "extraCertificates",
|
|
11838
11838
|
"parameters": [
|
|
@@ -11869,7 +11869,7 @@
|
|
|
11869
11869
|
},
|
|
11870
11870
|
"locationInModule": {
|
|
11871
11871
|
"filename": "src/image-builders/components.ts",
|
|
11872
|
-
"line":
|
|
11872
|
+
"line": 222
|
|
11873
11873
|
},
|
|
11874
11874
|
"name": "git",
|
|
11875
11875
|
"returns": {
|
|
@@ -11886,7 +11886,7 @@
|
|
|
11886
11886
|
},
|
|
11887
11887
|
"locationInModule": {
|
|
11888
11888
|
"filename": "src/image-builders/components.ts",
|
|
11889
|
-
"line":
|
|
11889
|
+
"line": 184
|
|
11890
11890
|
},
|
|
11891
11891
|
"name": "githubCli",
|
|
11892
11892
|
"returns": {
|
|
@@ -11904,7 +11904,7 @@
|
|
|
11904
11904
|
},
|
|
11905
11905
|
"locationInModule": {
|
|
11906
11906
|
"filename": "src/image-builders/components.ts",
|
|
11907
|
-
"line":
|
|
11907
|
+
"line": 262
|
|
11908
11908
|
},
|
|
11909
11909
|
"name": "githubRunner",
|
|
11910
11910
|
"parameters": [
|
|
@@ -11933,7 +11933,7 @@
|
|
|
11933
11933
|
},
|
|
11934
11934
|
"locationInModule": {
|
|
11935
11935
|
"filename": "src/image-builders/components.ts",
|
|
11936
|
-
"line":
|
|
11936
|
+
"line": 495
|
|
11937
11937
|
},
|
|
11938
11938
|
"name": "lambdaEntrypoint",
|
|
11939
11939
|
"returns": {
|
|
@@ -11985,7 +11985,7 @@
|
|
|
11985
11985
|
},
|
|
11986
11986
|
"locationInModule": {
|
|
11987
11987
|
"filename": "src/image-builders/components.ts",
|
|
11988
|
-
"line":
|
|
11988
|
+
"line": 544
|
|
11989
11989
|
},
|
|
11990
11990
|
"name": "getAssets",
|
|
11991
11991
|
"parameters": [
|
|
@@ -12022,7 +12022,7 @@
|
|
|
12022
12022
|
},
|
|
12023
12023
|
"locationInModule": {
|
|
12024
12024
|
"filename": "src/image-builders/components.ts",
|
|
12025
|
-
"line":
|
|
12025
|
+
"line": 539
|
|
12026
12026
|
},
|
|
12027
12027
|
"name": "getCommands",
|
|
12028
12028
|
"parameters": [
|
|
@@ -12058,7 +12058,7 @@
|
|
|
12058
12058
|
},
|
|
12059
12059
|
"locationInModule": {
|
|
12060
12060
|
"filename": "src/image-builders/components.ts",
|
|
12061
|
-
"line":
|
|
12061
|
+
"line": 553
|
|
12062
12062
|
},
|
|
12063
12063
|
"name": "getDockerCommands",
|
|
12064
12064
|
"parameters": [
|
|
@@ -12093,7 +12093,7 @@
|
|
|
12093
12093
|
},
|
|
12094
12094
|
"locationInModule": {
|
|
12095
12095
|
"filename": "src/image-builders/components.ts",
|
|
12096
|
-
"line":
|
|
12096
|
+
"line": 560
|
|
12097
12097
|
},
|
|
12098
12098
|
"name": "shouldReboot",
|
|
12099
12099
|
"parameters": [
|
|
@@ -12129,7 +12129,7 @@
|
|
|
12129
12129
|
"immutable": true,
|
|
12130
12130
|
"locationInModule": {
|
|
12131
12131
|
"filename": "src/image-builders/components.ts",
|
|
12132
|
-
"line":
|
|
12132
|
+
"line": 534
|
|
12133
12133
|
},
|
|
12134
12134
|
"name": "name",
|
|
12135
12135
|
"type": {
|
|
@@ -13013,6 +13013,6 @@
|
|
|
13013
13013
|
"symbolId": "src/image-builders/aws-image-builder/deprecated/windows-components:WindowsComponents"
|
|
13014
13014
|
}
|
|
13015
13015
|
},
|
|
13016
|
-
"version": "0.10.
|
|
13017
|
-
"fingerprint": "
|
|
13016
|
+
"version": "0.10.8",
|
|
13017
|
+
"fingerprint": "SoYttWw0/tJxiKE+DkHUA119xVuOUNQWSxOSmV5lGoc="
|
|
13018
13018
|
}
|
package/README.md
CHANGED
|
@@ -237,7 +237,7 @@ const myProvider = new FargateRunnerProvider(this, 'fargate runner', {
|
|
|
237
237
|
labels: ['customized-windows-fargate'],
|
|
238
238
|
vpc: vpc,
|
|
239
239
|
securityGroups: [runnerSg],
|
|
240
|
-
|
|
240
|
+
imageBuilder: myWindowsBuilder,
|
|
241
241
|
});
|
|
242
242
|
|
|
243
243
|
new GitHubRunners(this, 'runners', {
|
|
@@ -252,7 +252,7 @@ new GitHubRunners(this, 'runners', {
|
|
|
252
252
|
providers: [
|
|
253
253
|
new FargateRunnerProvider(this, 'fargate runner', {
|
|
254
254
|
labels: ['arm64', 'fargate'],
|
|
255
|
-
|
|
255
|
+
imageBuilder: FargateRunnerProvider.imageBuilder(this, 'image builder', {
|
|
256
256
|
architecture: Architecture.ARM64,
|
|
257
257
|
os: Os.LINUX_UBUNTU,
|
|
258
258
|
}),
|