Skip to content

Unable to Use eks_managed_node_group with EKS Module V21 #3558

@therestimmy

Description

@therestimmy

Description

We've recently started using hashicorp/aws provider version "~> 6 with the version of eks module ~> 21. The version of EKS we have is 1.32. When running tofu plan, I get this error:

│ Error: Invalid count argument
│
│   on .terraform/modules/eks.eks/modules/eks-managed-node-group/main.tf line 2, in data "aws_partition" "current":
│    2:   count = var.create && var.partition == "" ? 1 : 0
│
│ The "count" value depends on resource attributes that cannot be determined until apply, so OpenTofu cannot predict how many instances will be created.
│
│ To work around this, use the planning option -exclude=module.eks.module.eks.module.eks_managed_node_group\[\"bootstrap\"\].data.aws_partition.current to first apply
│ without this object, and then apply normally to converge.
╵
╷
│ Error: Invalid count argument
│
│   on .terraform/modules/eks.eks/modules/eks-managed-node-group/main.tf line 5, in data "aws_caller_identity" "current":
│    5:   count = var.create && var.account_id == "" ? 1 : 0
│
│ The "count" value depends on resource attributes that cannot be determined until apply, so OpenTofu cannot predict how many instances will be created.
│
│ To work around this, use the planning option -exclude=module.eks.module.eks.module.eks_managed_node_group\[\"bootstrap\"\].data.aws_caller_identity.current to first
│ apply without this object, and then apply normally to converge.

I tried running rm -rf .terraform and then tofu init; tofu plan. The init works, but plan throws the aforementioned error.

  • ✋ I have searched the open/closed issues and my issue is not listed.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

  • Module version [Required]:

  • Terraform version:

  • Provider version(s):
+ provider registry.opentofu.org/gavinbunney/kubectl v1.16.0
+ provider registry.opentofu.org/hashicorp/aws v6.18.0
+ provider registry.opentofu.org/hashicorp/cloudinit v2.3.7
+ provider registry.opentofu.org/hashicorp/helm v2.17.0
+ provider registry.opentofu.org/hashicorp/kubernetes v2.38.0
+ provider registry.opentofu.org/hashicorp/null v3.2.4
+ provider registry.opentofu.org/hashicorp/time v0.13.1
+ provider registry.opentofu.org/hashicorp/tls v4.1.0

Reproduction Code [Required]

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = var.module_version

  cluster_name                    = var.cluster_name
  cluster_version                 = var.cluster_version
  enable_irsa                     = true
  vpc_id                          = local.vpc_id
  subnet_ids                      = data.aws_subnets.private_subnets.ids
  cluster_endpoint_private_access = true
  cluster_endpoint_public_access  = true
  bootstrap_self_managed_addons   = var.bootstrap_self_managed_addons

  cluster_addons = {
    kube-proxy = {}
    vpc-cni    = {}
  }

eks_managed_node_groups = {
    bootstrap = {
      name                       = "bootstrap"
      use_custom_launch_template = false
      disk_size                  = 20
      capacity_type              = "SPOT"
      force_update_version       = true
      ami_type                   = "BOTTLEROCKET_x86_64"
      platform                   = "bottlerocket"
      instance_types             = ["m5.large", "m5a.large"]
      iam_role_attach_cni_policy = true

      min_size     = 0
      max_size     = 2
      desired_size = 0

      use_custom_launch_template = true
      enable_bootstrap_user_data = true

    }
  }

Steps to reproduce the behavior:

Expected behavior

tofu plan returns a list of resources to be created

Actual behavior

tofu plan returns the list of resources to be created followed by the aforementioned errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions