Opscraft
Infrastructure as code

Image building with Packer

New5 lessons · 19 min · 3 tests ·

Every EC2 instance, EKS node and autoscaled server starts from a machine image. Teams that build those images themselves, patched, hardened and tested, ship faster and more safely than teams that configure servers after they boot. Packer is the standard tool for this, and "how do you patch 300 servers?" is a common interview question whose best answer is "we don't; we build a new image and replace them". This topic covers why to bake images, how Packer templates work, how to build good images, and how to run an image pipeline from build to rollout and clean-up.

Stage 2 · Core tools

Know these first

After this topic you can

  • Explain golden images and when to bake or configure at boot
  • Build, test and scan AMIs with Packer in a pipeline
  • Roll new images out to Auto Scaling groups and EKS nodes safely

Lessons

  1. 1Why build images 3 min read
    • Golden images and immutable infrastructure
    • Bake versus fry
    • Where images are used
  2. 2Packer basics 4 min read
    • Template structure
    • The workflow and what amazon-ebs does
  3. 3Building good images 4 min read
    • Hardening and clean-up
    • Testing and scanning
    • Speed and reproducibility
  4. 4Pipelines and rollout 5 min read
    • An image pipeline
    • Rolling out a new image
    • Lifecycle and alternatives
  5. 5Interview questions and model answers 3 min read
    • "How do you patch 300 EC2 instances?"
    • "Bake or fry?"
    • "Walk me through what Packer does when building an AMI."
    • "What do you clean up before creating an image?"
    • "How do other accounts use your AMIs?"
    • "How do you roll a new AMI out to EKS nodes?"
    • "Packer or EC2 Image Builder?"