diff --git a/modules/eks-managed-node-group/README.md b/modules/eks-managed-node-group/README.md index 00dc6f71f2..6c923884f9 100644 --- a/modules/eks-managed-node-group/README.md +++ b/modules/eks-managed-node-group/README.md @@ -169,7 +169,7 @@ module "eks_managed_node_group" { | [metadata\_options](#input\_metadata\_options) | Customize the metadata options for the instance |
object({
http_endpoint = optional(string, "enabled")
http_protocol_ipv6 = optional(string)
http_put_response_hop_limit = optional(number, 1)
http_tokens = optional(string, "required")
instance_metadata_tags = optional(string)
})
|
{
"http_endpoint": "enabled",
"http_put_response_hop_limit": 1,
"http_tokens": "required"
}
| no | | [min\_size](#input\_min\_size) | Minimum number of instances/nodes | `number` | `1` | no | | [name](#input\_name) | Name of the EKS managed node group | `string` | `""` | no | -| [network\_interfaces](#input\_network\_interfaces) | Customize network interfaces to be attached at instance boot time |
list(object({
associate_carrier_ip_address = optional(bool)
associate_public_ip_address = optional(bool)
connection_tracking_specification = optional(object({
tcp_established_timeout = optional(number)
udp_stream_timeout = optional(number)
udp_timeout = optional(number)
}))
delete_on_termination = optional(bool)
description = optional(string)
device_index = optional(number)
ena_srd_specification = optional(object({
ena_srd_enabled = optional(bool)
ena_srd_udp_specification = optional(object({
ena_srd_udp_enabled = optional(bool)
}))
}))
interface_type = optional(string)
ipv4_address_count = optional(number)
ipv4_addresses = optional(list(string))
ipv4_prefix_count = optional(number)
ipv4_prefixes = optional(list(string))
ipv6_address_count = optional(number)
ipv6_addresses = optional(list(string))
ipv6_prefix_count = optional(number)
ipv6_prefixes = optional(list(string))
network_card_index = optional(number)
network_interface_id = optional(string)
primary_ipv6 = optional(bool)
private_ip_address = optional(string)
security_groups = optional(list(string), [])
subnet_id = optional(string)
}))
| `[]` | no | +| [network\_interfaces](#input\_network\_interfaces) | Customize network interfaces to be attached at instance boot time |
list(object({
associate_carrier_ip_address = optional(bool)
associate_public_ip_address = optional(bool)
connection_tracking_specification = optional(object({
tcp_established_timeout = optional(number)
udp_stream_timeout = optional(number)
udp_timeout = optional(number)
}))
delete_on_termination = optional(bool)
description = optional(string)
device_index = optional(number)
ena_srd_specification = optional(object({
ena_srd_enabled = optional(bool)
ena_srd_udp_specification = optional(object({
ena_srd_udp_enabled = optional(bool)
}))
}))
interface_type = optional(string)
ipv4_address_count = optional(number)
ipv4_addresses = optional(list(string))
ipv4_prefix_count = optional(number)
ipv4_prefixes = optional(list(string))
ipv6_address_count = optional(number)
ipv6_addresses = optional(list(string))
ipv6_prefix_count = optional(number)
ipv6_prefixes = optional(list(string))
network_card_index = optional(number)
network_interface_id = optional(string)
primary_ipv6 = optional(bool)
private_ip_address = optional(string)
security_groups = optional(list(string), [])
}))
| `[]` | no | | [node\_repair\_config](#input\_node\_repair\_config) | The node auto repair configuration for the node group |
object({
enabled = optional(bool, true)
})
| `null` | no | | [partition](#input\_partition) | The AWS partition - pass through value to reduce number of GET requests from data sources | `string` | `""` | no | | [placement](#input\_placement) | The placement of the instance |
object({
affinity = optional(string)
availability_zone = optional(string)
group_name = optional(string)
host_id = optional(string)
host_resource_group_arn = optional(string)
partition_number = optional(number)
spread_domain = optional(string)
tenancy = optional(string)
})
| `null` | no | diff --git a/modules/eks-managed-node-group/main.tf b/modules/eks-managed-node-group/main.tf index 1e8b8f1508..85d75efece 100644 --- a/modules/eks-managed-node-group/main.tf +++ b/modules/eks-managed-node-group/main.tf @@ -41,7 +41,7 @@ module "user_data" { ################################################################################ data "aws_ec2_instance_type" "this" { - count = var.create && var.enable_efa_support ? 1 : 0 + count = local.enable_efa_support ? 1 : 0 region = var.region @@ -62,6 +62,24 @@ locals { device_index = i == 0 ? 0 : 1 network_card_index = i interface_type = var.enable_efa_only ? contains(concat([0], var.efa_indices), i) ? "efa" : "efa-only" : "efa" + + # Null out due to error: The true and false result expressions must have consistent types. The 'true' value is tuple, but the 'false' value is list of objects. + associate_carrier_ip_address = null + connection_tracking_specification = null + description = "EFA${var.enable_efa_only ? "-only" : ""} Network Interface ${i}" + ena_srd_specification = null + ipv4_address_count = null + ipv4_addresses = null + ipv4_prefix_count = null + ipv4_prefixes = null + ipv6_address_count = null + ipv6_addresses = null + ipv6_prefix_count = null + ipv6_prefixes = null + network_interface_id = null + primary_ipv6 = null + private_ip_address = null + security_groups = [] } ] @@ -247,7 +265,7 @@ resource "aws_launch_template" "this" { name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null dynamic "network_interfaces" { - for_each = length(var.network_interfaces) > 0 ? var.network_interfaces : [] + for_each = length(local.network_interfaces) > 0 ? local.network_interfaces : [] content { associate_carrier_ip_address = network_interfaces.value.associate_carrier_ip_address @@ -688,9 +706,16 @@ locals { { all_self_efa = { description = "Node to node EFA" - protocol = "-1" - from_port = 0 + ip_protocol = "-1" self = true + + # Null out due to variable type and not using `try()` in resource + cidr_ipv4 = null + cidr_ipv6 = null + from_port = null + name = null + prefix_list_id = null + tags = {} } } : k => v if var.enable_efa_support }, @@ -700,9 +725,16 @@ locals { { all_self_efa = { description = "Node to node EFA" - protocol = "-1" - to_port = 0 + ip_protocol = "-1" self = true + + # Null out due to variable type and not using `try()` in resource + cidr_ipv4 = null + cidr_ipv6 = null + to_port = null + name = null + prefix_list_id = null + tags = {} } } : k => v if var.enable_efa_support }, diff --git a/modules/eks-managed-node-group/variables.tf b/modules/eks-managed-node-group/variables.tf index 6e65933e51..84bb8421d2 100644 --- a/modules/eks-managed-node-group/variables.tf +++ b/modules/eks-managed-node-group/variables.tf @@ -384,7 +384,6 @@ variable "network_interfaces" { primary_ipv6 = optional(bool) private_ip_address = optional(string) security_groups = optional(list(string), []) - subnet_id = optional(string) })) default = [] nullable = false diff --git a/modules/self-managed-node-group/README.md b/modules/self-managed-node-group/README.md index d834aa210d..c14f190d47 100644 --- a/modules/self-managed-node-group/README.md +++ b/modules/self-managed-node-group/README.md @@ -166,7 +166,7 @@ module "self_managed_node_group" { | [min\_size](#input\_min\_size) | The minimum size of the autoscaling group | `number` | `1` | no | | [mixed\_instances\_policy](#input\_mixed\_instances\_policy) | Configuration block containing settings to define launch targets for Auto Scaling groups |
object({
instances_distribution = optional(object({
on_demand_allocation_strategy = optional(string)
on_demand_base_capacity = optional(number)
on_demand_percentage_above_base_capacity = optional(number)
spot_allocation_strategy = optional(string)
spot_instance_pools = optional(number)
spot_max_price = optional(string)
}))
launch_template = object({
override = optional(list(object({
instance_requirements = optional(object({
accelerator_count = optional(object({
max = optional(number)
min = optional(number)
}))
accelerator_manufacturers = optional(list(string))
accelerator_names = optional(list(string))
accelerator_total_memory_mib = optional(object({
max = optional(number)
min = optional(number)
}))
accelerator_types = optional(list(string))
allowed_instance_types = optional(list(string))
bare_metal = optional(string)
baseline_ebs_bandwidth_mbps = optional(object({
max = optional(number)
min = optional(number)
}))
burstable_performance = optional(string)
cpu_manufacturers = optional(list(string))
excluded_instance_types = optional(list(string))
instance_generations = optional(list(string))
local_storage = optional(string)
local_storage_types = optional(list(string))
max_spot_price_as_percentage_of_optimal_on_demand_price = optional(number)
memory_gib_per_vcpu = optional(object({
max = optional(number)
min = optional(number)
}))
memory_mib = optional(object({
max = optional(number)
min = optional(number)
}))
network_bandwidth_gbps = optional(object({
max = optional(number)
min = optional(number)
}))
network_interface_count = optional(object({
max = optional(number)
min = optional(number)
}))
on_demand_max_price_percentage_over_lowest_price = optional(number)
require_hibernate_support = optional(bool)
spot_max_price_percentage_over_lowest_price = optional(number)
total_local_storage_gb = optional(object({
max = optional(number)
min = optional(number)
}))
vcpu_count = optional(object({
max = optional(number)
min = optional(number)
}))
}))
instance_type = optional(string)
launch_template_specification = optional(object({
launch_template_id = optional(string)
launch_template_name = optional(string)
version = optional(string)
}))
weighted_capacity = optional(string)
})))
})
})
| `null` | no | | [name](#input\_name) | Name of the Self managed Node Group | `string` | `""` | no | -| [network\_interfaces](#input\_network\_interfaces) | Customize network interfaces to be attached at instance boot time |
list(object({
associate_carrier_ip_address = optional(bool)
associate_public_ip_address = optional(bool)
connection_tracking_specification = optional(object({
tcp_established_timeout = optional(number)
udp_stream_timeout = optional(number)
udp_timeout = optional(number)
}))
delete_on_termination = optional(bool)
description = optional(string)
device_index = optional(number)
ena_srd_specification = optional(object({
ena_srd_enabled = optional(bool)
ena_srd_udp_specification = optional(object({
ena_srd_udp_enabled = optional(bool)
}))
}))
interface_type = optional(string)
ipv4_address_count = optional(number)
ipv4_addresses = optional(list(string))
ipv4_prefix_count = optional(number)
ipv4_prefixes = optional(list(string))
ipv6_address_count = optional(number)
ipv6_addresses = optional(list(string))
ipv6_prefix_count = optional(number)
ipv6_prefixes = optional(list(string))
network_card_index = optional(number)
network_interface_id = optional(string)
primary_ipv6 = optional(bool)
private_ip_address = optional(string)
security_groups = optional(list(string), [])
subnet_id = optional(string)
}))
| `[]` | no | +| [network\_interfaces](#input\_network\_interfaces) | Customize network interfaces to be attached at instance boot time |
list(object({
associate_carrier_ip_address = optional(bool)
associate_public_ip_address = optional(bool)
connection_tracking_specification = optional(object({
tcp_established_timeout = optional(number)
udp_stream_timeout = optional(number)
udp_timeout = optional(number)
}))
delete_on_termination = optional(bool)
description = optional(string)
device_index = optional(number)
ena_srd_specification = optional(object({
ena_srd_enabled = optional(bool)
ena_srd_udp_specification = optional(object({
ena_srd_udp_enabled = optional(bool)
}))
}))
interface_type = optional(string)
ipv4_address_count = optional(number)
ipv4_addresses = optional(list(string))
ipv4_prefix_count = optional(number)
ipv4_prefixes = optional(list(string))
ipv6_address_count = optional(number)
ipv6_addresses = optional(list(string))
ipv6_prefix_count = optional(number)
ipv6_prefixes = optional(list(string))
network_card_index = optional(number)
network_interface_id = optional(string)
primary_ipv6 = optional(bool)
private_ip_address = optional(string)
security_groups = optional(list(string), [])
}))
| `[]` | no | | [partition](#input\_partition) | The AWS partition - pass through value to reduce number of GET requests from data sources | `string` | `""` | no | | [placement](#input\_placement) | The placement of the instance |
object({
affinity = optional(string)
availability_zone = optional(string)
group_name = optional(string)
host_id = optional(string)
host_resource_group_arn = optional(string)
partition_number = optional(number)
spread_domain = optional(string)
tenancy = optional(string)
})
| `null` | no | | [placement\_group](#input\_placement\_group) | The name of the placement group into which you'll launch your instances | `string` | `null` | no | diff --git a/modules/self-managed-node-group/main.tf b/modules/self-managed-node-group/main.tf index 7ee3f40e84..c221521de4 100644 --- a/modules/self-managed-node-group/main.tf +++ b/modules/self-managed-node-group/main.tf @@ -82,7 +82,7 @@ module "user_data" { ################################################################################ data "aws_ec2_instance_type" "this" { - count = var.create && var.enable_efa_support ? 1 : 0 + count = local.enable_efa_support ? 1 : 0 region = var.region @@ -103,6 +103,24 @@ locals { device_index = i == 0 ? 0 : 1 network_card_index = i interface_type = var.enable_efa_only ? contains(concat([0], var.efa_indices), i) ? "efa" : "efa-only" : "efa" + + # Null out due to error: The true and false result expressions must have consistent types. The 'true' value is tuple, but the 'false' value is list of objects. + associate_carrier_ip_address = null + connection_tracking_specification = null + description = "EFA${var.enable_efa_only ? "-only" : ""} Network Interface ${i}" + ena_srd_specification = null + ipv4_address_count = null + ipv4_addresses = null + ipv4_prefix_count = null + ipv4_prefixes = null + ipv6_address_count = null + ipv6_addresses = null + ipv6_prefix_count = null + ipv6_prefixes = null + network_interface_id = null + primary_ipv6 = null + private_ip_address = null + security_groups = [] } ] @@ -365,7 +383,7 @@ resource "aws_launch_template" "this" { name_prefix = var.launch_template_use_name_prefix ? "${local.launch_template_name}-" : null dynamic "network_interfaces" { - for_each = length(var.network_interfaces) > 0 ? var.network_interfaces : [] + for_each = length(local.network_interfaces) > 0 ? local.network_interfaces : [] content { associate_carrier_ip_address = network_interfaces.value.associate_carrier_ip_address @@ -976,9 +994,16 @@ locals { { all_self_efa = { description = "Node to node EFA" - protocol = "-1" - from_port = 0 + ip_protocol = "-1" self = true + + # Null out due to variable type and not using `try()` in resource + cidr_ipv4 = null + cidr_ipv6 = null + from_port = null + name = null + prefix_list_id = null + tags = {} } } : k => v if var.enable_efa_support }, @@ -988,9 +1013,16 @@ locals { { all_self_efa = { description = "Node to node EFA" - protocol = "-1" - to_port = 0 + ip_protocol = "-1" self = true + + # Null out due to variable type and not using `try()` in resource + cidr_ipv4 = null + cidr_ipv6 = null + to_port = null + name = null + prefix_list_id = null + tags = {} } } : k => v if var.enable_efa_support }, diff --git a/modules/self-managed-node-group/variables.tf b/modules/self-managed-node-group/variables.tf index a3168a6aa7..6e42508c68 100644 --- a/modules/self-managed-node-group/variables.tf +++ b/modules/self-managed-node-group/variables.tf @@ -311,7 +311,6 @@ variable "network_interfaces" { primary_ipv6 = optional(bool) private_ip_address = optional(string) security_groups = optional(list(string), []) - subnet_id = optional(string) })) default = [] nullable = false diff --git a/tests/eks-managed-node-group/main.tf b/tests/eks-managed-node-group/main.tf index 27098981c4..c09bde0a3b 100644 --- a/tests/eks-managed-node-group/main.tf +++ b/tests/eks-managed-node-group/main.tf @@ -318,14 +318,15 @@ module "eks" { } efa = { - # Disabling automatic creation due to instance type/quota availability - # Can be enabled when appropriate for testing/validation - create = false - # The EKS AL2023 NVIDIA AMI provides all of the necessary components # for accelerated workloads w/ EFA ami_type = "AL2023_x86_64_NVIDIA" - instance_types = ["p5e.48xlarge"] + instance_types = ["p4d.24xlarge"] + + # Setting to zero so all resources are created *EXCEPT the EC2 instances + min_size = 0 + max_size = 1 + desired_size = 0 # Mount instance store volumes in RAID-0 for kubelet and containerd # https://github.com/awslabs/amazon-eks-ami/blob/master/doc/USER_GUIDE.md#raid-0-for-kubelet-and-containerd-raid0 @@ -350,11 +351,7 @@ module "eks" { # 3. Expose all of the available EFA interfaces on the launch template enable_efa_support = true enable_efa_only = true - efa_indices = [0, 4, 8, 12] - - min_size = 1 - max_size = 1 - desired_size = 1 + efa_indices = [0] labels = { "vpc.amazonaws.com/efa.present" = "true" diff --git a/tests/self-managed-node-group/main.tf b/tests/self-managed-node-group/main.tf index 9fc3fdc6b1..50611d4b3d 100644 --- a/tests/self-managed-node-group/main.tf +++ b/tests/self-managed-node-group/main.tf @@ -309,14 +309,15 @@ module "eks" { } efa = { - # Disabling automatic creation due to instance type/quota availability - # Can be enabled when appropriate for testing/validation - create = false - # The EKS AL2023 NVIDIA AMI provides all of the necessary components # for accelerated workloads w/ EFA ami_type = "AL2023_x86_64_NVIDIA" - instance_types = ["p5e.48xlarge"] + instance_types = ["p4d.24xlarge"] + + # Setting to zero so all resources are created *EXCEPT the EC2 instances + min_size = 0 + max_size = 1 + desired_size = 0 # Mount instance store volumes in RAID-0 for kubelet and containerd # https://github.com/awslabs/amazon-eks-ami/blob/master/doc/USER_GUIDE.md#raid-0-for-kubelet-and-containerd-raid0 @@ -341,11 +342,7 @@ module "eks" { # 3. Expose all of the available EFA interfaces on the launch template enable_efa_support = true enable_efa_only = true - efa_indices = [0, 4, 8, 12] - - min_size = 2 - max_size = 2 - desired_size = 2 + efa_indices = [0] labels = { "vpc.amazonaws.com/efa.present" = "true"