Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit b912bb8

Browse files
committed
feat!: Organise SSM paramamters by path (#2569)
Migration is only required when using pre-build AMI with your tailored start-runner script. Before all parameters were based on convetion. We have update them to be predictable with still similar conventions as default. We set the tag ghr:ssm_config_path as EC2 instance tag to the path used for the configuration. In the config path we store the same values as before (run_as, enable_cloudwatch, agent_mode). The tokens are stored in a separate location which can be retrieved by looking up the value token_path in the config. For a more details example check-out the following diffs: Linux start script // TODO UPDATE AFTER MERGE Windows start script // TODO UPDATE AFTER MERGE
1 parent 0823d47 commit b912bb8

File tree

104 files changed

+1535
-2064
lines changed

Some content is hidden

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

104 files changed

+1535
-2064
lines changed

Diff for: .github/lint/tflint.tfvars

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
aws_region = null
2+
github_app = {
3+
id = "0"
4+
key_base64 = "0"
5+
webhook_secret = "0"
6+
}
7+
subnet_ids = []
8+
vpc_id = null

Diff for: .github/workflows/terraform.yml

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
paths-ignore:
88
- "modules/*/lambdas/**"
99

10+
permissions:
11+
contents: read
12+
pull-requests: write
13+
1014
env:
1115
AWS_REGION: eu-west-1
1216
jobs:
@@ -37,6 +41,14 @@ jobs:
3741
continue-on-error: true
3842
- name: validate terraform
3943
run: terraform validate
44+
- if: contains(matrix.terraform, '1.3.')
45+
name: Setup TFLint
46+
uses: terraform-linters/setup-tflint@v2
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
- if: contains(matrix.terraform, '1.3.')
50+
name: Run TFLint
51+
run: tflint -f compact
4052

4153
verify_examples:
4254
name: Verify examples
@@ -92,3 +104,4 @@ jobs:
92104
continue-on-error: true
93105
- name: validate terraform
94106
run: terraform validate
107+

Diff for: .pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.52.0
3+
rev: v1.76.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_tflint
77
- id: terraform_docs
88
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v4.0.1
9+
rev: v4.3.0
1010
hooks:
1111
- id: check-merge-conflict

Diff for: .tflint.hcl

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
config {
2+
format = "compact"
3+
module = true
4+
5+
varfile = [".github/lint/tflint.tfvars"]
6+
7+
}

Diff for: README.md

+32-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This [Terraform](https://www.terraform.io/) module creates the required infrastr
1313
- [Motivation](#motivation)
1414
- [Overview](#overview)
1515
- [Major configuration options.](#major-configuration-options)
16+
- [AWS SSM Parameters](#aws-ssm-parameters)
1617
- [Usages](#usages)
1718
- [Setup GitHub App (part 1)](#setup-github-app-part-1)
1819
- [Setup terraform module](#setup-terraform-module)
@@ -91,6 +92,26 @@ To be able to support a number of use-cases the module has quite a lot of config
9192
- Spot vs on-demand. The runners use either the EC2 spot or on-demand life cycle. Runners will be created via the AWS [CreateFleet API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_CreateFleet.html). The module (scale up lambda) will request via the CreateFleet API to create instances in one of the subnets and of the specified instance types.
9293
- ARM64 support via Graviton/Graviton2 instance-types. 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.
9394

95+
### AWS SSM Parameters
96+
97+
The module uses the AWS System Manager Parameter store to store configuration for the runners, registration tokens and secrets for the Lambda's. Via the variable `ssm_paths` paths for the parameters can be configured. The location of the configuration parameters is retrieved buy the runners via the instance tag `ghr:ssm_config_path`. The following default paths will be used.
98+
99+
| Path | Description |
100+
| ----------- | ----------- |
101+
| `ssm_paths.root`/`var.prefix`?/app/ | App secrets used by Lambda's |
102+
| `ssm_paths.root`/`var.prefix`?/runners/config/`<name>` | Configuration parameters used by runner start script |
103+
| `ssm_paths.root`/`var.prefix`?/runners/tokens/`<ec2-instance-id>` | Registration tokens for the runners generate by the scale-up lambda, consumed by the start script on the runner. |
104+
105+
Available configuration parameters:
106+
107+
| Parameter name | Description |
108+
| ----------- | ----------- |
109+
| `agent_mode` | Indicates if the agent is running in ephemeral mode or not. |
110+
| `enable_cloudwatch` | Configuration for the cloudwatch agent to stream logging. |
111+
| `run_as` | The user used for running the GitHub action runner agent. |
112+
| `token_path` | The path where tokens are stored. |
113+
114+
94115
## Usages
95116

96117
Examples are provided in [the example directory](examples/). Please ensure you have installed the following tools.
@@ -384,15 +405,16 @@ We welcome any improvement to the standard module to make the default as secure
384405

385406
| Name | Version |
386407
|------|---------|
387-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.1 |
408+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
388409
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.15 |
410+
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.0 |
389411

390412
## Providers
391413

392414
| Name | Version |
393415
|------|---------|
394416
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.15 |
395-
| <a name="provider_random"></a> [random](#provider\_random) | n/a |
417+
| <a name="provider_random"></a> [random](#provider\_random) | ~> 3.0 |
396418

397419
## Modules
398420

@@ -459,7 +481,7 @@ We welcome any improvement to the standard module to make the default as secure
459481
| <a name="input_lambda_architecture"></a> [lambda\_architecture](#input\_lambda\_architecture) | AWS Lambda architecture. Lambda functions using Graviton processors ('arm64') tend to have better price/performance than 'x86\_64' functions. | `string` | `"x86_64"` | no |
460482
| <a name="input_lambda_principals"></a> [lambda\_principals](#input\_lambda\_principals) | (Optional) add extra principals to the role created for execution of the lambda, e.g. for local testing. | <pre>list(object({<br> type = string<br> identifiers = list(string)<br> }))</pre> | `[]` | no |
461483
| <a name="input_lambda_runtime"></a> [lambda\_runtime](#input\_lambda\_runtime) | AWS Lambda runtime. | `string` | `"nodejs16.x"` | no |
462-
| <a name="input_lambda_s3_bucket"></a> [lambda\_s3\_bucket](#input\_lambda\_s3\_bucket) | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
484+
| <a name="input_lambda_s3_bucket"></a> [lambda\_s3\_bucket](#input\_lambda\_s3\_bucket) | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `string` | `null` | no |
463485
| <a name="input_lambda_security_group_ids"></a> [lambda\_security\_group\_ids](#input\_lambda\_security\_group\_ids) | List of security group IDs associated with the Lambda function. | `list(string)` | `[]` | no |
464486
| <a name="input_lambda_subnet_ids"></a> [lambda\_subnet\_ids](#input\_lambda\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | `[]` | no |
465487
| <a name="input_log_level"></a> [log\_level](#input\_log\_level) | Logging level for lambda logging. Valid values are 'silly', 'trace', 'debug', 'info', 'warn', 'error', 'fatal'. | `string` | `"info"` | no |
@@ -498,25 +520,26 @@ We welcome any improvement to the standard module to make the default as secure
498520
| <a name="input_runner_metadata_options"></a> [runner\_metadata\_options](#input\_runner\_metadata\_options) | Metadata options for the ec2 runner instances. By default, the module uses metadata tags for bootstrapping the runner, only disable `instance_metadata_tags` when using custom scripts for starting the runner. | `map(any)` | <pre>{<br> "http_endpoint": "enabled",<br> "http_put_response_hop_limit": 1,<br> "http_tokens": "optional",<br> "instance_metadata_tags": "enabled"<br>}</pre> | no |
499521
| <a name="input_runner_os"></a> [runner\_os](#input\_runner\_os) | The EC2 Operating System type to use for action runner instances (linux,windows). | `string` | `"linux"` | no |
500522
| <a name="input_runner_run_as"></a> [runner\_run\_as](#input\_runner\_run\_as) | Run the GitHub actions agent as user. | `string` | `"ec2-user"` | no |
501-
| <a name="input_runners_lambda_s3_key"></a> [runners\_lambda\_s3\_key](#input\_runners\_lambda\_s3\_key) | S3 key for runners lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
502-
| <a name="input_runners_lambda_s3_object_version"></a> [runners\_lambda\_s3\_object\_version](#input\_runners\_lambda\_s3\_object\_version) | S3 object version for runners lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
523+
| <a name="input_runners_lambda_s3_key"></a> [runners\_lambda\_s3\_key](#input\_runners\_lambda\_s3\_key) | S3 key for runners lambda function. Required if using S3 bucket to specify lambdas. | `string` | `null` | no |
524+
| <a name="input_runners_lambda_s3_object_version"></a> [runners\_lambda\_s3\_object\_version](#input\_runners\_lambda\_s3\_object\_version) | S3 object version for runners lambda function. Useful if S3 versioning is enabled on source bucket. | `string` | `null` | no |
503525
| <a name="input_runners_lambda_zip"></a> [runners\_lambda\_zip](#input\_runners\_lambda\_zip) | File location of the lambda zip file for scaling runners. | `string` | `null` | no |
504526
| <a name="input_runners_maximum_count"></a> [runners\_maximum\_count](#input\_runners\_maximum\_count) | The maximum number of runners that will be created. | `number` | `3` | no |
505527
| <a name="input_runners_scale_down_lambda_timeout"></a> [runners\_scale\_down\_lambda\_timeout](#input\_runners\_scale\_down\_lambda\_timeout) | Time out for the scale down lambda in seconds. | `number` | `60` | no |
506528
| <a name="input_runners_scale_up_lambda_timeout"></a> [runners\_scale\_up\_lambda\_timeout](#input\_runners\_scale\_up\_lambda\_timeout) | Time out for the scale up lambda in seconds. | `number` | `30` | no |
507529
| <a name="input_scale_down_schedule_expression"></a> [scale\_down\_schedule\_expression](#input\_scale\_down\_schedule\_expression) | Scheduler expression to check every x for scale down. | `string` | `"cron(*/5 * * * ? *)"` | no |
508530
| <a name="input_scale_up_reserved_concurrent_executions"></a> [scale\_up\_reserved\_concurrent\_executions](#input\_scale\_up\_reserved\_concurrent\_executions) | Amount of reserved concurrent executions for the scale-up lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. | `number` | `1` | no |
531+
| <a name="input_ssm_paths"></a> [ssm\_paths](#input\_ssm\_paths) | The root path used in SSM to store configuration and secreets. | <pre>object({<br> root = string<br> use_prefix = bool<br> app = string<br> runners = string<br> })</pre> | <pre>{<br> "app": "app",<br> "root": "github-action-runners",<br> "runners": "runners",<br> "use_prefix": true<br>}</pre> | no |
509532
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of subnets in which the action runners will be launched, the subnets needs to be subnets in the `vpc_id`. | `list(string)` | n/a | yes |
510-
| <a name="input_syncer_lambda_s3_key"></a> [syncer\_lambda\_s3\_key](#input\_syncer\_lambda\_s3\_key) | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
511-
| <a name="input_syncer_lambda_s3_object_version"></a> [syncer\_lambda\_s3\_object\_version](#input\_syncer\_lambda\_s3\_object\_version) | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
533+
| <a name="input_syncer_lambda_s3_key"></a> [syncer\_lambda\_s3\_key](#input\_syncer\_lambda\_s3\_key) | S3 key for syncer lambda function. Required if using S3 bucket to specify lambdas. | `string` | `null` | no |
534+
| <a name="input_syncer_lambda_s3_object_version"></a> [syncer\_lambda\_s3\_object\_version](#input\_syncer\_lambda\_s3\_object\_version) | S3 object version for syncer lambda function. Useful if S3 versioning is enabled on source bucket. | `string` | `null` | no |
512535
| <a name="input_tags"></a> [tags](#input\_tags) | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
513536
| <a name="input_userdata_post_install"></a> [userdata\_post\_install](#input\_userdata\_post\_install) | Script to be ran after the GitHub Actions runner is installed on the EC2 instances | `string` | `""` | no |
514537
| <a name="input_userdata_pre_install"></a> [userdata\_pre\_install](#input\_userdata\_pre\_install) | Script to be ran before the GitHub Actions runner is installed on the EC2 instances | `string` | `""` | no |
515538
| <a name="input_userdata_template"></a> [userdata\_template](#input\_userdata\_template) | Alternative user-data template, replacing the default template. By providing your own user\_data you have to take care of installing all required software, including the action runner. Variables userdata\_pre/post\_install are ignored. | `string` | `null` | no |
516539
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The VPC for security groups of the action runners. | `string` | n/a | yes |
517540
| <a name="input_webhook_lambda_apigateway_access_log_settings"></a> [webhook\_lambda\_apigateway\_access\_log\_settings](#input\_webhook\_lambda\_apigateway\_access\_log\_settings) | n/a | <pre>object({<br> destination_arn = string<br> format = string<br> })</pre> | `null` | no |
518-
| <a name="input_webhook_lambda_s3_key"></a> [webhook\_lambda\_s3\_key](#input\_webhook\_lambda\_s3\_key) | S3 key for webhook lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
519-
| <a name="input_webhook_lambda_s3_object_version"></a> [webhook\_lambda\_s3\_object\_version](#input\_webhook\_lambda\_s3\_object\_version) | S3 object version for webhook lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
541+
| <a name="input_webhook_lambda_s3_key"></a> [webhook\_lambda\_s3\_key](#input\_webhook\_lambda\_s3\_key) | S3 key for webhook lambda function. Required if using S3 bucket to specify lambdas. | `string` | `null` | no |
542+
| <a name="input_webhook_lambda_s3_object_version"></a> [webhook\_lambda\_s3\_object\_version](#input\_webhook\_lambda\_s3\_object\_version) | S3 object version for webhook lambda function. Useful if S3 versioning is enabled on source bucket. | `string` | `null` | no |
520543
| <a name="input_webhook_lambda_timeout"></a> [webhook\_lambda\_timeout](#input\_webhook\_lambda\_timeout) | Time out of the webhook lambda in seconds. | `number` | `10` | no |
521544
| <a name="input_webhook_lambda_zip"></a> [webhook\_lambda\_zip](#input\_webhook\_lambda\_zip) | File location of the webhook lambda zip file. | `string` | `null` | no |
522545
| <a name="input_workflow_job_queue_configuration"></a> [workflow\_job\_queue\_configuration](#input\_workflow\_job\_queue\_configuration) | Configuration options for workflow job queue which is only applicable if the flag enable\_workflow\_job\_events\_queue is set to true. | <pre>object({<br> delay_seconds = number<br> visibility_timeout_seconds = number<br> message_retention_seconds = number<br> })</pre> | <pre>{<br> "delay_seconds": null,<br> "message_retention_seconds": null,<br> "visibility_timeout_seconds": null<br>}</pre> | no |

Diff for: examples/arm64/.terraform.lock.hcl

+30-26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: examples/arm64/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Steps for the full setup, such as creating a GitHub app can be found in the root
99
> 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
1010
1111
```bash
12-
cd lambdas-download
12+
cd ../lambdas-download
1313
terraform init
14-
terraform apply
15-
cd ..
14+
terraform apply -var=module_version=<VERSION>
15+
cd -
1616
```
1717

1818
Before running Terraform, ensure the GitHub app is configured. See the [configuration details](https://github.com/philips-labs/terraform-aws-github-runner#usages) for more details.

Diff for: examples/arm64/lambdas-download/versions.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 1"
3+
}

0 commit comments

Comments
 (0)