Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable_irsa = true fails on new cluster #2170

Closed
d-m opened this issue Jul 21, 2022 · 9 comments · Fixed by #2174
Closed

enable_irsa = true fails on new cluster #2170

d-m opened this issue Jul 21, 2022 · 9 comments · Fixed by #2174

Comments

@d-m
Copy link

d-m commented Jul 21, 2022

Issue

I'm working through the Karpenter example and enabling IRSA via enable_irsa = true fails on a new cluster with the following error when attempting terraform plan and terraform apply:

│ Error: Invalid index
│ 
│   on .terraform/modules/eks/main.tf line 211, in resource "aws_iam_openid_connect_provider" "oidc_provider":
│  211:   thumbprint_list = concat([data.tls_certificate.this[0].certificates[0].sha1_fingerprint], var.custom_oidc_thumbprints)
│     ├────────────────
│     │ data.tls_certificate.this[0].certificates is empty list of object
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.

It succeeds when I set enable_irsa = false, run terraform apply, set enable_irsa = true, and then run terraform apply again. Is this intended? I didn't see anything in the documentation saying that it couldn't be used on a new cluster.

Terraform manifest

module "eks" {
  # https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/latest
  source  = "terraform-aws-modules/eks/aws"
  version = "18.17.0"

  cluster_name    = local.cluster_name
  cluster_version = "1.21"

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

  # Required for Karpenter role below
  enable_irsa = true

  # We will rely only on the cluster security group created by the EKS service
  # See note below for `tags`
  create_cluster_security_group = false
  create_node_security_group    = false

  # Only need one node to get Karpenter up and running.
  # This ensures core services such as VPC CNI, CoreDNS, etc. are up and running
  # so that Karpenter can be deployed and start managing compute capacity as required
  eks_managed_node_groups = {
    initial = {
      instance_types = ["t3.medium"]
      # We don't need the node security group since we are using the
      # cluster-created security group, which Karpenter will also use
      create_security_group                 = false
      attach_cluster_primary_security_group = true

      min_size     = 1
      max_size     = 1
      desired_size = 1

      iam_role_additional_policies = [
        # Required by Karpenter
        "arn:${local.partition}:iam::aws:policy/AmazonSSMManagedInstanceCore"
      ]
    }
  }

  tags = {
    # Tag node group resources for Karpenter auto-discovery
    # NOTE - if creating multiple security groups with this module, only tag the
    # security group that Karpenter should utilize with the following tag
    "karpenter.sh/discovery" = local.cluster_name
  }
}

Terraform version

❯ terraform -version
Terraform v1.2.5
on linux_amd64
+ provider registry.terraform.io/gavinbunney/kubectl v1.14.0
+ provider registry.terraform.io/hashicorp/aws v4.22.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/helm v2.5.1
+ provider registry.terraform.io/hashicorp/kubernetes v2.12.1
+ provider registry.terraform.io/hashicorp/tls v4.0.0
@mikeinton
Copy link

Also wanted to comment here that I encountered the same issue while testing the creation of new EKS clusters using EKS Blueprints.

❯ terraform version
Terraform v1.2.5
on darwin_amd64
+ provider registry.terraform.io/gavinbunney/kubectl v1.14.0
+ provider registry.terraform.io/hashicorp/aws v4.22.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.2.0
+ provider registry.terraform.io/hashicorp/helm v2.6.0
+ provider registry.terraform.io/hashicorp/kubernetes v2.10.0
+ provider registry.terraform.io/hashicorp/local v2.2.3
+ provider registry.terraform.io/hashicorp/null v3.1.1
+ provider registry.terraform.io/hashicorp/time v0.7.2
+ provider registry.terraform.io/hashicorp/tls v3.4.0
+ provider registry.terraform.io/terraform-aws-modules/http v2.4.1

@tieujason330
Copy link

Also seeing this error when running terraform apply in terraform-aws-eks/examples/complete


│ Error: Invalid index

│ on ../../main.tf line 211, in resource "aws_iam_openid_connect_provider" "oidc_provider":
│ 211: thumbprint_list = concat([data.tls_certificate.this[0].certificates[0].sha1_fingerprint], var.custom_oidc_thumbprints)
│ ├────────────────
│ │ data.tls_certificate.this[0].certificates is empty list of object

│ The given key does not identify an element in this collection value.

@fahadahammed
Copy link

ALso seeing this error:

│ Error: Invalid index
│ 
│   on modules/terraform-aws-eks/main.tf line 211, in resource "aws_iam_openid_connect_provider" "oidc_provider":
│  211:   thumbprint_list = concat([data.tls_certificate.this[0].certificates[0].sha1_fingerprint], var.custom_oidc_thumbprints)
│     ├────────────────
│     │ data.tls_certificate.this[0].certificates is empty list of object
│ 
│ The given key does not identify an element in this collection value: the collection has no elements.

@smuth4
Copy link

smuth4 commented Jul 21, 2022

We also received this error, and were able to work around it by pinning hashicorp/tls to <4.0.0

terraform {
  required_providers {
    tls = {
      version = "<4.0.0"
    }
  }
}

jbronn added a commit to radiant-maxar/terraform-eks that referenced this issue Jul 21, 2022
* Add workaround for terraform-aws-modules/terraform-aws-eks#2170.
* Remove `ClusterIssuer` manifest configuration.
anhqqt pushed a commit to aq-terraform-workspace/AWS-ACLOUDGURU-2 that referenced this issue Jul 22, 2022
@anhqqt
Copy link

anhqqt commented Jul 22, 2022

I also encountered the same issue today

image

@smuth4 Thank you, you saved my life

@spr-mweber3
Copy link

This is hunting us aswell.

@FernandoMiguel
Copy link
Contributor

FYI this is the underlying issue hashicorp/terraform-provider-tls#244

@antonbabenko
Copy link
Member

This issue has been resolved in version 18.26.6 🎉

@github-actions
Copy link

github-actions bot commented Nov 9, 2022

I'm going to lock this issue 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 similar to this, 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 Nov 9, 2022
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 a pull request may close this issue.

9 participants