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

Commit 7a2ca0d

Browse files
authored
feat: Add possibility to create multiple ebs (#1845)
* add possibility to create multiple ebs * keep the ability to not map any device * add type constraint on block_device_mappings * modify block_device_mappings of ubuntu example based on type constraints
1 parent 819fa4f commit 7a2ca0d

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ In case the setup does not work as intended follow the trace of events:
401401
| <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 |
402402
| <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 |
403403
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes |
404-
| <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 |
404+
| <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` | <pre>list(object({<br> device_name = string<br> delete_on_termination = bool<br> volume_type = string<br> volume_size = number<br> encrypted = bool<br> iops = number<br> }))</pre> | `[]` | no |
405405
| <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 |
406406
| <a name="input_create_service_linked_role_spot"></a> [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 |
407407
| <a name="input_delay_webhook_event"></a> [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 for: examples/ubuntu/main.tf

+8-3
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ module "runners" {
5656
# ami_owners = [data.aws_caller_identity.current.account_id]
5757

5858

59-
block_device_mappings = {
59+
block_device_mappings = [{
6060
# Set the block device name for Ubuntu root device
61-
device_name = "/dev/sda1"
62-
}
61+
device_name = "/dev/sda1"
62+
delete_on_termination = true
63+
volume_type = "gp3"
64+
volume_size = 30
65+
encrypted = true
66+
iops = null
67+
}]
6368

6469
runner_log_files = [
6570
{

Diff for: modules/runners/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ yarn run dist
117117
| <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 |
118118
| <a name="input_aws_partition"></a> [aws\_partition](#input\_aws\_partition) | (optional) partition for the base arn if not 'aws' | `string` | `"aws"` | no |
119119
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region. | `string` | n/a | yes |
120-
| <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 |
120+
| <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` | <pre>list(object({<br> device_name = string<br> delete_on_termination = bool<br> volume_type = string<br> volume_size = number<br> encrypted = bool<br> iops = number<br> }))</pre> | `[]` | no |
121121
| <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 |
122122
| <a name="input_create_service_linked_role_spot"></a> [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 |
123123
| <a name="input_disable_runner_autoupdate"></a> [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 for: modules/runners/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ resource "aws_launch_template" "runner" {
5757
name = "${var.environment}-action-runner"
5858

5959
dynamic "block_device_mappings" {
60-
for_each = var.block_device_mappings != null ? [var.block_device_mappings] : []
60+
for_each = var.block_device_mappings != null ? var.block_device_mappings : []
6161
content {
6262
device_name = lookup(block_device_mappings.value, "device_name", "/dev/xvda")
6363

Diff for: modules/runners/variables.tf

+9-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,15 @@ variable "s3_location_runner_binaries" {
4747

4848
variable "block_device_mappings" {
4949
description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`"
50-
type = map(string)
51-
default = {}
50+
type = list(object({
51+
device_name = string
52+
delete_on_termination = bool
53+
volume_type = string
54+
volume_size = number
55+
encrypted = bool
56+
iops = number
57+
}))
58+
default = []
5259
}
5360

5461
variable "market_options" {

Diff for: variables.tf

+9-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,15 @@ variable "runner_allow_prerelease_binaries" {
225225

226226
variable "block_device_mappings" {
227227
description = "The EC2 instance block device configuration. Takes the following keys: `device_name`, `delete_on_termination`, `volume_type`, `volume_size`, `encrypted`, `iops`"
228-
type = map(string)
229-
default = {}
228+
type = list(object({
229+
device_name = string
230+
delete_on_termination = bool
231+
volume_type = string
232+
volume_size = number
233+
encrypted = bool
234+
iops = number
235+
}))
236+
default = []
230237
}
231238

232239
variable "ami_filter" {

0 commit comments

Comments
 (0)