Skip to content

[Bug]: timeouts block of aws_eks_addon does not support for_each loop #35510

@jaygridley

Description

@jaygridley

Terraform Core Version

1.5.7

AWS Provider Version

5.33.0

Affected Resource(s)

  • aws_eks_addon

Expected Behavior

When specifying timeouts for aws_eks_addon and using for_each on the resource, timeouts should support specifying a value for timeouts.create, timeouts.update and timeouts.delete using each.value.

Actual Behavior

Terraform is producing an error when using each.value for timeouts.create, timeouts.update and timeouts.delete.

Relevant Error/Panic Output Snippet

╷
│ Error: Error parsing "create" timeout: time: unknown unit "D" in duration "74D93920-ED26-11E3-AC10-0800200C9A66"
│ 
│   with aws_eks_addon["aws-cni"],
│   on main.tf line 21, in resource "aws_eks_addon" "this":
│  21: resource "aws_eks_addon" "this" {
│ 
╵

Terraform Configuration Files

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "4.0.0"

  name               = "vpc"
  cidr               = "10.0.0.0/16"
  azs                = ["eu-central-1a", "eu-central-1b"]
  public_subnets     = ["10.0.101.0/24", "10.0.102.0/24"]
  enable_nat_gateway = true
}

module "eks_cluster" {
  source  = "cloudposse/eks-cluster/aws"
  version = "2.3.0"

  region     = "eu-central-1"
  subnet_ids = module.vpc.public_subnets
  vpc_id     = module.vpc.vpc_id
  name       = "example"
  kubernetes_version = "1.26"
}

resource "aws_eks_addon" "this" {
  for_each = {
    vpc-cni = "v1.15.5-eksbuild.1"
  }

  cluster_name  = module.eks_cluster.eks_cluster_id
  addon_name    = each.key
  addon_version = each.value

  timeouts {
    create = try(each.value.create_timeout, "30m")
  }
}

Steps to Reproduce

  1. Add AWS VPC
  2. Add AWS EKS cluster
  3. Add AWS EKS managed addon, i.e. aws-cni using aws_eks_addon resource
  4. Add for_each to the aws_eks_addon resource
  5. Add timeouts to the aws_eks_addon resource and use each.value for timeouts.create
  6. Run Terraform plan -> this will produce the error

Debug Output

No response

Panic Output

No response

Important Factoids

  • When the addon is already installed, adding timeouts to the resource do NOT cause the error.
  • Not using each.value in timeouts block do NOT cause the error.
  • Value 74D93920-ED26-11E3-AC10-0800200C9A66 is Terraform magic string for an unknown value.

References

No response

Would you like to implement a fix?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAddresses a defect in current functionality.service/eksIssues and PRs that pertain to the eks service.upstream-terraformAddresses functionality related to the Terraform core binary.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions