Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ We are grateful to the community for contributing bugfixes and improvements! Ple
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | Number of days to retain log events. Default retention - 90 days | `number` | `90` | no |
| <a name="input_cloudwatch_log_group_tags"></a> [cloudwatch\_log\_group\_tags](#input\_cloudwatch\_log\_group\_tags) | A map of additional tags to add to the cloudwatch log group created | `map(string)` | `{}` | no |
| <a name="input_cluster_tags"></a> [cluster\_tags](#input\_cluster\_tags) | A map of additional tags to add to the cluster | `map(string)` | `{}` | no |
| <a name="input_compute_config"></a> [compute\_config](#input\_compute\_config) | Configuration block for the cluster compute configuration | <pre>object({<br/> enabled = optional(bool, false)<br/> node_pools = optional(list(string))<br/> node_role_arn = optional(string)<br/> })</pre> | `null` | no |
| <a name="input_compute_config"></a> [compute\_config](#input\_compute\_config) | Configuration block for the cluster compute configuration | <pre>object({<br/> enabled = optional(bool, false)<br/> node_pools = optional(list(string), [])<br/> node_role_arn = optional(string)<br/> })</pre> | `null` | no |
| <a name="input_control_plane_subnet_ids"></a> [control\_plane\_subnet\_ids](#input\_control\_plane\_subnet\_ids) | A list of subnet IDs where the EKS cluster control plane (ENIs) will be provisioned. Used for expanding the pool of subnets used by nodes/node groups without replacing the EKS control plane | `list(string)` | `[]` | no |
| <a name="input_create"></a> [create](#input\_create) | Controls if resources should be created (affects nearly all resources) | `bool` | `true` | no |
| <a name="input_create_cloudwatch_log_group"></a> [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a log group is created by this module for the cluster logs. If not, AWS will automatically create one if logging is enabled | `bool` | `true` | no |
Expand Down
1 change: 1 addition & 0 deletions examples/eks-auto-mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Note that this example may create resources which cost money. Run `terraform des
|------|--------|---------|
| <a name="module_disabled_eks"></a> [disabled\_eks](#module\_disabled\_eks) | ../.. | n/a |
| <a name="module_eks"></a> [eks](#module\_eks) | ../.. | n/a |
| <a name="module_eks_custom_node_pools"></a> [eks\_custom\_node\_pools](#module\_eks\_custom\_node\_pools) | ../.. | n/a |
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |

## Resources
Expand Down
21 changes: 21 additions & 0 deletions examples/eks-auto-mode/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ module "eks" {
tags = local.tags
}

module "eks_custom_node_pools" {
source = "../.."

name = "${local.name}-cnp"
kubernetes_version = local.kubernetes_version
endpoint_public_access = true
deletion_protection = true

enable_cluster_creator_admin_permissions = true

compute_config = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#3514 does what I believe you are trying to do. this does not work as its written and throws the following error
image

its also not very intuitive, in my opinion, to know that you need to set node_pools = [] just to get the IAM resources required for using only custom node pools

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied and updated and destroyed my config a dozen times with various inputs. What exact combination of configs and workflow generated that error? If you look at the commit message for 076e62d (#3513), you'll see that is the exact issue I was addressing (or attempting to...).

Copy link
Contributor Author

@lorengordon lorengordon Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I set the default compute_config.node_pools = [], you do not actually need to set that in config to enable auto mode and use the node iam role for a custom node pool. You can pass in only compute.config.enabled = true and it will do the right thing.

enabled = true
node_pools = []
}

vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets

tags = local.tags
}

module "disabled_eks" {
source = "../.."

Expand Down
10 changes: 5 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ resource "aws_eks_cluster" "this" {
}

dynamic "compute_config" {
for_each = var.compute_config != null ? [var.compute_config] : []
for_each = var.compute_config[*]

content {
enabled = compute_config.value.enabled
node_pools = compute_config.value.node_pools
node_role_arn = compute_config.value.node_pools != null ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null
node_pools = compute_config.value.enabled ? compute_config.value.node_pools : []
node_role_arn = compute_config.value.enabled ? (length(compute_config.value.node_pools) > 0 ? try(aws_iam_role.eks_auto[0].arn, compute_config.value.node_role_arn) : null) : null
}
}

Expand All @@ -81,7 +81,7 @@ resource "aws_eks_cluster" "this" {

content {
dynamic "elastic_load_balancing" {
for_each = local.auto_mode_enabled ? [1] : []
for_each = var.compute_config[*]

content {
enabled = local.auto_mode_enabled
Expand Down Expand Up @@ -148,7 +148,7 @@ resource "aws_eks_cluster" "this" {
}

dynamic "storage_config" {
for_each = local.auto_mode_enabled ? [1] : []
for_each = var.compute_config[*]

content {
block_storage {
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ variable "compute_config" {
description = "Configuration block for the cluster compute configuration"
type = object({
enabled = optional(bool, false)
node_pools = optional(list(string))
node_pools = optional(list(string), [])
node_role_arn = optional(string)
})
default = null
Expand Down