diff --git a/README.md b/README.md index 26afcca..e1ad291 100644 --- a/README.md +++ b/README.md @@ -177,9 +177,9 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir | Name | Version | |------|---------| -| [aws](#provider\_aws) | 4.49.0 | +| [aws](#provider\_aws) | >=3.61.0 | | [helm](#provider\_helm) | 2.2.0 | -| [kubernetes](#provider\_kubernetes) | 2.16.1 | +| [kubernetes](#provider\_kubernetes) | >=2.6.1 | ## Modules @@ -334,6 +334,7 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir | [migration\_mode](#input\_migration\_mode) | Whether to enable migration mode for the cluster. This is used to migrate details from existing security groups, which have had their names and description changed in versions v18.X of the community EKS module. | `bool` | `false` | no | | [migration\_mode\_node\_sg\_name](#input\_migration\_mode\_node\_sg\_name) | The name (not ID!) of the existing security group used by worker nodes. This is required when "migration\_mode" is set to "true", otherwise the parent module will attempt to set a new security group name and destroy the existin one. | `string` | `null` | no | | [node\_pool\_ami\_id](#input\_node\_pool\_ami\_id) | The AMI ID to use for the EKS cluster nodes. Defaults to the latest EKS Optimized AMI provided by AWS. | `string` | `""` | no | +| [node\_pool\_azs](#input\_node\_pool\_azs) | A list of availability zones to use for the EKS node group. If not set, the module will use the same availability zones with the cluster. | `list(string)` | `[]` | no | | [node\_pool\_block\_device\_name](#input\_node\_pool\_block\_device\_name) | The name of the block device to use for the EKS cluster nodes. | `string` | `"/dev/nvme0n1"` | no | | [node\_pool\_desired\_size](#input\_node\_pool\_desired\_size) | Desired number of worker nodes in the node pool. | `number` | `0` | no | | [node\_pool\_disk\_iops](#input\_node\_pool\_disk\_iops) | The amount of provisioned IOPS for the worker node root EBS volume. | `number` | `3000` | no | @@ -397,6 +398,7 @@ _Note: Since this module manages all of the Kubernetes addon dependencies requir | [eks\_node\_group\_security\_group\_id](#output\_eks\_node\_group\_security\_group\_id) | Security group ID attached to the EKS node groups | | [eks\_node\_groups](#output\_eks\_node\_groups) | Map of all attributes of the EKS node groups created by this module | | [external\_dns\_arn](#output\_external\_dns\_arn) | The ARN for External DNS | +| [inuse\_azs](#output\_inuse\_azs) | The availability zones in which the EKS nodes is deployed | | [tiered\_storage\_s3\_bucket\_arn](#output\_tiered\_storage\_s3\_bucket\_arn) | The ARN for the tiered storage S3 bucket created by this module | | [velero\_arn](#output\_velero\_arn) | ARN for Velero | | [velero\_s3\_bucket\_arn](#output\_velero\_s3\_bucket\_arn) | The ARN for the Velero S3 bucket created by this module | diff --git a/main.tf b/main.tf index b2bbf76..ea64211 100644 --- a/main.tf +++ b/main.tf @@ -21,6 +21,11 @@ data "aws_subnet" "private_subnets" { id = var.private_subnet_ids[count.index] } +data "aws_subnet" "public_subnets" { + count = length(var.public_subnet_ids) + id = var.public_subnet_ids[count.index] +} + data "aws_kms_key" "ebs_default" { key_id = "alias/aws/ebs" } @@ -38,7 +43,12 @@ locals { default_service_policy_arn = "arn:${local.aws_partition}:iam::${local.account_id}:policy/StreamNative/StreamNativeCloudRuntimePolicy" ebs_kms_key = var.disk_encryption_kms_key_arn == "" ? data.aws_kms_key.ebs_default.arn : var.disk_encryption_kms_key_arn oidc_issuer = trimprefix(module.eks.cluster_oidc_issuer_url, "https://") - nodes_subnet_ids = var.enable_nodes_use_public_subnet ? var.public_subnet_ids : var.private_subnet_ids + + nodes_available_subnets = var.enable_nodes_use_public_subnet ? data.aws_subnet.public_subnets : data.aws_subnet.private_subnets + node_group_subnets = length(var.node_pool_azs) != 0 ? [ + for index, subnet in local.nodes_available_subnets : subnet if contains(var.node_pool_azs, subnet.availability_zone) + ] : local.nodes_available_subnets + node_group_subnet_ids = [for index, subnet in local.node_group_subnets : subnet.id] tags = merge( { @@ -134,7 +144,7 @@ locals { v3_node_groups = tomap({ "snc-core" = { - subnet_ids = local.nodes_subnet_ids + subnet_ids = local.node_group_subnet_ids instance_types = [var.v3_node_group_core_instance_type] name = "snc-core" taints = local.v3_node_taints diff --git a/outputs.tf b/outputs.tf index ac45ccb..1dbb45a 100644 --- a/outputs.tf +++ b/outputs.tf @@ -121,3 +121,8 @@ output "eks" { value = module.eks description = "All outputs of module.eks for provide convenient approach to access child module's outputs." } + +output "inuse_azs" { + value = distinct([for index, subnet in local.node_group_subnets : subnet.availability_zone]) + description = "The availability zones in which the EKS nodes is deployed" +} diff --git a/variables.tf b/variables.tf index e2b2e0e..bcf2566 100644 --- a/variables.tf +++ b/variables.tf @@ -489,6 +489,12 @@ variable "node_pool_instance_types" { type = list(string) } +variable "node_pool_azs" { + type = list(string) + description = "A list of availability zones to use for the EKS node group. If not set, the module will use the same availability zones with the cluster." + default = [] +} + variable "node_pool_labels" { default = {} description = "A map of kubernetes labels to add to the node pool."