How do you build golden images with Packer?
IntermediateProductionPatching, Automation & Golden Images
Answer
source "amazon-ebs" "base" {
region = "ap-south-1"
instance_type = "t3.small"
ssh_username = "ubuntu"
ami_name = "base-ubuntu24-{{timestamp}}"
source_ami_filter {
filters = { name = "ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*" }
owners = ["099720109477"]
most_recent = true
}
}
build {
sources = ["source.amazon-ebs.base"]
provisioner "ansible" { playbook_file = "./harden.yml" }
}
packer init . && packer validate . && packer build .
Run it in CI on a schedule, then scan and test the result before promoting.
More on Patching, Automation & Golden Images
What does a good Linux patching strategy look like?BeginnerIn-place patching vs immutable image replacement: which do you prefer?IntermediateHow do you know whether a server needs a reboot after patching?BeginnerHow do you configure automatic security updates?BeginnerWhat is kernel live patching?IntermediateHow do you roll kernel updates across a 200-node fleet safely?Advanced