Services

Resources

Company

/

Amazon Machine Image (AMI)

Amazon Machine Image (AMI)

An Amazon Machine Image (AMI) is what an EC2 instance boots from. It holds a snapshot of the root disk with the operating system and installed software. It also records the CPU architecture, the block device mapping and who may launch it. Every EC2 instance starts from an AMI, and so does every Amazon EKS worker node.

How it works

An AMI ID such as ami-0abc1234def567890 exists in one region only. Copying the image to another region with aws ec2 copy-image gives it a new ID. So an ID hardcoded for us-east-1 in Terraform fails in eu-west-1. An AMI never changes after it is built. Patching means baking a new image and launching new instances from it.

For Kubernetes nodes, AWS publishes EKS-optimized AMIs with containerd and the kubelet built in. New releases ship every few weeks with security patches. Rather than copy IDs around, you read the current one from a public SSM parameter:

aws ssm get-parameter --region us-east-1 \
  --name /aws/service/eks/optimized-ami/1.34/amazon-linux-2023/x86_64/standard/recommended/image_id \
  --query Parameter.Value --output

aws ssm get-parameter --region us-east-1 \
  --name /aws/service/eks/optimized-ami/1.34/amazon-linux-2023/x86_64/standard/recommended/image_id \
  --query Parameter.Value --output

aws ssm get-parameter --region us-east-1 \
  --name /aws/service/eks/optimized-ami/1.34/amazon-linux-2023/x86_64/standard/recommended/image_id \
  --query Parameter.Value --output

aws ssm get-parameter --region us-east-1 \
  --name /aws/service/eks/optimized-ami/1.34/amazon-linux-2023/x86_64/standard/recommended/image_id \
  --query Parameter.Value --output

aws ssm get-parameter --region us-east-1 \
  --name /aws/service/eks/optimized-ami/1.34/amazon-linux-2023/x86_64/standard/recommended/image_id \
  --query Parameter.Value --output

The same name returns a newer ID after each release. Karpenter's al2023@latest alias resolves the same way. Your container images then run on top of whatever node image this picks.

One2N's post on Karpenter AMI drift shows where this bites. A protected NodePool runs CI runners and monitoring, with a disruption budget of nodes: "0" for drifted nodes. On April 20 Karpenter launches a node on AMI v20251209, which carries kubelet v1.34.2.

On June 5 the team changes the EC2NodeClass from the pinned v20251209 to latest, which now means v20260526 with kubelet v1.34.8. A minute later Karpenter marks the NodeClaim as drifted, reason AMIDrift. The budget allows zero replacements, so the node stays on the old image. No alert fires. Every later release repeats the cycle and widens the gap.

The post lists the ways out. Keep the version pinned and bump it in a pull request. Or allow one drifted replacement during a weekly window such as 0 2 * * MON. Or allow one replacement at any time. Using latest with a zero budget is safe only if someone watches for drift.

Why it matters in production

The AMI is where kernel, containerd and kubelet patches reach your nodes. A node that never gets replaced keeps the CVEs (publicly listed vulnerabilities) of the day it booted, while its config says "latest". That is configuration drift that no dashboard shows by default. Compare the AMI IDs your running nodes use against the current SSM parameter, and alert when they differ for longer than your patch window.

See also

On the One2N blog

References

  1. Amazon EC2 User Guide: Amazon Machine Images in Amazon EC2

  2. Amazon EKS User Guide: Retrieve recommended Amazon Linux AMI IDs

State diagram of an EC2 node and its Amazon Machine Image (AMI). On Apr 20 a node boots on AMI v20251209 with kubelet 1.34.2. On Jun 5 the pin is changed to latest, now v20260526, and Karpenter marks the node drifted with reason AMIDrift. The step to a replacement on v20260526 with kubelet 1.34.8 is crossed out in red: the disruption budget is 0 nodes, so it is never replaced and no alert fires.