Building an AMI with Packer
Packer is an open source tool from Hashicorp that automates the process of building system images. It works with all major cloud providers and helps author your golden images – templates for your virtual machines in the cloud. It also offers a multi-cloud workflow to define a blueprint for creating images across multiple providers, such as AWS and GCP. For the scope of this chapter, we will focus on creating an AWS-based AMI and starting an EC2 instance off of it.
Packer leverages a JSON template that defines all the configurations for creating your AWS image. Using the CLI, you can target a specific configuration that defines the steps to create an AMI in your AWS account. Once the execution completes, you can simply create an EC2 instance using this standardized template with all software dependencies baked in. Using pre-baked AMIs ensures a good security posture and avoids the need for any modifications post instance creation.
Let’...