Skip to main content
EKS managed node groups (MNG) let AWS handle the provisioning, patching, and graceful draining of EC2 worker nodes. You retain full control over instance types, AMI selection, sizing, and node-level configuration while AWS owns the underlying Auto Scaling group lifecycle. This example demonstrates two separate clusters — one using the Amazon Linux 2023 (AL2023) AMI and one using Bottlerocket — to show how the eks_managed_node_groups map works with different operating systems.

Prerequisites

  • AWS credentials with permissions to create EKS, EC2, IAM, and VPC resources
  • Terraform >= 1.5.7
  • AWS provider >= 6.28
  • The example provisions its own VPC — no pre-existing VPC is required

VPC and shared locals

Both clusters share a common VPC defined in main.tf.

Amazon Linux 2023 cluster (eks-al2023.tf)

AL2023 is the default AMI type for EKS managed node groups starting with Kubernetes 1.30. It uses nodeadm for node initialization, and additional configuration can be injected via cloudinit_pre_nodeadm.

Bottlerocket cluster (eks-bottlerocket.tf)

Bottlerocket is a Linux-based OS purpose-built for container workloads. Node configuration is injected via the bootstrap_extra_args field using TOML syntax.

Key configuration options

AMI types

before_compute addon flag

Setting before_compute = true on vpc-cni and eks-pod-identity-agent ensures those addons are installed before the first node joins the cluster, preventing race conditions where pods start before the CNI is ready.

desired_size and drift

desired_size is only respected on the initial creation of the node group. After creation, the Auto Scaling group’s actual desired capacity is the source of truth. See eks-desired-size-hack for a workaround pattern.
Use use_latest_ami_release_version = true on a node group to automatically track the latest patched AMI release for the configured AMI type and Kubernetes version.

Deploy

1

Initialize Terraform

2

Review the plan

3

Apply

Both clusters are created together. Expect 15–20 minutes for all resources.
4

Configure kubectl

Key outputs

Full example on GitHub

View the complete example including outputs.tf, variables.tf, and versions.tf.