Packer templates are JSON documents that provide a declarative description that tells Packer how to build a machine image.
Packer templates are organized around four common top-level parameters, as demonstrated in the following example and described here:
- variables: An object that provides input variables for the build.
- builders: A list of Packer builders, which define the target machine image platform(s). In this chapter, you will be targeting a builder referred to as the EBS-backed AMI builder, which is the simplest and most popular builder for creating custom Amazon Machine Images. Builders are responsible for ensuring the correct image format and publishing the final image in a format suitable for deployment to the target machine platform.
- provisioners: A list or array of Packer provisioners, which perform various provisioning tasks as part of the image building process. The simplest provisioners include file and shell provisioners, which copy files into the image and perform shell tasks, such as installing packages.
- post-processors: A list or array of Packer post-processors, which perform post-processing tasks once the machine image has been built and published:
{
"variables": {},
"builders": [],
"provisioners": [],
"post-processors": []
}
Packer template structure