Interview Prep/Real-World Interview/Write-Terraform tasks

Write an EKS cluster with a managed node group using the community module.

AdvancedHands-onWrite-Terraform tasks
Answer
module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = "~> 20.0"

  cluster_name    = "devopsshack-prod"
  cluster_version = "1.31"
  vpc_id          = module.vpc.vpc_id
  subnet_ids      = module.vpc.private_subnets

  cluster_endpoint_public_access           = true
  enable_cluster_creator_admin_permissions = true

  eks_managed_node_groups = {
    general = {
      instance_types = ["m6i.large"]
      min_size       = 2
      max_size       = 6
      desired_size   = 3
      capacity_type  = "ON_DEMAND"
    }
  }

  tags = { Environment = "prod" }
}

Key trick → Pin the module's major version, because v19 to v20 changed authentication to EKS access entries. Put nodes in private subnets, and enable_cluster_creator_admin_permissions keeps you from locking yourself out.

All Real-World Interview questions Roadmap: Interview readiness

More on Write-Terraform tasks