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

self managed node group fails with default cluster_version = null #1959

Closed
aidanmelen opened this issue Mar 24, 2022 · 4 comments
Closed

self managed node group fails with default cluster_version = null #1959

aidanmelen opened this issue Mar 24, 2022 · 4 comments

Comments

@aidanmelen
Copy link

aidanmelen commented Mar 24, 2022

Description

The self managed node group uses the cluster_version input used to lookup default AMI ID if one is not provided. But the default for cluster_version is null.

The data.aws_ami.eks_default data resource will fail to filter with the null value. e.g. amazon-eks-node-null-v*

Versions

  • Terraform: v1.1.7
  • Provider(s): terraform-aws-modules/eks/aws (0.18.3)
  • Sub-Module: self-managed-node-group

Reproduction

Steps to reproduce the behavior:

  1. run terraform-aws-modules/eks/aws with self_managed_node_groups sub-module and don't set cluster_version

Code Snippet to Reproduce

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = ">= 18.0.0"

  cluster_name    = local.name
  # cluster_version = "1.21"
  vpc_id          = module.vpc.vpc_id
  subnet_ids      = module.vpc.private_subnets

  self_managed_node_groups = {
    boo = {
      instance_type = "t3.medium"
      instance_market_options = {
        market_type = "spot"
      }
    }
  }
}

Expected behavior

defaults to the cluster version.

Actual behavior

defaults to null

Terminal Output Screenshot(s)

Additional context

one possible solution is to retrieve the cluster_version from a data resource and set that as the default

data "aws_eks_cluster" "example" {
  name = "example"
}

output "dynamic_cluster_version" {
  value = data.aws_eks_cluster.example.version
}
@bryantbiggs
Copy link
Member

I think its better if we just rely on users specifying the version - it aligns with the other sub-modules as well

@aidanmelen
Copy link
Author

aidanmelen commented Mar 24, 2022

it aligns with the other sub-modules as well

The behavior of the self managed node group is inconsistent with the other sub-modules. for example

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = ">= 18.0.0"

  cluster_name    = local.name
  # cluster_version = "1.21"

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

  self_managed_node_groups = {
    boo = {
      instance_type = "t3.medium"
      instance_market_options = {
        market_type = "spot"
      }
    }
  }
}

FAIL: The plan fails as the self managed node group fails to look up the EKS AMI with latest cluster version.

╷
│ Error: Invalid template interpolation value
│ 
│   on ../../modules/self-managed-node-group/main.tf line 10, in data "aws_ami" "eks_default":
│   10:     values = ["amazon-eks-node-${var.cluster_version}-v*"]
│     ├────────────────
│     │ var.cluster_version is null
│ 
│ The expression result is null. Cannot include a null value in a string template.
╵
module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = ">= 18.0.0"

  cluster_name    = local.name
  # cluster_version = "1.21"

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

  eks_managed_node_groups = {
    foo = {}
  }
}

PASS: creates eks managed node group on latest cluster version

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = ">= 18.0.0"

  cluster_name    = local.name
  # cluster_version = "1.21"

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

  fargate_profiles = {
    bar = {
      selectors = [
        {
          namespace = "bar"
        }
      ]
    }
  }
}

PASS: creates fargate profile on latest cluster version

@bryantbiggs
Copy link
Member

The behavior of the self managed node group is inconsistent with the other sub-modules. for example

Self managed node groups by their very nature are different from EKS managed or Fargate profiles because all management is up to users

@github-actions
Copy link

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 13, 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

No branches or pull requests

2 participants