HashiCorp Packer
Build automated, reproducible machine images with HashiCorp Packer. Author HCL2 templates to bake AMIs, Docker images, and GCP/Azure images with provisioners, variables, and post-processors for immutable infrastructure pipelines.
This skill helps you create golden images with HashiCorp Packer. It writes HCL2 templates with source and build blocks, configures builders for AWS AMIs, Docker, GCP, and Azure, runs shell/Ansible provisioners to install and harden the image, parameterizes builds with variables and locals, and wires post-processors and manifest output. It also covers parallel builds, base image selection, and integrating Packer into CI so infra is immutable and versioned.
When to use
Use when building machine images with HashiCorp Packer — HCL2 templates, AMI/Docker/GCP/Azure builders, provisioners, variables, or baking immutable golden images in CI.
Examples
Build a hardened AMI
Golden image with provisioners
Write a Packer HCL2 template that builds an Ubuntu 22.04 AMI in us-east-1, runs a shell provisioner to install Docker and apply CIS hardening, tags the image, and outputs a manifest
Multi-target build
One template, many builders
Create a Packer template with a shared provisioner that builds both a Docker image and an AWS AMI from the same source configuration using variables for the app version