Skip to content

Commit efc5b56

Browse files
committed
cppal initial commit
1 parent e315230 commit efc5b56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3109
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Terraform module for scalable self hosted GitHub action runners <!-- omit in toc -->
22

3+
see [README-CPP.md](README-CPP.md) for the C++ specific admin info.
4+
35
[![awesome-runners](https://img.shields.io/badge/listed%20on-awesome--runners-blue.svg)](https://github.com/jonico/awesome-runners)[![Terraform registry](https://img.shields.io/github/v/release/philips-labs/terraform-aws-github-runner?label=Terraform%20Registry)](https://registry.terraform.io/modules/philips-labs/github-runner/aws/) [![Terraform checks](https://github.com/philips-labs/terraform-aws-github-runner/actions/workflows/terraform.yml/badge.svg)](https://github.com/philips-labs/terraform-aws-github-runner/actions/workflows/terraform.yml) [![Lambdas](https://github.com/philips-labs/terraform-aws-github-runner/actions/workflows/lambda.yml/badge.svg)](https://github.com/philips-labs/terraform-aws-github-runner/actions/workflows/lambda.yml)
46

57
This [Terraform](https://www.terraform.io/) module creates the required infrastructure needed to host [GitHub Actions](https://github.com/features/actions) self-hosted, auto-scaling runners on [AWS spot instances](https://aws.amazon.com/ec2/spot/). It provides the required logic to handle the life cycle for scaling up and down using a set of AWS Lambda functions. Runners are scaled down to zero to avoid costs when no workflows are active.

examples/lambdas-download-cppal/.terraform.lock.hcl

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Wrapper module to download lambda's for running the examples
2+
3+
Module is used by examples to download Lambda distribution from the GitHub release.
4+
5+
```bash
6+
terraform init
7+
terraform apply -var=module_version=<VERSION>
8+
```
9+
10+
<!-- BEGIN_TF_DOCS -->
11+
## Requirements
12+
13+
| Name | Version |
14+
|------|---------|
15+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1 |
16+
17+
## Providers
18+
19+
No providers.
20+
21+
## Modules
22+
23+
| Name | Source | Version |
24+
|------|--------|---------|
25+
| <a name="module_lambdas"></a> [lambdas](#module\_lambdas) | ../../modules/download-lambda | n/a |
26+
27+
## Resources
28+
29+
No resources.
30+
31+
## Inputs
32+
33+
| Name | Description | Type | Default | Required |
34+
|------|-------------|------|---------|:--------:|
35+
| <a name="input_module_version"></a> [module\_version](#input\_module\_version) | Module release version. | `string` | n/a | yes |
36+
37+
## Outputs
38+
39+
| Name | Description |
40+
|------|-------------|
41+
| <a name="output_files"></a> [files](#output\_files) | n/a |
42+
<!-- END_TF_DOCS -->
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module "lambdas" {
2+
source = "../../modules/download-lambda"
3+
lambdas = [
4+
{
5+
name = "webhook"
6+
tag = var.module_version
7+
},
8+
{
9+
name = "runners"
10+
tag = var.module_version
11+
},
12+
{
13+
name = "runner-binaries-syncer"
14+
tag = var.module_version
15+
}
16+
]
17+
}
18+
19+
output "files" {
20+
value = module.lambdas.files
21+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
variable "module_version" {
2+
description = "Module release version."
3+
type = string
4+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 1"
3+
}

examples/multi-runner-cppal/.terraform.lock.hcl

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

examples/multi-runner-cppal/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Action runners deployment of Multiple-Runner-Configurations-Together example
2+
3+
This module shows how to create GitHub action runners with multiple runner configuration together in one deployment. This example has the configurations for the following runner types with the relevant labels supported by them as matchers:
4+
5+
- Linux ARM64 `["self-hosted", "linux", "arm64", "amazon"]`
6+
- Linux Ubuntu `["self-hosted", "linux", "x64", "ubuntu-latest"]` or `["self-hosted", "linux", "x64", "ubuntu-2204"]``
7+
- Linux X64 `["self-hosted", "linux", "x64", "amazon"]`
8+
- Windows X64 `["self-hosted", "windows", "x64", "servercore-2022"]`
9+
10+
The module will decide the runner for the workflow job based on the match in the labels defined in the workflow job and runner configuration. Also the runner configuration allows the match to be exact or non-exact match. We recommend to use only exact matches.
11+
12+
For exact match, all the labels defined in the workflow should be present in the runner configuration matchers and for non-exact match, some of the labels in the workflow, when present in runner configuration, shall be enough for the runner configuration to be used for the job. First the exact matchers are applied, next the non exact ones.
13+
14+
## Webhook
15+
16+
For the list of provided runner configurations, there will be a single webhook and only a single Github App to receive the notifications for all types of workflow triggers.
17+
18+
## Lambda distribution
19+
20+
Per combination of OS and architecture a lambda distribution syncer will be created. For this example there will be three instances (windows X64, linux X64, linux ARM).
21+
22+
## Usages
23+
24+
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.
25+
26+
> 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
27+
28+
```bash
29+
cd ../lambdas-download
30+
terraform init
31+
terraform apply -var=module_version=<VERSION>
32+
cd -
33+
```
34+
35+
Before running Terraform, ensure the GitHub app is configured. See the [configuration details](../../README.md#usages) for more details.
36+
37+
```bash
38+
terraform init
39+
terraform apply
40+
```
41+
42+
You can receive the webhook details by running:
43+
44+
```bash
45+
terraform output -raw webhook_secret
46+
```
47+
48+
Be-aware some shells will print some end of line character `%`.
49+
50+
<!-- BEGIN_TF_DOCS -->
51+
## Requirements
52+
53+
| Name | Version |
54+
|------|---------|
55+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
56+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0 |
57+
| <a name="requirement_local"></a> [local](#requirement\_local) | ~> 2.0 |
58+
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.0 |
59+
60+
## Providers
61+
62+
| Name | Version |
63+
|------|---------|
64+
| <a name="provider_random"></a> [random](#provider\_random) | 3.4.3 |
65+
66+
## Modules
67+
68+
| Name | Source | Version |
69+
|------|--------|---------|
70+
| <a name="module_multi-runner"></a> [multi-runner](#module\_multi-runner) | ../../modules/multi-runner | n/a |
71+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | 3.11.2 |
72+
73+
## Resources
74+
75+
| Name | Type |
76+
|------|------|
77+
| [random_id.random](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
78+
79+
## Inputs
80+
81+
| Name | Description | Type | Default | Required |
82+
|------|-------------|------|---------|:--------:|
83+
| <a name="input_environment"></a> [environment](#input\_environment) | n/a | `string` | `null` | no |
84+
| <a name="input_github_app"></a> [github\_app](#input\_github\_app) | GitHub for API usages. | <pre>object({<br> id = string<br> key_base64 = string<br> })</pre> | n/a | yes |
85+
86+
## Outputs
87+
88+
| Name | Description |
89+
|------|-------------|
90+
| <a name="output_webhook_endpoint"></a> [webhook\_endpoint](#output\_webhook\_endpoint) | n/a |
91+
| <a name="output_webhook_secret"></a> [webhook\_secret](#output\_webhook\_secret) | n/a |
92+
<!-- END_TF_DOCS -->
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
2+
data "aws_route_table" "gha_public_rt" {
3+
vpc_id = module.vpc.vpc_id
4+
tags = {
5+
Name = "vpc-gha-public"
6+
Environment = "gha"
7+
}
8+
}
9+
10+
data "aws_route_table" "gha_private_rt" {
11+
vpc_id = module.vpc.vpc_id
12+
tags = {
13+
Name = "vpc-gha-private"
14+
Environment = "gha"
15+
}
16+
}
17+
18+
resource "aws_vpc_peering_connection" "peering1" {
19+
peer_vpc_id = var.aws_default_vpc
20+
vpc_id = module.vpc.vpc_id
21+
auto_accept = true
22+
}
23+
24+
resource "aws_route" "default_vpc_route_1" {
25+
route_table_id = var.aws_default_route_table
26+
destination_cidr_block = "10.0.1.0/24"
27+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
28+
}
29+
30+
resource "aws_route" "default_vpc_route_2" {
31+
route_table_id = var.aws_default_route_table
32+
destination_cidr_block = "10.0.2.0/24"
33+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
34+
}
35+
resource "aws_route" "default_vpc_route_3" {
36+
route_table_id = var.aws_default_route_table
37+
destination_cidr_block = "10.0.3.0/24"
38+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
39+
}
40+
resource "aws_route" "default_vpc_route_101" {
41+
route_table_id = var.aws_default_route_table
42+
destination_cidr_block = "10.0.101.0/24"
43+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
44+
}
45+
resource "aws_route" "default_vpc_route_102" {
46+
route_table_id = var.aws_default_route_table
47+
destination_cidr_block = "10.0.102.0/24"
48+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
49+
}
50+
resource "aws_route" "default_vpc_route_103" {
51+
route_table_id = var.aws_default_route_table
52+
destination_cidr_block = "10.0.103.0/24"
53+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
54+
}
55+
56+
resource "aws_route" "gha_vpc_route_public_1" {
57+
route_table_id = data.aws_route_table.gha_public_rt.id
58+
destination_cidr_block = var.aws_default_cidr_range
59+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
60+
}
61+
62+
resource "aws_route" "gha_vpc_route_private_1" {
63+
route_table_id = data.aws_route_table.gha_private_rt.id
64+
destination_cidr_block = var.aws_default_cidr_range
65+
vpc_peering_connection_id = aws_vpc_peering_connection.peering1.id
66+
}

0 commit comments

Comments
 (0)