Skip to content

Commit

Permalink
feat: Enable ebs_optimized setting for node_groups (#1459)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzabo authored Aug 25, 2021
1 parent 9022013 commit 3b12298
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.48.0
rev: v1.50.0
hooks:
- id: terraform_fmt
- id: terraform_docs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraf
| <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 |
| <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 |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | VPC where the cluster and workers will be deployed. | `string` | n/a | yes |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
1 change: 1 addition & 0 deletions examples/launch_templates/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module "eks" {
instance_type = "t3.medium"
asg_desired_capacity = 1
public_ip = true
ebs_optimized = true
},
{
name = "worker-group-3"
Expand Down
2 changes: 2 additions & 0 deletions modules/node_groups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The role ARN specified in `var.default_iam_role_arn` will be used by default. In
| desired\_capacity | Desired number of workers | number | `var.workers_group_defaults[asg_desired_capacity]` |
| disk\_size | Workers' disk size | number | Provider default behavior |
| disk\_type | Workers' disk type. Require `create_launch_template` to be `true`| number | `gp3` |
| 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` |
| enable_monitoring | Enables/disables detailed monitoring. Require `create_launch_template` to be `true`| bool | `true` |
| eni_delete | Delete the Elastic Network Interface (ENI) on termination (if set to false you will have to manually delete before destroying) | bool | `true` |
| 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 |
Expand Down Expand Up @@ -80,6 +81,7 @@ No modules.
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | Name of parent cluster | `string` | n/a | yes |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
Expand Down
2 changes: 2 additions & 0 deletions modules/node_groups/launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ resource "aws_launch_template" "workers" {
}
}

ebs_optimized = lookup(each.value, "ebs_optimized", !contains(var.ebs_optimized_not_supported, element(each.value.instance_types, 0)))

instance_type = each.value["set_instance_types_on_lt"] ? element(each.value.instance_types, 0) : null

monitoring {
Expand Down
1 change: 1 addition & 0 deletions modules/node_groups/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ locals {
pre_userdata = var.workers_group_defaults["pre_userdata"]
additional_security_group_ids = var.workers_group_defaults["additional_security_group_ids"]
taints = []
ebs_optimized = null
},
var.node_groups_defaults,
v,
Expand Down
6 changes: 6 additions & 0 deletions modules/node_groups/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ variable "ng_depends_on" {
type = any
default = null
}

variable "ebs_optimized_not_supported" {
description = "List of instance types that do not support EBS optimization"
type = list(string)
default = []
}
1 change: 1 addition & 0 deletions node_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module "node_groups" {
tags = var.tags
node_groups_defaults = var.node_groups_defaults
node_groups = var.node_groups
ebs_optimized_not_supported = local.ebs_optimized_not_supported

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

0 comments on commit 3b12298

Please sign in to comment.