Skip to content

Commit 3376a70

Browse files
authored
Merge pull request #1645 from philips-labs/develop
Release
2 parents 1a409d2 + ec497a2 commit 3376a70

File tree

25 files changed

+1130
-886
lines changed

25 files changed

+1130
-886
lines changed

.github/workflows/packer-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
paths:
99
- "images/**"
1010
- ".github/workflows/packer-build.yml"
11+
- "module/runners/templates/**"
1112

1213
env:
1314
AWS_REGION: eu-west-1

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292

9393
steps:
9494
- name: Generate provenance for release
95-
uses: philips-labs/[email protected].0
95+
uses: philips-labs/[email protected].1
9696
with:
9797
artifact_path: release-assets
9898
output_path: 'build.provenance'

.github/workflows/terraform.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
fail-fast: false
4444
matrix:
4545
terraform: [0.14.3, 0.15.5, 1.0.8]
46-
example: ["default", "ubuntu", "prebuilt"]
46+
example: ["default", "ubuntu", "prebuilt", "arm64", "ephemeral", "windows"]
4747
defaults:
4848
run:
4949
working-directory: examples/${{ matrix.example }}

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ To be able to support a number of use-cases the module has quite a lot configura
9393

9494
#### ARM64 support via Graviton/Graviton2 instance-types
9595

96-
When using the default example or top-level module, specifying an `instance_type` that matches a Graviton/Graviton 2 (ARM64) architecture (e.g. a1, t4g or any 6th-gen `g` or `gd` type), the sub-modules will be automatically configured to provision with ARM64 AMIs and leverage GitHub's ARM64 action runner. See below for more details.
96+
When using the default example or top-level module, specifying `instance_types` that match a Graviton/Graviton 2 (ARM64) architecture (e.g. a1, t4g or any 6th-gen `g` or `gd` type), you must also specify `runner_architecture = "arm64"` and the sub-modules will be automatically configured to provision with ARM64 AMIs and leverage GitHub's ARM64 action runner. See below for more details.
9797

9898
## Usages
9999

@@ -184,8 +184,6 @@ module "github-runner" {
184184
}
185185
```
186186

187-
**ARM64** support: Specify an `a1`, `t4g` or `*6g*` (6th-gen Graviton2) instance type to stand up an ARM64 runner, otherwise the default is x86_64.
188-
189187
Run terraform by using the following commands
190188

191189
```bash
@@ -322,9 +320,10 @@ This module also allows you to run agents from a prebuilt AMI to gain faster sta
322320
Examples are located in the [examples](./examples) directory. The following examples are provided:
323321

324322
- _[Default](examples/default/README.md)_: The default example of the module
323+
- _[ARM64](examples/arm64/README.md)_: Example usage with ARM64 architecture
325324
- _[Ubuntu](examples/ubuntu/README.md)_: Example usage of creating a runner using Ubuntu AMIs.
326325
- _[Windows](examples/windows/README.md)_: Example usage of creating a runner using Windows as the OS.
327-
- _[Ephemeral](examples/ephemeral/README.md) : Example usages of ephemeral runners based on the default example.
326+
- _[Ephemeral](examples/ephemeral/README.md)_: Example usages of ephemeral runners based on the default example.
328327
- _[Prebuilt Images](examples/prebuilt/README.md)_: Example usages of deploying runners with a custom prebuilt image.
329328
- _[Permissions boundary](examples/permissions-boundary/README.md)_: Example usages of permissions boundaries.
330329

@@ -345,7 +344,7 @@ The following sub modules are optional and are provided as example or utility:
345344

346345
### ARM64 configuration for submodules
347346

348-
When using the top level module configure `runner_architecture = arm64` and insure the list of `instance_types` matches. When not using the top-level ensure the bot properties are set on the submodules.
347+
When using the top level module configure `runner_architecture = "arm64"` and ensure the list of `instance_types` matches. When not using the top-level, ensure these properties are set on the submodules.
349348

350349
## Debugging
351350

@@ -354,7 +353,7 @@ In case the setup does not work as intended follow the trace of events:
354353
- In the GitHub App configuration, the Advanced page displays all webhook events that were sent.
355354
- In AWS CloudWatch, every lambda has a log group. Look at the logs of the `webhook` and `scale-up` lambdas.
356355
- In AWS SQS you can see messages available or in flight.
357-
- Once an EC2 instance is running, you can connect to it in the EC2 user interface using Session Manager. Check the user data script using `cat /var/log/user-data.log`. By default several log files of the instances are streamed to AWS CloudWatch, look for a log group named `<environment>/runners`. In the log group you should see at least the log streams for the user data installation and runner agent.
356+
- Once an EC2 instance is running, you can connect to it in the EC2 user interface using Session Manager (use `enable_ssm_on_runners = true`). Check the user data script using `cat /var/log/user-data.log`. By default several log files of the instances are streamed to AWS CloudWatch, look for a log group named `<environment>/runners`. In the log group you should see at least the log streams for the user data installation and runner agent.
358357
- Registered instances should show up in the Settings - Actions page of the repository or organization (depending on the installation mode).
359358

360359
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/arm64/.terraform.lock.hcl

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/arm64/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Action runners deployment with ARM64 architecture
2+
3+
This module shows how to create GitHub action runners using AWS Graviton instances which have ARM64 architecture. Lambda release will be downloaded from GitHub.
4+
5+
## Usages
6+
7+
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.
8+
9+
> 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
10+
11+
```bash
12+
cd lambdas-download
13+
terraform init
14+
terraform apply
15+
cd ..
16+
```
17+
18+
Before running Terraform, ensure the GitHub app is configured. See the [configuration details](../../README.md#usages) for more details.
19+
20+
```bash
21+
terraform init
22+
terraform apply
23+
```
24+
25+
You can receive the webhook details by running:
26+
27+
```bash
28+
terraform output -raw webhook_secret
29+
```
30+
31+
Be-aware some shells will print some end of line character `%`.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
locals {
2+
version = "<REPLACE_BY_GITHUB_RELEASE_VERSION>"
3+
}
4+
5+
module "lambdas" {
6+
source = "../../../modules/download-lambda"
7+
lambdas = [
8+
{
9+
name = "webhook"
10+
tag = local.version
11+
},
12+
{
13+
name = "runners"
14+
tag = local.version
15+
},
16+
{
17+
name = "runner-binaries-syncer"
18+
tag = local.version
19+
}
20+
]
21+
}
22+
23+
output "files" {
24+
value = module.lambdas.files
25+
}

examples/arm64/main.tf

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
locals {
2+
environment = "default"
3+
aws_region = "eu-west-1"
4+
}
5+
6+
resource "random_id" "random" {
7+
byte_length = 20
8+
}
9+
10+
11+
################################################################################
12+
### Hybrid account
13+
################################################################################
14+
15+
module "runners" {
16+
source = "../../"
17+
create_service_linked_role_spot = true
18+
aws_region = local.aws_region
19+
vpc_id = module.vpc.vpc_id
20+
subnet_ids = module.vpc.private_subnets
21+
22+
environment = local.environment
23+
tags = {
24+
Project = "ProjectX"
25+
}
26+
27+
github_app = {
28+
key_base64 = var.github_app_key_base64
29+
id = var.github_app_id
30+
webhook_secret = random_id.random.hex
31+
}
32+
33+
# Grab zip files via lambda_download, will automatically get the ARM64 build
34+
webhook_lambda_zip = "lambdas-download/webhook.zip"
35+
runner_binaries_syncer_lambda_zip = "lambdas-download/runner-binaries-syncer.zip"
36+
runners_lambda_zip = "lambdas-download/runners.zip"
37+
38+
enable_organization_runners = false
39+
# Runners will automatically get the "arm64" label
40+
runner_extra_labels = "default,example"
41+
42+
# enable access to the runners via SSM
43+
enable_ssm_on_runners = true
44+
45+
# use S3 or KMS SSE to runners S3 bucket
46+
# runner_binaries_s3_sse_configuration = {
47+
# rule = {
48+
# apply_server_side_encryption_by_default = {
49+
# sse_algorithm = "AES256"
50+
# }
51+
# }
52+
# }
53+
54+
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
55+
# idle_config = [{
56+
# cron = "* * 9-17 * * *"
57+
# timeZone = "Europe/Amsterdam"
58+
# idleCount = 1
59+
# }]
60+
61+
# Let the module manage the service linked role
62+
# create_service_linked_role_spot = true
63+
64+
runner_architecture = "arm64"
65+
# Ensure all instance types have ARM64 architecture (ie. AWS Graviton processors)
66+
instance_types = ["t4g.large", "c6g.large"]
67+
68+
# override delay of events in seconds
69+
delay_webhook_event = 5
70+
runners_maximum_count = 1
71+
72+
# set up a fifo queue to remain order
73+
fifo_build_queue = true
74+
75+
# override scaling down
76+
scale_down_schedule_expression = "cron(* * * * ? *)"
77+
}

examples/arm64/outputs.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
output "runners" {
2+
value = {
3+
lambda_syncer_name = module.runners.binaries_syncer.lambda.function_name
4+
}
5+
}
6+
7+
output "webhook_endpoint" {
8+
value = module.runners.webhook.endpoint
9+
}
10+
11+
output "webhook_secret" {
12+
sensitive = true
13+
value = random_id.random.hex
14+
}
15+

examples/arm64/providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "aws" {
2+
region = local.aws_region
3+
}

0 commit comments

Comments
 (0)