Skip to content

Conversation

mirza-opsguru
Copy link

Description

Changed the content in eks_cluster resource for dynamic blocks kubernetes_network_config.elastic_load_balancing and storage_config to be normal blocks instead of dynamic, so they are always resolved to either true or false (default).

Motivation and Context

The problem is whenever you enable EKS auto-mode, if you want to disable it in the future, it won't be possible to do it.
The reason behind this is that the dynamic blocks mentioned above are managed by local variable called auto_mode_enabled, which gets its value from try(var.compute_config.enabled, false), so it's either true or false.

dynamic "kubernetes_network_config" {
    # Not valid on Outposts
    for_each = local.create_outposts_local_cluster ? [] : [1]

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

        content {
          enabled = local.auto_mode_enabled
        }
      }

      ip_family         = var.ip_family
      service_ipv4_cidr = var.service_ipv4_cidr
      service_ipv6_cidr = var.service_ipv6_cidr
    }
  }
  ...
  dynamic "storage_config" {
    for_each = local.auto_mode_enabled ? [1] : []

    content {
      block_storage {
        enabled = local.auto_mode_enabled
      }
    }
  }

As seen in the blocks, if the local variable resolves to false, it won't create the dynamic blocks, which is great if you never enabled eks auto-mode, but if you ever enabled it, it will try to resolve the values to null instead of false, which terraform and AWS provider won't allow.
You'll get error like this:

  │ Error: compute_config.enabled, kubernetes_networking_config.elastic_load_balancing.enabled, and storage_config.block_storage.enabled must all be set to either true or false
  │ 
  │   with module.eks.aws_eks_cluster.this[0],
  │   on .terraform/modules/eks/main.tf line 35, in resource "aws_eks_cluster" "this":
  │   35: resource "aws_eks_cluster" "this" {

hashicorp/terraform-provider-aws#42483
#3273
These issues are not opened, but they haven't been resolved before.

Breaking Changes

It doesn't break anything, since the blocks for these values shouldn't be dynamic in the newer providers versions, they should always be set to either true or false (all 3 blocks).
#3273 (comment)

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects

I have tested and validated these changes on a live project. (these changes were made for the project to get it working after the customer decided to disable EKS auto-mode after enabling it first)

  • I have executed pre-commit run -a on my pull request

@mirza-opsguru mirza-opsguru changed the title Fix disabling EKS auto-mode after it has been enabled fix disabling EKS auto-mode after it has been enabled Sep 16, 2025
@mirza-opsguru mirza-opsguru changed the title fix disabling EKS auto-mode after it has been enabled fix: disabling EKS auto-mode after it has been enabled Sep 16, 2025
@mirza-opsguru mirza-opsguru changed the title fix: disabling EKS auto-mode after it has been enabled fix: Disabling EKS auto-mode after it has been enabled Sep 16, 2025
@antonbabenko
Copy link
Member

This issue has been resolved in version 21.3.0 🎉

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants