Skip to content

Commit b23a6c4

Browse files
authored
Merge pull request #1376 from philips-labs/develop
release
2 parents 5d47c64 + 0a910e0 commit b23a6c4

Some content is hidden

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

44 files changed

+783
-406
lines changed

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
retention-days: 1
3434

3535
release:
36+
name: release
3637
runs-on: ubuntu-latest
3738
needs:
3839
prepare
@@ -80,4 +81,21 @@ jobs:
8081
cp .release/* .
8182
yarn
8283
yarn release --repositoryUrl https://x-access-token:[email protected]/$GITHUB_REPOSITORY.git
84+
85+
provenance:
86+
name: Generate provenance
87+
runs-on: ubuntu-20.04
88+
needs:
89+
release
90+
if: startsWith(github.ref, 'refs/tags/')
91+
92+
steps:
93+
- name: Generate provenance for release
94+
uses: philips-labs/[email protected]
95+
with:
96+
artifact_path: release-assets
97+
output_path: 'build.provenance'
98+
tag_name: "${{ github.ref_name }}"
99+
env:
100+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
83101

.github/workflows/terraform.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ env:
1313
tf_working_dir: "."
1414
AWS_REGION: eu-west-1
1515
jobs:
16-
1716
verify_module:
1817
name: Verify module
1918
strategy:
2019
matrix:
21-
terraform: [1.0.8]
20+
terraform: [1.0.8]
2221
runs-on: ubuntu-latest
2322
container:
2423
image: hashicorp/terraform:${{ matrix.terraform }}
@@ -43,15 +42,15 @@ jobs:
4342
strategy:
4443
fail-fast: false
4544
matrix:
46-
terraform: [0.14.1, 0.15.0, 1.0.8]
45+
terraform: [0.14.3, 0.15.5, 1.0.8]
4746
example: ["default", "ubuntu"]
4847
defaults:
4948
run:
5049
working-directory: examples/${{ matrix.example }}
5150
runs-on: ubuntu-latest
5251
container:
5352
image: hashicorp/terraform:${{ matrix.terraform }}
54-
steps:
53+
steps:
5554
- uses: actions/checkout@v2
5655
- name: terraform init
5756
run: terraform init -get -backend=false -input=false
@@ -61,5 +60,3 @@ jobs:
6160
continue-on-error: true
6261
- name: validate terraform
6362
run: terraform validate
64-
65-

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This [Terraform](https://www.terraform.io/) module creates the required infrastr
2424
- [Providers](#providers)
2525
- [Modules](#modules)
2626
- [Resources](#resources)
27+
- [Modules](#modules-1)
28+
- [Resources](#resources-1)
2729
- [Inputs](#inputs)
2830
- [Outputs](#outputs)
2931
- [Contribution](#contribution)
@@ -382,11 +384,14 @@ In case the setup does not work as intended follow the trace of events:
382384
| <a name="input_instance_profile_path"></a> [instance\_profile\_path](#input\_instance\_profile\_path) | The path that will be added to the instance\_profile, if not set the environment name will be used. | `string` | `null` | no |
383385
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | [DEPRECATED] See instance\_types. | `string` | `"m5.large"` | no |
384386
| <a name="input_instance_types"></a> [instance\_types](#input\_instance\_types) | List of instance types for the action runner. | `list(string)` | `null` | no |
387+
| <a name="input_job_queue_retention_in_seconds"></a> [job\_queue\_retention\_in\_seconds](#input\_job\_queue\_retention\_in\_seconds) | The number of seconds the job is held in the queue before it is purged | `number` | `86400` | no |
385388
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | Key pair name | `string` | `null` | no |
386389
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | Optional CMK Key ARN to be used for Parameter Store. This key must be in the current account. | `string` | `null` | no |
387390
| <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 |
388391
| <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 |
389392
| <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 |
393+
| <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 |
394+
| <a name="input_log_type"></a> [log\_type](#input\_log\_type) | Logging format for lambda logging. Valid values are 'json', 'pretty', 'hidden'. | `string` | `"pretty"` | no |
390395
| <a name="input_logging_retention_in_days"></a> [logging\_retention\_in\_days](#input\_logging\_retention\_in\_days) | Specifies the number of days you want to retain log events for the lambda log group. Possible values are: 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `180` | no |
391396
| <a name="input_market_options"></a> [market\_options](#input\_market\_options) | Market options for the action runner instances. Setting the value to `null` let the scaler create on-demand instances instead of spot instances. | `string` | `"spot"` | no |
392397
| <a name="input_minimum_running_time_in_minutes"></a> [minimum\_running\_time\_in\_minutes](#input\_minimum\_running\_time\_in\_minutes) | The time an ec2 action runner should be running at minimum before terminated if not busy. | `number` | `5` | no |
@@ -396,9 +401,11 @@ In case the setup does not work as intended follow the trace of events:
396401
| <a name="input_runner_additional_security_group_ids"></a> [runner\_additional\_security\_group\_ids](#input\_runner\_additional\_security\_group\_ids) | (optional) List of additional security groups IDs to apply to the runner | `list(string)` | `[]` | no |
397402
| <a name="input_runner_allow_prerelease_binaries"></a> [runner\_allow\_prerelease\_binaries](#input\_runner\_allow\_prerelease\_binaries) | Allow the runners to update to prerelease binaries. | `bool` | `false` | no |
398403
| <a name="input_runner_as_root"></a> [runner\_as\_root](#input\_runner\_as\_root) | Run the action runner under the root user. | `bool` | `false` | no |
404+
| <a name="input_runner_binaries_s3_sse_configuration"></a> [runner\_binaries\_s3\_sse\_configuration](#input\_runner\_binaries\_s3\_sse\_configuration) | Map containing server-side encryption configuration for runner-binaries S3 bucket. | `any` | `{}` | no |
399405
| <a name="input_runner_binaries_syncer_lambda_timeout"></a> [runner\_binaries\_syncer\_lambda\_timeout](#input\_runner\_binaries\_syncer\_lambda\_timeout) | Time out of the binaries sync lambda in seconds. | `number` | `300` | no |
400406
| <a name="input_runner_binaries_syncer_lambda_zip"></a> [runner\_binaries\_syncer\_lambda\_zip](#input\_runner\_binaries\_syncer\_lambda\_zip) | File location of the binaries sync lambda zip file. | `string` | `null` | no |
401407
| <a name="input_runner_boot_time_in_minutes"></a> [runner\_boot\_time\_in\_minutes](#input\_runner\_boot\_time\_in\_minutes) | The minimum time for an EC2 runner to boot and register as a runner. | `number` | `5` | no |
408+
| <a name="input_runner_ec2_tags"></a> [runner\_ec2\_tags](#input\_runner\_ec2\_tags) | Map of tags that will be added to the launch template instance tag specificatons. | `map(string)` | `{}` | no |
402409
| <a name="input_runner_egress_rules"></a> [runner\_egress\_rules](#input\_runner\_egress\_rules) | List of egress rules for the GitHub runner instances. | <pre>list(object({<br> cidr_blocks = list(string)<br> ipv6_cidr_blocks = list(string)<br> prefix_list_ids = list(string)<br> from_port = number<br> protocol = string<br> security_groups = list(string)<br> self = bool<br> to_port = number<br> description = string<br> }))</pre> | <pre>[<br> {<br> "cidr_blocks": [<br> "0.0.0.0/0"<br> ],<br> "description": null,<br> "from_port": 0,<br> "ipv6_cidr_blocks": [<br> "::/0"<br> ],<br> "prefix_list_ids": null,<br> "protocol": "-1",<br> "security_groups": null,<br> "self": null,<br> "to_port": 0<br> }<br>]</pre> | no |
403410
| <a name="input_runner_extra_labels"></a> [runner\_extra\_labels](#input\_runner\_extra\_labels) | Extra labels for the runners (GitHub). Separate each label by a comma | `string` | `""` | no |
404411
| <a name="input_runner_group_name"></a> [runner\_group\_name](#input\_runner\_group\_name) | Name of the runner group. | `string` | `"Default"` | no |

examples/default/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ module "runners" {
3939
# enable access to the runners via SSM
4040
enable_ssm_on_runners = true
4141

42+
# use S3 or KMS SSE to runners S3 bucket
43+
# runner_binaries_s3_sse_configuration = {
44+
# rule = {
45+
# apply_server_side_encryption_by_default = {
46+
# sse_algorithm = "AES256"
47+
# }
48+
# }
49+
# }
50+
4251
# Uncommet idle config to have idle runners from 9 to 5 in time zone Amsterdam
4352
# idle_config = [{
4453
# cron = "* * 9-17 * * *"

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ module "webhook" {
6464
role_path = var.role_path
6565
role_permissions_boundary = var.role_permissions_boundary
6666
repository_white_list = var.repository_white_list
67+
68+
log_type = var.log_type
69+
log_level = var.log_level
6770
}
6871

6972
module "runners" {
@@ -133,6 +136,9 @@ module "runners" {
133136
ghes_ssl_verify = var.ghes_ssl_verify
134137

135138
kms_key_arn = var.kms_key_arn
139+
140+
log_type = var.log_type
141+
log_level = var.log_level
136142
}
137143

138144
module "runner_binaries" {
@@ -154,8 +160,13 @@ module "runner_binaries" {
154160
lambda_timeout = var.runner_binaries_syncer_lambda_timeout
155161
logging_retention_in_days = var.logging_retention_in_days
156162

163+
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
164+
157165
role_path = var.role_path
158166
role_permissions_boundary = var.role_permissions_boundary
167+
168+
log_type = var.log_type
169+
log_level = var.log_level
159170
}
160171

161172
resource "aws_resourcegroups_group" "resourcegroups_group" {

modules/runner-binaries-syncer/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ No modules.
8484
| <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 |
8585
| <a name="input_lambda_timeout"></a> [lambda\_timeout](#input\_lambda\_timeout) | Time out of the lambda in seconds. | `number` | `300` | no |
8686
| <a name="input_lambda_zip"></a> [lambda\_zip](#input\_lambda\_zip) | File location of the lambda zip file. | `string` | `null` | no |
87+
| <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 |
88+
| <a name="input_log_type"></a> [log\_type](#input\_log\_type) | Logging format for lambda logging. Valid values are 'json', 'pretty', 'hidden'. | `string` | `"pretty"` | no |
8789
| <a name="input_logging_retention_in_days"></a> [logging\_retention\_in\_days](#input\_logging\_retention\_in\_days) | Specifies the number of days you want to retain log events for the lambda log group. Possible values are: 0, 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, and 3653. | `number` | `7` | no |
8890
| <a name="input_role_path"></a> [role\_path](#input\_role\_path) | The path that will be added to the role, if not set the environment name will be used. | `string` | `null` | no |
8991
| <a name="input_role_permissions_boundary"></a> [role\_permissions\_boundary](#input\_role\_permissions\_boundary) | Permissions boundary that will be added to the created role for the lambda. | `string` | `null` | no |
9092
| <a name="input_runner_allow_prerelease_binaries"></a> [runner\_allow\_prerelease\_binaries](#input\_runner\_allow\_prerelease\_binaries) | Allow the runners to update to prerelease binaries. | `bool` | `false` | no |
9193
| <a name="input_runner_architecture"></a> [runner\_architecture](#input\_runner\_architecture) | The platform architecture for the runner instance (x64, arm64), defaults to 'x64' | `string` | `"x64"` | no |
94+
| <a name="input_server_side_encryption_configuration"></a> [server\_side\_encryption\_configuration](#input\_server\_side\_encryption\_configuration) | Map containing server-side encryption configuration. | `any` | `{}` | no |
9295
| <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 |
9396
| <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 |
9497
| <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 |

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"devDependencies": {
1818
"@octokit/rest": "^18.12.0",
1919
"@types/jest": "^27.0.1",
20-
"@types/node": "^16.11.5",
20+
"@types/node": "^16.11.6",
2121
"@types/request": "^2.48.4",
2222
"@typescript-eslint/eslint-plugin": "^4.33.0",
2323
"@typescript-eslint/parser": "^4.33.0",
2424
"@vercel/ncc": "^0.31.1",
25-
"aws-sdk": "^2.1016.0",
25+
"aws-sdk": "^2.1019.0",
2626
"eslint": "^7.32.0",
2727
"eslint-plugin-prettier": "4.0.0",
2828
"jest": "^27.3.1",
@@ -32,6 +32,7 @@
3232
"typescript": "^4.4.4"
3333
},
3434
"dependencies": {
35+
"tslog": "^3.2.2",
3536
"axios": "^0.24.0"
3637
}
37-
}
38+
}

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/lambda.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { handle } from './syncer/handler';
2+
import { logger } from './syncer/logger';
23

34
// eslint-disable-next-line
45
export const handler = async (event: any, context: any, callback: any): Promise<void> => {
6+
logger.setSettings({ requestId: context.awsRequestId });
7+
logger.debug(JSON.stringify(event));
58
try {
69
await handle();
710
callback(null);

modules/runner-binaries-syncer/lambdas/runner-binaries-syncer/src/syncer/handler.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { PassThrough } from 'stream';
33
import { S3 } from 'aws-sdk';
44
import AWS from 'aws-sdk';
55
import axios from 'axios';
6+
import { logger as rootLogger } from './logger';
7+
8+
const logger = rootLogger.getChildLogger();
69

710
const versionKey = 'name';
811

@@ -22,7 +25,7 @@ async function getCachedVersion(s3: S3, cacheObject: CacheObject): Promise<strin
2225
const versions = objectTagging.TagSet?.filter((t: S3.Tag) => t.Key === versionKey);
2326
return versions.length === 1 ? versions[0].Value : undefined;
2427
} catch (e) {
25-
console.debug('No tags found');
28+
logger.debug('No tags found');
2629
return undefined;
2730
}
2831
}
@@ -73,7 +76,7 @@ async function uploadToS3(s3: S3, cacheObject: CacheObject, actionRunnerReleaseA
7376
})
7477
.promise();
7578

76-
console.debug('Start downloading %s and uploading to S3.', actionRunnerReleaseAsset.name);
79+
logger.debug('Start downloading %s and uploading to S3.', actionRunnerReleaseAsset.name);
7780

7881
const readPromise = new Promise<void>((resolve, reject) => {
7982
axios
@@ -93,9 +96,9 @@ async function uploadToS3(s3: S3, cacheObject: CacheObject, actionRunnerReleaseA
9396
});
9497

9598
await Promise.all([readPromise, writePromise])
96-
.then(() => console.info(`The new distribution is uploaded to S3.`))
99+
.then(() => logger.info(`The new distribution is uploaded to S3.`))
97100
.catch((error) => {
98-
console.error(`Uploading of the new distribution to S3 failed: ${error}`);
101+
logger.error(`Uploading of the new distribution to S3 failed: ${error}`);
99102
throw error;
100103
});
101104
}
@@ -120,10 +123,10 @@ export const handle = async (): Promise<void> => {
120123
}
121124

122125
const currentVersion = await getCachedVersion(s3, cacheObject);
123-
console.debug('latest: ' + currentVersion);
126+
logger.debug('latest: ' + currentVersion);
124127
if (currentVersion === undefined || currentVersion != actionRunnerReleaseAsset.name) {
125128
uploadToS3(s3, cacheObject, actionRunnerReleaseAsset);
126129
} else {
127-
console.debug('Distribution is up-to-date, no action.');
130+
logger.debug('Distribution is up-to-date, no action.');
128131
}
129132
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Logger } from 'tslog';
2+
3+
export const logger = new Logger({
4+
colorizePrettyLogs: false,
5+
displayInstanceName: false,
6+
minLevel: process.env.LOG_LEVEL || 'info',
7+
name: 'runner-binaries-syncer',
8+
overwriteConsole: true,
9+
type: process.env.LOG_TYPE || 'pretty',
10+
});

0 commit comments

Comments
 (0)