Packer is a simple tool for building customized images. Building images manually is painstaking and error prone. By taking advantage of Packer automation, you can customize and build images in the same way each time and store this in source control.
- [Instructor] What is Packer? Packer is one of the suite of tools offered by HashiCorp. HashiCorp's tools have greatly changed the way we build infrastructure by bringing automation to areas of infrastructure that have previously been managed manually. Packer is just one of these tools. Packer does not need any of the other HashiCorp tools to operate. They all focus on a single area. Packer's focus is automation of image creation. This can be images both for use in the cloud or in on-prem, virtualized infrastructure. In this video, we'll be focusing on using Packer with AWS EC2.
Let's take the example of a basic website hosted on multiple EC2 instances. First, we'd select an AMI to launch, and this may be one of those provided by the operating system creators, such as Windows Server 2016 from Microsoft or Ubuntu 1604 from Canonical. These and many other images are made available to the public on Amazon's AMI Marketplace. We would launch that image and then configure it to our website's purposes. We'd install the tool, and we'd need to run it. So that would be maybe a language runtime, such as Node or Ruby or extra tools for monitoring and logging.
And after that we'd upload the website's code itself. The customization and tool installation is a standard step that we'd have across whatever web application code we installed. We can reduce deployment times and uncertainty by pre-installing this tooling and baking our own image. First, we would launch that basic image from the Marketplace, manually customize it by installing our tooling, shut it down, and take an image. We can then use that image to launch the EC2 instances and upload our application code onto it. Packer automates that customization and image creation process.
By automating it, we take away the manual, error-prone element, and replace it with a deterministic, repeatable process. We can also commit the Packer templates to source control, thereby giving us a historical log of changes and an ability to reproduce images created with previous versions of the template. We can further automate the Packer build by hooking it into a CI pipeline and building new images upon each template change. So Packer automates the creation of customized images in a repeatable manner.
- What is Packer?
- Baking a website image for EC2
- Provisioning with a configuration management tool
- Building hardened images
- Building a pipeline for Packer images