Skip to content

Release #1592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 48 commits into from
Jan 6, 2022
Merged

Release #1592

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2f323d6
feat: add option ephemeral runners (#1374)
npalm Dec 22, 2021
b572e7b
chore: Bump typescript in /modules/webhook/lambdas/webhook (#1536)
dependabot[bot] Dec 22, 2021
d3c1a4e
chore: Bump @types/aws-lambda in /modules/runners/lambdas/runners (#1…
dependabot[bot] Dec 22, 2021
a2135fb
chore: Bump @types/node (#1532)
dependabot[bot] Dec 22, 2021
25ea765
chore: Bump @vercel/ncc in /modules/runners/lambdas/runners (#1549)
dependabot[bot] Dec 22, 2021
cb8a4fe
chore: Bump aws-sdk in /modules/webhook/lambdas/webhook (#1548)
dependabot[bot] Dec 22, 2021
a7532ed
chore: Bump @types/node (#1547)
dependabot[bot] Dec 22, 2021
164e529
chore: Bump @vercel/ncc (#1552)
dependabot[bot] Dec 23, 2021
0abd6ea
chore: Bump ts-jest in /modules/runners/lambdas/runners (#1550)
dependabot[bot] Dec 23, 2021
3fbf48d
chore: Bump @types/node in /modules/webhook/lambdas/webhook (#1545)
dependabot[bot] Dec 23, 2021
1dfaed8
chore: Bump @vercel/ncc in /modules/webhook/lambdas/webhook (#1551)
dependabot[bot] Dec 23, 2021
1f380f8
chore: Bump aws-sdk (#1544)
dependabot[bot] Dec 23, 2021
1851fae
chore: Bump @types/node in /modules/webhook/lambdas/webhook (#1558)
dependabot[bot] Dec 23, 2021
2c463b9
chore: Bump cron-parser in /modules/runners/lambdas/runners (#1555)
dependabot[bot] Dec 23, 2021
09d5452
chore: Bump typescript (#1534)
dependabot[bot] Dec 23, 2021
5fafebf
chore: Bump ts-jest in /modules/webhook/lambdas/webhook (#1559)
dependabot[bot] Dec 23, 2021
94d4faa
chore: Bump aws-sdk in /modules/runners/lambdas/runners (#1546)
dependabot[bot] Dec 23, 2021
a7eae5a
chore: Bump jest (#1527)
dependabot[bot] Dec 23, 2021
670dbbb
chore: Bump express in /modules/webhook/lambdas/webhook (#1557)
dependabot[bot] Dec 23, 2021
76f3c4b
chore: Bump typescript in /modules/runners/lambdas/runners (#1531)
dependabot[bot] Dec 23, 2021
2727458
chore: Bump ts-jest (#1526)
dependabot[bot] Dec 23, 2021
ddc0071
chore: Bump @types/aws-lambda in /modules/webhook/lambdas/webhook (#1…
dependabot[bot] Dec 23, 2021
2b35960
chore: Bump jest in /modules/runners/lambdas/runners (#1528)
dependabot[bot] Dec 24, 2021
5165cb0
chore: Bump jest in /modules/webhook/lambdas/webhook (#1529)
dependabot[bot] Dec 24, 2021
8c9eb88
chore: Bump @types/aws-lambda in /modules/webhook/lambdas/webhook (#1…
dependabot[bot] Dec 28, 2021
0fdb13b
chore: Bump @aws-sdk/client-ssm in /modules/runners/lambdas/runners (…
dependabot[bot] Dec 28, 2021
53205a3
chore: Bump @types/node (#1564)
dependabot[bot] Dec 28, 2021
31c7170
chore: Bump @types/aws-lambda in /modules/runners/lambdas/runners (#1…
dependabot[bot] Dec 28, 2021
430124d
chore: Bump @aws-sdk/client-ssm in /modules/webhook/lambdas/webhook (…
dependabot[bot] Dec 28, 2021
ea44c32
chore: Bump @types/node in /modules/runners/lambdas/runners (#1565)
dependabot[bot] Dec 28, 2021
d926fc7
chore: Bump @types/node in /modules/webhook/lambdas/webhook (#1568)
dependabot[bot] Dec 28, 2021
b4f5585
chore: Bump philips-labs/slsa-provenance-action from 0.4.0 to 0.5.0 (…
dependabot[bot] Dec 28, 2021
2c66eea
chore: Bump @octokit/webhooks in /modules/webhook/lambdas/webhook (#1…
dependabot[bot] Dec 28, 2021
3fa5896
feat: Support t4g Graviton instance type (#1561)
bliles Dec 28, 2021
b76acbe
docs: Offline runners are note required anymore. (#1573)
npalm Jan 3, 2022
77f350b
feat: Change default location of runner to `/opt` and fix Ubuntu exam…
npalm Jan 3, 2022
611b76a
chore: Bump @types/node in /modules/webhook/lambdas/webhook (#1587)
dependabot[bot] Jan 4, 2022
7404de6
chore: Bump @types/node in /modules/runners/lambdas/runners (#1586)
dependabot[bot] Jan 4, 2022
e59866d
chore: Bump tslog (#1585)
dependabot[bot] Jan 4, 2022
3c871b1
chore: Bump @types/node (#1584)
dependabot[bot] Jan 4, 2022
79493e8
chore: Bump @types/jest in /modules/runners/lambdas/runners (#1583)
dependabot[bot] Jan 4, 2022
0de7f32
chore: Bump tslog in /modules/webhook/lambdas/webhook (#1582)
dependabot[bot] Jan 4, 2022
4df55f5
chore: Bump @types/jest (#1581)
dependabot[bot] Jan 4, 2022
063274d
chore: Bump @types/jest in /modules/webhook/lambdas/webhook (#1580)
dependabot[bot] Jan 4, 2022
859e5d1
chore: Bump tslog in /modules/runners/lambdas/runners (#1578)
dependabot[bot] Jan 4, 2022
4ec44df
chore: Bump @types/request (#1579)
dependabot[bot] Jan 4, 2022
7907984
fix: Add config for windows ami (#1525)
maths22 Jan 5, 2022
27e974d
feat: Replace run instance API by create fleet API (#1556)
npalm Jan 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .ci/build-yarn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# Build all the lambda's, output on the default place (inside the lambda module)

lambdaSrcDirs=("modules/runner-binaries-syncer/lambdas/runner-binaries-syncer" "modules/runners/lambdas/runners" "modules/webhook/lambdas/webhook")
repoRoot=$(dirname $(dirname $(realpath ${BASH_SOURCE[0]})))

for lambdaDir in ${lambdaSrcDirs[@]}; do
cd "$repoRoot/${lambdaDir}"
yarn && yarn run dist
done
7 changes: 5 additions & 2 deletions .github/workflows/packer-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ jobs:
runs-on: ubuntu-latest
container:
image: hashicorp/packer:1.7.8
strategy:
matrix:
image: ["linux-amzn2", "windows-core-2019"]
defaults:
run:
working-directory: images/linux-amzn2
working-directory: images/${{ matrix.image }}
steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: packer init
run: packer init .

- name: check terraform formatting
- name: check packer formatting
run: packer fmt -recursive -check=true .

- name: packer validate
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:

steps:
- name: Generate provenance for release
uses: philips-labs/slsa-provenance-action@v0.4.0
uses: philips-labs/slsa-provenance-action@v0.5.0
with:
artifact_path: release-assets
output_path: 'build.provenance'
Expand Down
97 changes: 54 additions & 43 deletions README.md

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ module "runners" {
webhook_secret = random_id.random.hex
}

# Grab zip files via lambda_download
webhook_lambda_zip = "lambdas-download/webhook.zip"
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
runners_lambda_zip = "lambdas-download/runners.zip"
enable_organization_runners = false
runner_extra_labels = "default,example"

enable_organization_runners = false
runner_extra_labels = "default,example"

# enable access to the runners via SSM
enable_ssm_on_runners = true
Expand All @@ -61,7 +63,11 @@ module "runners" {
instance_types = ["m5.large", "c5.large"]

# override delay of events in seconds
delay_webhook_event = 5
delay_webhook_event = 5
runners_maximum_count = 1

# set up a fifo queue to remain order
fifo_build_queue = true

# override scaling down
scale_down_schedule_expression = "cron(* * * * ? *)"
Expand Down
57 changes: 57 additions & 0 deletions examples/ephemeral/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions examples/ephemeral/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Action runners deployment ephemeral example

This example is based on the default setup, but shows how runners can be used with the ephemeral flag enabled. Once enabled, ephemeral runners will be used for one job only. Each job requires a fresh instance. This feature should be used in combination with the `workflow_job` event. See GitHub webhook endpoint configuration(link needed here). It is also suggested to use a pre-build AMI to minimize runner launch times.
## Usages

Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md). First download the Lambda releases from GitHub. Alternatively you can build the lambdas locally with Node or Docker, there is a simple build script in `<root>/.ci/build.sh`. In the `main.tf` you can simply remove the location of the lambda zip files, the default location will work in this case.

> Ensure you have set the version in `lambdas-download/main.tf` for running the example. The version needs to be set to a GitHub release version, see https://github.com/philips-labs/terraform-aws-github-runner/releases
```bash
cd lambdas-download
terraform init
terraform apply
cd ..
```

Before running Terraform, ensure the GitHub app is configured. See the [configuration details](../../README.md#usages) for more details.

```bash
terraform init
terraform apply
```

You can receive the webhook details by running:

```bash
terraform output -raw webhook_secret
```

Be-aware some shells will print some end of line character `%`.
25 changes: 25 additions & 0 deletions examples/ephemeral/lambdas-download/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
locals {
version = "<REPLACE_BY_GITHUB_RELEASE_VERSION>"
}

module "lambdas" {
source = "../../../modules/download-lambda"
lambdas = [
{
name = "webhook"
tag = local.version
},
{
name = "runners"
tag = local.version
},
{
name = "runner-binaries-syncer"
tag = local.version
}
]
}

output "files" {
value = module.lambdas.files
}
71 changes: 71 additions & 0 deletions examples/ephemeral/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
locals {
environment = "ephemeral"
aws_region = "eu-west-1"
}

resource "random_id" "random" {
byte_length = 20
}

data "aws_caller_identity" "current" {}

module "runners" {
source = "../../"
create_service_linked_role_spot = true
aws_region = local.aws_region
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets

environment = local.environment
tags = {
Project = "ProjectX"
}

github_app = {
key_base64 = var.github_app_key_base64
id = var.github_app_id
webhook_secret = random_id.random.hex
}

# Grab the lambda packages from local directory. Must run /.ci/build.sh first
webhook_lambda_zip = "../../lambda_output/webhook.zip"
runner_binaries_syncer_lambda_zip = "../../lambda_output/runner-binaries-syncer.zip"
runners_lambda_zip = "../../lambda_output/runners.zip"

enable_organization_runners = true
runner_extra_labels = "default,example"

# enable access to the runners via SSM
enable_ssm_on_runners = true

# Let the module manage the service linked role
# create_service_linked_role_spot = true

instance_types = ["m5.large", "c5.large"]

# override delay of events in seconds
delay_webhook_event = 0

# Ensure you set the number not too low, each build require a new instance
runners_maximum_count = 20

# override scaling down
scale_down_schedule_expression = "cron(* * * * ? *)"

enable_ephemeral_runners = true

# configure your pre-built AMI
# enabled_userdata = false
# ami_filter = { name = ["github-runner-amzn2-x86_64-2021*"] }
# ami_owners = [data.aws_caller_identity.current.account_id]

# Enable logging
# log_level = "debug"

# Setup a dead letter queue, by default scale up lambda will kepp retrying to process event in case of scaling error.
# redrive_policy_build_queue = {
# enabled = true
# maxReceiveCount = 50 # 50 retries every 30 seconds => 25 minutes
# deadLetterTargetArn = null
# }
}
15 changes: 15 additions & 0 deletions examples/ephemeral/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
output "runners" {
value = {
lambda_syncer_name = module.runners.binaries_syncer.lambda.function_name
}
}

output "webhook_endpoint" {
value = module.runners.webhook.endpoint
}

output "webhook_secret" {
sensitive = true
value = random_id.random.hex
}

3 changes: 3 additions & 0 deletions examples/ephemeral/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "aws" {
region = local.aws_region
}
5 changes: 5 additions & 0 deletions examples/ephemeral/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

variable "github_app_key_base64" {}

variable "github_app_id" {}

15 changes: 15 additions & 0 deletions examples/ephemeral/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.27"
}
local = {
source = "hashicorp/local"
}
random = {
source = "hashicorp/random"
}
}
required_version = ">= 0.14"
}
7 changes: 7 additions & 0 deletions examples/ephemeral/vpc.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module "vpc" {
source = "git::https://github.com/philips-software/terraform-aws-vpc.git?ref=2.2.0"

environment = local.environment
aws_region = local.aws_region
create_private_hosted_zone = false
}
12 changes: 11 additions & 1 deletion examples/prebuilt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ This module shows how to create GitHub action runners using a prebuilt AMI for t

## Usages

Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md).
Steps for the full setup, such as creating a GitHub app can be found in the root module's [README](../../README.md).

## Variables

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_ami_filter"></a> [ami\_filter](#input\_ami\_filter) | The amis to search. Use the default for the provided amazon linux image, `github-runner-windows-core-2019-*` for the provided widnows image | `string` | `github-runner-amzn2-x86_64-2021*` | no |
| <a name="input_github_app_key_base64"></a> [github\_app\_key\_base64](#input\_github\_app\_key\_base64) | The base64 encoded private key you downloaded from GitHub when creating the app | `string` | | yes |
| <a name="input_github_app_id"></a> [github\_app\_id](#input\_github\_app\_id) | The id of the app you created on GitHub | `string` | | yes |
| <a name="input_region"></a> [region](#input\_region) | The target aws region | `string` | `eu-west-1` | no |
| <a name="input_runner_os"></a> [runner\_os](#input\_runner\_os) | The os of the image, either `linux` or `windows` | `string` | `linux` | no |

### Lambdas

Expand Down
13 changes: 7 additions & 6 deletions examples/prebuilt/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
locals {
environment = "prebuilt"
aws_region = "eu-west-1"
}

resource "random_id" "random" {
Expand All @@ -12,7 +11,7 @@ data "aws_caller_identity" "current" {}
module "runners" {
source = "../../"
create_service_linked_role_spot = true
aws_region = local.aws_region
aws_region = var.aws_region
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets

Expand All @@ -24,15 +23,17 @@ module "runners" {
webhook_secret = random_id.random.hex
}

webhook_lambda_zip = "../../lambda_output/webhook.zip"
runner_binaries_syncer_lambda_zip = "../../lambda_output/runner-binaries-syncer.zip"
runners_lambda_zip = "../../lambda_output/runners.zip"
webhook_lambda_zip = "lambdas-download/webhook.zip"
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
runners_lambda_zip = "lambdas-download/runners.zip"

runner_extra_labels = "default,example"

runner_os = var.runner_os

# configure your pre-built AMI
enabled_userdata = false
ami_filter = { name = ["github-runner-amzn2-x86_64-2021*"] }
ami_filter = { name = [var.ami_name_filter] }
ami_owners = [data.aws_caller_identity.current.account_id]

# enable access to the runners via SSM
Expand Down
2 changes: 1 addition & 1 deletion examples/prebuilt/providers.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
provider "aws" {
region = local.aws_region
region = var.aws_region
}
15 changes: 15 additions & 0 deletions examples/prebuilt/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@
variable "github_app_key_base64" {}

variable "github_app_id" {}

variable "runner_os" {
type = string
default = "linux"
}

variable "ami_name_filter" {
type = string
default = "github-runner-amzn2-x86_64-2021*"
}

variable "aws_region" {
type = string
default = "eu-west-1"
}
Loading