Skip to content

Commit 9b534d5

Browse files
authored
Merge pull request #1840 from philips-labs/develop
Release
2 parents 10d4ccb + c88a005 commit 9b534d5

Some content is hidden

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

41 files changed

+611
-543
lines changed

.github/workflows/lambda-runner-binaries-syncer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
working-directory: modules/runner-binaries-syncer/lambdas/runner-binaries-syncer
1818

1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
2121
- name: Install dependencies
2222
run: yarn install
2323
- name: Run prettier

.github/workflows/lambda-runners.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
working-directory: modules/runners/lambdas/runners
1818

1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
2121
- name: Install dependencies
2222
run: yarn install
2323
- name: Run prettier

.github/workflows/lambda-webhook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
working-directory: modules/webhook/lambdas/webhook
1818

1919
steps:
20-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v3
2121
- name: Install dependencies
2222
run: yarn install
2323
- name: Run prettier

.github/workflows/packer-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
working-directory: images/${{ matrix.image }}
2828
steps:
2929
- name: "Checkout"
30-
uses: actions/checkout@v2
30+
uses: actions/checkout@v3
3131

3232
- name: packer init
3333
run: packer init .

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
env:
2222
LAMBDA: ${{ matrix.lambda }}
2323
run: echo ::set-output name=name::${LAMBDA##*/}
24-
- uses: actions/checkout@v2
24+
- uses: actions/checkout@v3
2525
- name: Add zip
2626
run: apt update && apt install zip
2727
- name: Build dist
@@ -39,7 +39,7 @@ jobs:
3939
needs:
4040
prepare
4141
steps:
42-
- uses: actions/checkout@v2
42+
- uses: actions/checkout@v3
4343
with:
4444
fetch-depth: 0
4545
persist-credentials: false

.github/workflows/terraform.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
image: hashicorp/terraform:${{ matrix.terraform }}
2222
steps:
2323
- name: "Checkout"
24-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
2525
- name: "Fake zip files" # Validate will fail if it cannot find the zip files
2626
run: |
2727
touch modules/webhook/lambdas/webhook/webhook.zip
@@ -53,7 +53,7 @@ jobs:
5353
container:
5454
image: hashicorp/terraform:${{ matrix.terraform }}
5555
steps:
56-
- uses: actions/checkout@v2
56+
- uses: actions/checkout@v3
5757
- name: terraform init
5858
run: terraform init -get -backend=false -input=false
5959
- if: contains(matrix.terraform, '1.1.')

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,18 @@ In case the setup does not work as intended follow the trace of events:
387387
| [aws_resourcegroups_group.resourcegroups_group](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/resourcegroups_group) | resource |
388388
| [aws_sqs_queue.queued_builds](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
389389
| [aws_sqs_queue.queued_builds_dlq](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
390+
| [aws_sqs_queue_policy.build_queue_dlq_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource |
391+
| [aws_sqs_queue_policy.build_queue_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource |
390392
| [random_string.random](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
393+
| [aws_iam_policy_document.deny_unsecure_transport](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
391394

392395
## Inputs
393396

394397
| Name | Description | Type | Default | Required |
395398
|------|-------------|------|---------|:--------:|
396399
| <a name="input_ami_filter"></a> [ami\_filter](#input\_ami\_filter) | List of maps used to create the AMI filter for the action runner AMI. By default amazon linux 2 is used. | `map(list(string))` | `null` | no |
397400
| <a name="input_ami_owners"></a> [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
401+
| <a name="input_aws_partition"></a> [aws\_partition](#input\_aws\_partition) | (optiona) partition in the arn namespace to use if not 'aws' | `string` | `"aws"` | no |
398402
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes |
399403
| <a name="input_block_device_mappings"></a> [block\_device\_mappings](#input\_block\_device\_mappings) | The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops` | `map(string)` | `{}` | no |
400404
| <a name="input_cloudwatch_config"></a> [cloudwatch\_config](#input\_cloudwatch\_config) | (optional) Replaces the module default cloudwatch log config. See https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html for details. | `string` | `null` | no |
@@ -428,6 +432,7 @@ In case the setup does not work as intended follow the trace of events:
428432
| <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 |
429433
| <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 |
430434
| <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 |
435+
| <a name="input_logging_kms_key_id"></a> [logging\_kms\_key\_id](#input\_logging\_kms\_key\_id) | Specifies the kms key id to encrypt the logs with | `string` | `null` | no |
431436
| <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 |
432437
| <a name="input_market_options"></a> [market\_options](#input\_market\_options) | DEPCRECATED: Replaced by `instance_target_capacity_type`. | `string` | `null` | no |
433438
| <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` | `null` | no |

images/linux-amzn2/github_agent.linux.pkr.hcl

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ variable "subnet_id" {
3131
default = null
3232
}
3333

34+
variable "associate_public_ip_address" {
35+
description = "If using a non-default VPC, there is no public IP address assigned to the EC2 instance. If you specified a public subnet, you probably want to set this to true. Otherwise the EC2 instance won't have access to the internet"
36+
type = string
37+
default = null
38+
}
39+
3440
variable "instance_type" {
3541
description = "The instance type Packer will use for the builder"
3642
type = string
@@ -66,15 +72,22 @@ variable "snapshot_tags" {
6672
default = {}
6773
}
6874

75+
variable "custom_shell_commands" {
76+
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
77+
type = list(string)
78+
default = []
79+
}
80+
6981
source "amazon-ebs" "githubrunner" {
70-
ami_name = "github-runner-amzn2-x86_64-${formatdate("YYYYMMDDhhmm", timestamp())}"
71-
instance_type = var.instance_type
72-
region = var.region
73-
security_group_id = var.security_group_id
74-
subnet_id = var.subnet_id
82+
ami_name = "github-runner-amzn2-x86_64-${formatdate("YYYYMMDDhhmm", timestamp())}"
83+
instance_type = var.instance_type
84+
region = var.region
85+
security_group_id = var.security_group_id
86+
subnet_id = var.subnet_id
87+
associate_public_ip_address = var.associate_public_ip_address
7588
source_ami_filter {
7689
filters = {
77-
name = "amzn2-ami-hvm-2.*-x86_64-ebs"
90+
name = "amzn2-ami-kernel-5.*-hvm-*-x86_64-gp2"
7891
root-device-type = "ebs"
7992
virtualization-type = "hvm"
8093
}
@@ -111,15 +124,15 @@ build {
111124
]
112125
provisioner "shell" {
113126
environment_vars = []
114-
inline = [
127+
inline = concat([
115128
"sudo yum update -y",
116129
"sudo yum install -y amazon-cloudwatch-agent curl jq git",
117130
"sudo amazon-linux-extras install docker",
118131
"sudo systemctl enable docker.service",
119132
"sudo systemctl enable containerd.service",
120133
"sudo service docker start",
121134
"sudo usermod -a -G docker ec2-user",
122-
]
135+
], var.custom_shell_commands)
123136
}
124137

125138
provisioner "file" {

images/ubuntu-focal/github_agent.ubuntu.pkr.hcl

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ variable "subnet_id" {
3131
default = null
3232
}
3333

34+
variable "associate_public_ip_address" {
35+
description = "If using a non-default VPC, there is no public IP address assigned to the EC2 instance. If you specified a public subnet, you probably want to set this to true. Otherwise the EC2 instance won't have access to the internet"
36+
type = string
37+
default = null
38+
}
39+
3440
variable "instance_type" {
3541
description = "The instance type Packer will use for the builder"
3642
type = string
@@ -66,12 +72,20 @@ variable "snapshot_tags" {
6672
default = {}
6773
}
6874

75+
variable "custom_shell_commands" {
76+
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
77+
type = list(string)
78+
default = []
79+
}
80+
6981
source "amazon-ebs" "githubrunner" {
70-
ami_name = "github-runner-ubuntu-focal-amd64-${formatdate("YYYYMMDDhhmm", timestamp())}"
71-
instance_type = var.instance_type
72-
region = var.region
73-
security_group_id = var.security_group_id
74-
subnet_id = var.subnet_id
82+
ami_name = "github-runner-ubuntu-focal-amd64-${formatdate("YYYYMMDDhhmm", timestamp())}"
83+
instance_type = var.instance_type
84+
region = var.region
85+
security_group_id = var.security_group_id
86+
subnet_id = var.subnet_id
87+
associate_public_ip_address = var.associate_public_ip_address
88+
7589
source_ami_filter {
7690
filters = {
7791
name = "*/ubuntu-focal-20.04-amd64-server-*"
@@ -112,7 +126,7 @@ build {
112126
environment_vars = [
113127
"DEBIAN_FRONTEND=noninteractive"
114128
]
115-
inline = [
129+
inline = concat([
116130
"sudo apt-get -y update",
117131
"sudo apt-get -y install ca-certificates curl gnupg lsb-release",
118132
"sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg",
@@ -128,7 +142,7 @@ build {
128142
"sudo curl -f https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip -o awscliv2.zip",
129143
"unzip awscliv2.zip",
130144
"sudo ./aws/install",
131-
]
145+
], var.custom_shell_commands)
132146
}
133147

134148
provisioner "file" {

images/windows-core-2019/github_agent.windows.pkr.hcl

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,25 @@ variable "ebs_delete_on_termination" {
2525
default = true
2626
}
2727

28+
variable "associate_public_ip_address" {
29+
description = "If using a non-default VPC, there is no public IP address assigned to the EC2 instance. If you specified a public subnet, you probably want to set this to true. Otherwise the EC2 instance won't have access to the internet"
30+
type = string
31+
default = null
32+
}
33+
34+
variable "custom_shell_commands" {
35+
description = "Additional commands to run on the EC2 instance, to customize the instance, like installing packages"
36+
type = list(string)
37+
default = []
38+
}
39+
2840
source "amazon-ebs" "githubrunner" {
29-
ami_name = "github-runner-windows-core-2019-${formatdate("YYYYMMDDhhmm", timestamp())}"
30-
communicator = "winrm"
31-
instance_type = "t3a.medium"
32-
region = var.region
41+
ami_name = "github-runner-windows-core-2019-${formatdate("YYYYMMDDhhmm", timestamp())}"
42+
communicator = "winrm"
43+
instance_type = "t3a.medium"
44+
region = var.region
45+
associate_public_ip_address = var.associate_public_ip_address
46+
3347
source_ami_filter {
3448
filters = {
3549
name = "Windows_Server-2019-English-Core-ContainersLatest-*"
@@ -70,8 +84,10 @@ build {
7084
}
7185

7286
provisioner "powershell" {
73-
inline = [templatefile("./windows-provisioner.ps1", {
74-
action_runner_url = var.action_runner_url
75-
})]
87+
inline = concat([
88+
templatefile("./windows-provisioner.ps1", {
89+
action_runner_url = var.action_runner_url
90+
})
91+
], var.custom_shell_commands)
7692
}
7793
}

main.tf

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,38 @@ resource "random_string" "random" {
1717
upper = false
1818
}
1919

20+
data "aws_iam_policy_document" "deny_unsecure_transport" {
21+
statement {
22+
sid = "DenyUnsecureTransport"
23+
24+
effect = "Deny"
25+
26+
principals {
27+
type = "AWS"
28+
identifiers = ["*"]
29+
}
30+
31+
actions = [
32+
"sqs:*"
33+
]
34+
35+
resources = [
36+
"*"
37+
]
38+
39+
condition {
40+
test = "Bool"
41+
variable = "aws:SecureTransport"
42+
values = ["false"]
43+
}
44+
}
45+
}
46+
47+
resource "aws_sqs_queue_policy" "build_queue_policy" {
48+
queue_url = aws_sqs_queue.queued_builds.id
49+
policy = data.aws_iam_policy_document.deny_unsecure_transport.json
50+
}
51+
2052
resource "aws_sqs_queue" "queued_builds" {
2153
name = "${var.environment}-queued-builds${var.fifo_build_queue ? ".fifo" : ""}"
2254
delay_seconds = var.delay_webhook_event
@@ -33,6 +65,13 @@ resource "aws_sqs_queue" "queued_builds" {
3365
tags = var.tags
3466
}
3567

68+
69+
resource "aws_sqs_queue_policy" "build_queue_dlq_policy" {
70+
count = var.redrive_build_queue.enabled ? 1 : 0
71+
queue_url = aws_sqs_queue.queued_builds.id
72+
policy = data.aws_iam_policy_document.deny_unsecure_transport.json
73+
}
74+
3675
resource "aws_sqs_queue" "queued_builds_dlq" {
3776
count = var.redrive_build_queue.enabled ? 1 : 0
3877
name = "${var.environment}-queued-builds_dead_letter"
@@ -67,6 +106,7 @@ module "webhook" {
67106
lambda_zip = var.webhook_lambda_zip
68107
lambda_timeout = var.webhook_lambda_timeout
69108
logging_retention_in_days = var.logging_retention_in_days
109+
logging_kms_key_id = var.logging_kms_key_id
70110

71111
# labels
72112
enable_workflow_job_labels_check = var.runner_enable_workflow_job_labels_check
@@ -83,11 +123,12 @@ module "webhook" {
83123
module "runners" {
84124
source = "./modules/runners"
85125

86-
aws_region = var.aws_region
87-
vpc_id = var.vpc_id
88-
subnet_ids = var.subnet_ids
89-
environment = var.environment
90-
tags = local.tags
126+
aws_region = var.aws_region
127+
aws_partition = var.aws_partition
128+
vpc_id = var.vpc_id
129+
subnet_ids = var.subnet_ids
130+
environment = var.environment
131+
tags = local.tags
91132

92133
s3_bucket_runner_binaries = module.runner_binaries.bucket
93134
s3_location_runner_binaries = local.s3_action_runner_url
@@ -132,6 +173,7 @@ module "runners" {
132173
lambda_subnet_ids = var.lambda_subnet_ids
133174
lambda_security_group_ids = var.lambda_security_group_ids
134175
logging_retention_in_days = var.logging_retention_in_days
176+
logging_kms_key_id = var.logging_kms_key_id
135177
enable_cloudwatch_agent = var.enable_cloudwatch_agent
136178
cloudwatch_config = var.cloudwatch_config
137179
runner_log_files = var.runner_log_files
@@ -187,6 +229,7 @@ module "runner_binaries" {
187229
lambda_zip = var.runner_binaries_syncer_lambda_zip
188230
lambda_timeout = var.runner_binaries_syncer_lambda_timeout
189231
logging_retention_in_days = var.logging_retention_in_days
232+
logging_kms_key_id = var.logging_kms_key_id
190233

191234
server_side_encryption_configuration = var.runner_binaries_s3_sse_configuration
192235

modules/runner-binaries-syncer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ No modules.
8787
| <a name="input_lambda_zip"></a> [lambda\_zip](#input\_lambda\_zip) | File location of the lambda zip file. | `string` | `null` | no |
8888
| <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 |
8989
| <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 |
90+
| <a name="input_logging_kms_key_id"></a> [logging\_kms\_key\_id](#input\_logging\_kms\_key\_id) | Specifies the kms key id to encrypt the logs with | `string` | `null` | no |
9091
| <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 |
9192
| <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 |
9293
| <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 |

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
"devDependencies": {
1818
"@octokit/rest": "^18.12.0",
1919
"@trivago/prettier-plugin-sort-imports": "^3.2.0",
20-
"@types/jest": "^27.4.0",
20+
"@types/jest": "^27.4.1",
2121
"@types/node": "^17.0.21",
2222
"@types/request": "^2.48.8",
2323
"@typescript-eslint/eslint-plugin": "^4.33.0",
2424
"@typescript-eslint/parser": "^4.33.0",
2525
"@vercel/ncc": "^0.33.3",
26-
"aws-sdk": "^2.1081.0",
26+
"aws-sdk": "^2.1090.0",
2727
"eslint": "^7.32.0",
2828
"eslint-plugin-prettier": "4.0.0",
2929
"jest": "^27.5.1",
3030
"jest-mock": "^27.5.1",
3131
"prettier": "2.5.1",
3232
"ts-jest": "^27.1.3",
3333
"ts-node-dev": "^1.1.6",
34-
"typescript": "^4.5.5"
34+
"typescript": "^4.6.2"
3535
},
3636
"dependencies": {
3737
"axios": "^0.26.0",

0 commit comments

Comments
 (0)