Skip to content

Commit 80104c3

Browse files
committed
Merge branch 'toots-develop' into develop
2 parents 000c86e + 96c095d commit 80104c3

File tree

8 files changed

+102
-45
lines changed

8 files changed

+102
-45
lines changed

README.md

+63-44
Large diffs are not rendered by default.

examples/default/main.tf

+3
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ module "runners" {
4545

4646
# disable KMS and encryption
4747
# encrypt_secrets = false
48+
49+
# Let the module manage the service linked role
50+
# create_service_linked_role_spot = true
4851
}

main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ module "runners" {
100100
userdata_template = var.userdata_template
101101
userdata_pre_install = var.userdata_pre_install
102102
userdata_post_install = var.userdata_post_install
103+
104+
create_service_linked_role_spot = var.create_service_linked_role_spot
103105
}
104106

105107
module "runner_binaries" {

modules/runners/README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ No requirements.
6565
| ami\_filter | List of maps used to create the AMI filter for the action runner AMI. | `map(list(string))` | <pre>{<br> "name": [<br> "amzn2-ami-hvm-2.*-x86_64-ebs"<br> ]<br>}</pre> | no |
6666
| ami\_owners | The list of owners used to select the AMI of action runner instances. | `list(string)` | <pre>[<br> "amazon"<br>]</pre> | no |
6767
| aws\_region | AWS region. | `string` | n/a | yes |
68-
| block\_device\_mappings | The EC2 instance block device configuration. Takes the following keys: `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops` | `map(string)` | `{}` | no |
68+
| 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 |
69+
| create\_service\_linked\_role\_spot | (optional) create the serviced linked role for spot instances that is required by the scale-up lambda. | `bool` | `false` | no |
6970
| enable\_organization\_runners | n/a | `bool` | n/a | yes |
71+
| enable\_ssm\_on\_runners | Enable to allow access the runner instances for debugging purposes via SSM. Note that this adds additional permissions to the runner instances. | `bool` | n/a | yes |
7072
| encryption | KMS key to encrypted lambda environment secrets. Either provide a key and `encrypt` set to `true`. Or set the key to `null` and encrypt to `false`. | <pre>object({<br> kms_key_id = string<br> encrypt = bool<br> })</pre> | n/a | yes |
7173
| environment | A name that identifies the environment, used as prefix and for tagging. | `string` | n/a | yes |
7274
| github\_app | GitHub app parameters, see your github app. Ensure the key is base64 encoded. | <pre>object({<br> key_base64 = string<br> id = string<br> client_id = string<br> client_secret = string<br> })</pre> | n/a | yes |
7375
| idle\_config | List of time period that can be defined as cron expression to keep a minimum amount of runners active instead of scaling down to 0. By defining this list you can ensure that in time periods that match the cron expression within 5 seconds a runner is kept idle. | <pre>list(object({<br> cron = string<br> timeZone = string<br> idleCount = number<br> }))</pre> | `[]` | no |
7476
| 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 |
7577
| instance\_type | Default instance type for the action runner. | `string` | `"m5.large"` | no |
78+
| lambda\_s3\_bucket | S3 bucket from which to specify lambda functions. This is an alternative to providing local files directly. | `any` | `null` | no |
7679
| lambda\_timeout\_scale\_down | Time out for the scale down lambda in seconds. | `number` | `60` | no |
7780
| lambda\_timeout\_scale\_up | Time out for the scale up lambda in seconds. | `number` | `60` | no |
7881
| lambda\_zip | File location of the lambda zip file. | `string` | `null` | no |
@@ -85,6 +88,8 @@ No requirements.
8588
| runner\_architecture | The platform architecture of the runner instance\_type. | `string` | `"x64"` | no |
8689
| runner\_as\_root | Run the action runner under the root user. | `bool` | `false` | no |
8790
| runner\_extra\_labels | Extra labels for the runners (GitHub). Separate each label by a comma | `string` | `""` | no |
91+
| runners\_lambda\_s3\_key | S3 key for runners lambda function. Required if using S3 bucket to specify lambdas. | `any` | `null` | no |
92+
| runners\_lambda\_s3\_object\_version | S3 object version for runners lambda function. Useful if S3 versioning is enabled on source bucket. | `any` | `null` | no |
8893
| runners\_maximum\_count | The maximum number of runners that will be created. | `number` | `3` | no |
8994
| s3\_bucket\_runner\_binaries | n/a | <pre>object({<br> arn = string<br> })</pre> | n/a | yes |
9095
| s3\_location\_runner\_binaries | S3 location of runner distribution. | `string` | n/a | yes |
@@ -94,6 +99,7 @@ No requirements.
9499
| tags | Map of tags that will be added to created resources. By default resources will be tagged with name and environment. | `map(string)` | `{}` | no |
95100
| userdata\_post\_install | User-data script snippet to insert after GitHub acton runner install | `string` | `""` | no |
96101
| userdata\_pre\_install | User-data script snippet to insert before GitHub acton runner install | `string` | `""` | no |
102+
| 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 |
97103
| vpc\_id | The VPC for the security groups. | `string` | n/a | yes |
98104

99105
## Outputs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Effect": "Allow",
6+
"Action": "iam:CreateServiceLinkedRole",
7+
"Resource": "arn:aws:iam::*:role/aws-service-role/*"
8+
}
9+
]
10+
}

modules/runners/scale-up.tf

+7
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,10 @@ resource "aws_iam_role_policy" "scale_up_logging" {
8888
log_group_arn = aws_cloudwatch_log_group.scale_up.arn
8989
})
9090
}
91+
92+
resource "aws_iam_role_policy" "service_linked_role" {
93+
count = var.create_service_linked_role_spot ? 1 : 0
94+
name = "${var.environment}-service_linked_role"
95+
role = aws_iam_role.scale_up.name
96+
policy = templatefile("${path.module}/policies/service-linked-role-create-policy.json", {})
97+
}

modules/runners/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,8 @@ variable "runners_lambda_s3_object_version" {
233233
default = null
234234
}
235235

236+
variable "create_service_linked_role_spot" {
237+
description = "(optional) create the serviced linked role for spot instances that is required by the scale-up lambda."
238+
type = bool
239+
default = false
240+
}

variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,8 @@ variable "runners_lambda_s3_object_version" {
251251
default = null
252252
}
253253

254+
variable "create_service_linked_role_spot" {
255+
description = "(optional) create the serviced linked role for spot instances that is required by the scale-up lambda."
256+
type = bool
257+
default = false
258+
}

0 commit comments

Comments
 (0)