Sets up an EKS Node Group to automatically use the latest Amazon EKS optimized AMI based on the EKS cluster version.

Terraform Template

data "aws_ssm_parameter" "eks_ami_release_version" {
  name = "/aws/service/eks/optimized-ami/${aws_eks_cluster.example.version}/amazon-linux-2/recommended/release_version"
}

resource "aws_eks_node_group" "example" {
  cluster_name = "aws_eks_cluster.example.name"
  node_group_name = "example"
  node_role_arn = "aws_iam_role.example.arn"
  release_version = nonsensitive(data.aws_ssm_parameter.eks_ami_release_version.value)
  subnet_ids = aws_subnet.example[*].id
  version = "aws_eks_cluster.example.version"
}