Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add option to set instance_type on the launch template #2677

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions examples/eks_managed_node_group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ module "eks" {
instance_types = ["t4g.medium"]
}

# Set the instance type in the launch template
lt_instance_type = {
instance_type = "t3.medium"
instance_types = null # Reset the value from eks_managed_node_group_defaults to prevent conflict.
}

# Complete
complete = {
name = "complete-eks-mng"
Expand Down Expand Up @@ -269,17 +275,17 @@ module "eks" {
min_size = 2
max_size = "-1" # Retains current max size
desired_size = 2
start_time = "2023-03-05T00:00:00Z"
end_time = "2024-03-05T00:00:00Z"
start_time = "2024-03-05T00:00:00Z"
end_time = "2025-03-05T00:00:00Z"
timezone = "Etc/GMT+0"
recurrence = "0 0 * * *"
},
scale-down = {
min_size = 0
max_size = "-1" # Retains current max size
desired_size = 0
start_time = "2023-03-05T12:00:00Z"
end_time = "2024-03-05T12:00:00Z"
start_time = "2024-03-05T12:00:00Z"
end_time = "2025-03-05T12:00:00Z"
timezone = "Etc/GMT+0"
recurrence = "0 12 * * *"
}
Expand Down
3 changes: 2 additions & 1 deletion modules/eks-managed-node-group/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ module "eks_managed_node_group" {
| <a name="input_iam_role_tags"></a> [iam\_role\_tags](#input\_iam\_role\_tags) | A map of additional tags to add to the IAM role created | `map(string)` | `{}` | no |
| <a name="input_iam_role_use_name_prefix"></a> [iam\_role\_use\_name\_prefix](#input\_iam\_role\_use\_name\_prefix) | Determines whether the IAM role name (`iam_role_name`) is used as a prefix | `bool` | `true` | no |
| <a name="input_instance_market_options"></a> [instance\_market\_options](#input\_instance\_market\_options) | The market (purchasing) option for the instance | `any` | `{}` | no |
| <a name="input_instance_types"></a> [instance\_types](#input\_instance\_types) | Set of instance types associated with the EKS Node Group. Defaults to `["t3.medium"]` | `list(string)` | `null` | no |
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Set of instance type associated with the Launch Template. Conflicts with `instance_types` | `string` | `null` | no |
| <a name="input_instance_types"></a> [instance\_types](#input\_instance\_types) | Set of instance types associated with the EKS Node Group. Defaults to `["t3.medium"]`. Conflicts with `instance_types` | `list(string)` | `null` | no |
| <a name="input_kernel_id"></a> [kernel\_id](#input\_kernel\_id) | The kernel ID | `string` | `null` | no |
| <a name="input_key_name"></a> [key\_name](#input\_key\_name) | The key name that should be used for the instance(s) | `string` | `null` | no |
| <a name="input_labels"></a> [labels](#input\_labels) | Key-value map of Kubernetes labels. Only labels that are applied with the EKS API are managed by this argument. Other Kubernetes labels applied to the EKS Node Group will not be managed | `map(string)` | `null` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/eks-managed-node-group/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ resource "aws_launch_template" "this" {
}
}

instance_type = var.instance_type

# # Set on node group instead
# instance_type = var.launch_template_instance_type
kernel_id = var.kernel_id
Expand Down
8 changes: 7 additions & 1 deletion modules/eks-managed-node-group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ variable "instance_market_options" {
default = {}
}

variable "instance_type" {
description = "Set of instance type associated with the Launch Template. Conflicts with `instance_types`"
type = string
default = null
}

variable "maintenance_options" {
description = "The maintenance options for the instance"
type = any
Expand Down Expand Up @@ -351,7 +357,7 @@ variable "force_update_version" {
}

variable "instance_types" {
description = "Set of instance types associated with the EKS Node Group. Defaults to `[\"t3.medium\"]`"
description = "Set of instance types associated with the EKS Node Group. Defaults to `[\"t3.medium\"]`. Conflicts with `instance_types`"
type = list(string)
default = null
}
Expand Down
1 change: 1 addition & 0 deletions node_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ module "eks_managed_node_group" {
elastic_inference_accelerator = try(each.value.elastic_inference_accelerator, var.eks_managed_node_group_defaults.elastic_inference_accelerator, {})
enclave_options = try(each.value.enclave_options, var.eks_managed_node_group_defaults.enclave_options, {})
instance_market_options = try(each.value.instance_market_options, var.eks_managed_node_group_defaults.instance_market_options, {})
instance_type = try(each.value.instance_type, var.eks_managed_node_group_defaults.instance_type, null)
license_specifications = try(each.value.license_specifications, var.eks_managed_node_group_defaults.license_specifications, {})
metadata_options = try(each.value.metadata_options, var.eks_managed_node_group_defaults.metadata_options, local.metadata_options)
enable_monitoring = try(each.value.enable_monitoring, var.eks_managed_node_group_defaults.enable_monitoring, true)
Expand Down