From 7cd2524ed0dba38849ac1e0e477cffda24bf21a3 Mon Sep 17 00:00:00 2001 From: Niek Palm Date: Mon, 25 Jul 2022 19:33:38 +0200 Subject: [PATCH] feat: Add options extra option to ebs block device mapping (#2052) * feat: Add options `throughput`, `kms_key_id`, `snapshot_id to ebs block device mapping * fix examples --- README.md | 2 +- examples/ubuntu/main.tf | 3 +++ modules/runners/README.md | 2 +- modules/runners/main.tf | 7 +++++-- modules/runners/variables.tf | 20 +++++++++++++------- variables.tf | 20 +++++++++++++------- 6 files changed, 36 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5f02c9b9cc..2013f036a6 100644 --- a/README.md +++ b/README.md @@ -398,7 +398,7 @@ In case the setup does not work as intended follow the trace of events: | [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` |
[
"amazon"
]
| no | | [aws\_partition](#input\_aws\_partition) | (optiona) partition in the arn namespace to use if not 'aws' | `string` | `"aws"` | no | | [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes | -| [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` |
list(object({
device_name = string
delete_on_termination = bool
volume_type = string
volume_size = number
encrypted = bool
iops = number
}))
|
[
{
"delete_on_termination": true,
"device_name": "/dev/xvda",
"encrypted": true,
"iops": null,
"volume_size": 30,
"volume_type": "gp3"
}
]
| no | +| [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`, `throughput`, `kms_key_id`, `snapshot_id`. |
list(object({
delete_on_termination = bool
device_name = string
encrypted = bool
iops = number
kms_key_id = string
snapshot_id = string
throughput = number
volume_size = number
volume_type = string
}))
|
[
{
"delete_on_termination": true,
"device_name": "/dev/xvda",
"encrypted": true,
"iops": null,
"kms_key_id": null,
"snapshot_id": null,
"throughput": null,
"volume_size": 30,
"volume_type": "gp3"
}
]
| no | | [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 | | [create\_service\_linked\_role\_spot](#input\_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 | | [delay\_webhook\_event](#input\_delay\_webhook\_event) | The number of seconds the event accepted by the webhook is invisible on the queue before the scale up lambda will receive the event. | `number` | `30` | no | diff --git a/examples/ubuntu/main.tf b/examples/ubuntu/main.tf index cad0e1ca59..e6390361b7 100644 --- a/examples/ubuntu/main.tf +++ b/examples/ubuntu/main.tf @@ -64,6 +64,9 @@ module "runners" { volume_size = 30 encrypted = true iops = null + throughput = null + kms_key_id = null + snapshot_id = null }] runner_log_files = [ diff --git a/modules/runners/README.md b/modules/runners/README.md index 719fbbee1c..7acfb4317a 100644 --- a/modules/runners/README.md +++ b/modules/runners/README.md @@ -117,7 +117,7 @@ yarn run dist | [ami\_owners](#input\_ami\_owners) | The list of owners used to select the AMI of action runner instances. | `list(string)` |
[
"amazon"
]
| no | | [aws\_partition](#input\_aws\_partition) | (optional) partition for the base arn if not 'aws' | `string` | `"aws"` | no | | [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes | -| [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` |
list(object({
device_name = string
delete_on_termination = bool
volume_type = string
volume_size = number
encrypted = bool
iops = number
}))
|
[
{
"delete_on_termination": true,
"device_name": "/dev/xvda",
"encrypted": true,
"iops": null,
"volume_size": 30,
"volume_type": "gp3"
}
]
| no | +| [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`, `throughput`, `kms_key_id`, `snapshot_id`. |
list(object({
delete_on_termination = bool
device_name = string
encrypted = bool
iops = number
kms_key_id = string
snapshot_id = string
throughput = number
volume_size = number
volume_type = string
}))
|
[
{
"delete_on_termination": true,
"device_name": "/dev/xvda",
"encrypted": true,
"iops": null,
"kms_key_id": null,
"snapshot_id": null,
"throughput": null,
"volume_size": 30,
"volume_type": "gp3"
}
]
| no | | [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 | | [create\_service\_linked\_role\_spot](#input\_create\_service\_linked\_role\_spot) | (optional) create the service linked role for spot instances that is required by the scale-up lambda. | `bool` | `false` | no | | [disable\_runner\_autoupdate](#input\_disable\_runner\_autoupdate) | Disable the auto update of the github runner agent. Be-aware there is a grace period of 30 days, see also the [GitHub article](https://github.blog/changelog/2022-02-01-github-actions-self-hosted-runners-can-now-disable-automatic-updates/) | `bool` | `false` | no | diff --git a/modules/runners/main.tf b/modules/runners/main.tf index a3d009c28a..cec1d086c7 100644 --- a/modules/runners/main.tf +++ b/modules/runners/main.tf @@ -63,10 +63,13 @@ resource "aws_launch_template" "runner" { ebs { delete_on_termination = block_device_mappings.value.delete_on_termination - volume_type = block_device_mappings.value.volume_type - volume_size = block_device_mappings.value.volume_size encrypted = block_device_mappings.value.encrypted iops = block_device_mappings.value.iops + kms_key_id = block_device_mappings.value.kms_key_id + snapshot_id = block_device_mappings.value.snapshot_id + throughput = block_device_mappings.value.throughput + volume_size = block_device_mappings.value.volume_size + volume_type = block_device_mappings.value.volume_type } } } diff --git a/modules/runners/variables.tf b/modules/runners/variables.tf index ba6954308f..ed82d4cbf3 100644 --- a/modules/runners/variables.tf +++ b/modules/runners/variables.tf @@ -58,22 +58,28 @@ variable "s3_location_runner_binaries" { } variable "block_device_mappings" { - description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`" + description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`, `throughput`, `kms_key_id`, `snapshot_id`." type = list(object({ - device_name = string delete_on_termination = bool - volume_type = string - volume_size = number + device_name = string encrypted = bool iops = number + kms_key_id = string + snapshot_id = string + throughput = number + volume_size = number + volume_type = string })) default = [{ - device_name = "/dev/xvda" delete_on_termination = true - volume_type = "gp3" - volume_size = 30 + device_name = "/dev/xvda" encrypted = true iops = null + kms_key_id = null + snapshot_id = null + throughput = null + volume_size = 30 + volume_type = "gp3" }] } diff --git a/variables.tf b/variables.tf index 6ee5653b2b..fc54081b92 100644 --- a/variables.tf +++ b/variables.tf @@ -242,22 +242,28 @@ variable "runner_allow_prerelease_binaries" { } variable "block_device_mappings" { - description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`" + description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`, `throughput`, `kms_key_id`, `snapshot_id`." type = list(object({ - device_name = string delete_on_termination = bool - volume_type = string - volume_size = number + device_name = string encrypted = bool iops = number + kms_key_id = string + snapshot_id = string + throughput = number + volume_size = number + volume_type = string })) default = [{ - device_name = "/dev/xvda" delete_on_termination = true - volume_type = "gp3" - volume_size = 30 + device_name = "/dev/xvda" encrypted = true iops = null + kms_key_id = null + snapshot_id = null + throughput = null + volume_size = 30 + volume_type = "gp3" }] }