Skip to content

Commit 3b12298

Browse files
authored
feat: Enable ebs_optimized setting for node_groups (#1459)
1 parent 9022013 commit 3b12298

File tree

8 files changed

+15
-2
lines changed

8 files changed

+15
-2
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: git://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.48.0
3+
rev: v1.50.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_docs

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraf
266266
| <a name="input_subnets"></a> [subnets](#input\_subnets) | A list of subnets to place the EKS cluster and workers within. | `list(string)` | n/a | yes |
267267
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources. Tags added to launch configuration or templates override these values for ASG Tags only. | `map(string)` | `{}` | no |
268268
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | VPC where the cluster and workers will be deployed. | `string` | n/a | yes |
269-
| <a name="input_wait_for_cluster_timeout"></a> [wait\_for\_cluster\_timeout](#wait\_for\_cluster\_timeout) | Allows for a configurable timeout (in seconds) when waiting for a cluster to come up | `number` | `300` | no |
269+
| <a name="input_wait_for_cluster_timeout"></a> [wait\_for\_cluster\_timeout](#input\_wait\_for\_cluster\_timeout) | A timeout (in seconds) to wait for cluster to be available. | `number` | `300` | no |
270270
| <a name="input_worker_additional_security_group_ids"></a> [worker\_additional\_security\_group\_ids](#input\_worker\_additional\_security\_group\_ids) | A list of additional security group ids to attach to worker instances | `list(string)` | `[]` | no |
271271
| <a name="input_worker_ami_name_filter"></a> [worker\_ami\_name\_filter](#input\_worker\_ami\_name\_filter) | Name filter for AWS EKS worker AMI. If not provided, the latest official AMI for the specified 'cluster\_version' is used. | `string` | `""` | no |
272272
| <a name="input_worker_ami_name_filter_windows"></a> [worker\_ami\_name\_filter\_windows](#input\_worker\_ami\_name\_filter\_windows) | Name filter for AWS EKS Windows worker AMI. If not provided, the latest official AMI for the specified 'cluster\_version' is used. | `string` | `""` | no |

examples/launch_templates/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module "eks" {
5959
instance_type = "t3.medium"
6060
asg_desired_capacity = 1
6161
public_ip = true
62+
ebs_optimized = true
6263
},
6364
{
6465
name = "worker-group-3"

modules/node_groups/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ The role ARN specified in `var.default_iam_role_arn` will be used by default. In
2525
| desired\_capacity | Desired number of workers | number | `var.workers_group_defaults[asg_desired_capacity]` |
2626
| disk\_size | Workers' disk size | number | Provider default behavior |
2727
| disk\_type | Workers' disk type. Require `create_launch_template` to be `true`| number | `gp3` |
28+
| ebs\_optimized | Enables/disables EBS optimization. Require `create_launch_template` to be `true` | bool | `true` if defined `instance\_types` are not present in `var.ebs\_optimized\_not\_supported` |
2829
| enable_monitoring | Enables/disables detailed monitoring. Require `create_launch_template` to be `true`| bool | `true` |
2930
| eni_delete | Delete the Elastic Network Interface (ENI) on termination (if set to false you will have to manually delete before destroying) | bool | `true` |
3031
| force\_update\_version | Force version update if existing pods are unable to be drained due to a pod disruption budget issue. | bool | Provider default behavior |
@@ -80,6 +81,7 @@ No modules.
8081
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of parent cluster | `string` | n/a | yes |
8182
| <a name="input_create_eks"></a> [create\_eks](#input\_create\_eks) | Controls if EKS resources should be created (it affects almost all resources) | `bool` | `true` | no |
8283
| <a name="input_default_iam_role_arn"></a> [default\_iam\_role\_arn](#input\_default\_iam\_role\_arn) | ARN of the default IAM worker role to use if one is not specified in `var.node_groups` or `var.node_groups_defaults` | `string` | n/a | yes |
84+
| <a name="input_ebs_optimized_not_supported"></a> [ebs\_optimized\_not\_supported](#input\_ebs\_optimized\_not\_supported) | List of instance types that do not support EBS optimization | `list(string)` | `[]` | no |
8385
| <a name="input_ng_depends_on"></a> [ng\_depends\_on](#input\_ng\_depends\_on) | List of references to other resources this submodule depends on | `any` | `null` | no |
8486
| <a name="input_node_groups"></a> [node\_groups](#input\_node\_groups) | Map of maps of `eks_node_groups` to create. See "`node_groups` and `node_groups_defaults` keys" section in README.md for more details | `any` | `{}` | no |
8587
| <a name="input_node_groups_defaults"></a> [node\_groups\_defaults](#input\_node\_groups\_defaults) | map of maps of node groups to create. See "`node_groups` and `node_groups_defaults` keys" section in README.md for more details | `any` | n/a | yes |

modules/node_groups/launch_template.tf

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ resource "aws_launch_template" "workers" {
3939
}
4040
}
4141

42+
ebs_optimized = lookup(each.value, "ebs_optimized", !contains(var.ebs_optimized_not_supported, element(each.value.instance_types, 0)))
43+
4244
instance_type = each.value["set_instance_types_on_lt"] ? element(each.value.instance_types, 0) : null
4345

4446
monitoring {

modules/node_groups/locals.tf

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ locals {
2222
pre_userdata = var.workers_group_defaults["pre_userdata"]
2323
additional_security_group_ids = var.workers_group_defaults["additional_security_group_ids"]
2424
taints = []
25+
ebs_optimized = null
2526
},
2627
var.node_groups_defaults,
2728
v,

modules/node_groups/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ variable "ng_depends_on" {
5454
type = any
5555
default = null
5656
}
57+
58+
variable "ebs_optimized_not_supported" {
59+
description = "List of instance types that do not support EBS optimization"
60+
type = list(string)
61+
default = []
62+
}

node_groups.tf

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module "node_groups" {
99
tags = var.tags
1010
node_groups_defaults = var.node_groups_defaults
1111
node_groups = var.node_groups
12+
ebs_optimized_not_supported = local.ebs_optimized_not_supported
1213

1314
# Hack to ensure ordering of resource creation.
1415
# This is a homemade `depends_on` https://discuss.hashicorp.com/t/tips-howto-implement-module-depends-on-emulation/2305/2

0 commit comments

Comments
 (0)