Packer: Building AMIs Runbook - Enterprise-CMCS/eAPD GitHub Wiki
Using Packer to Build AMIs
Packer is a command line tool created by Hashicorp to build images. Download it, add it to your shell, and run it like any other *nix command. eAPD uses it to take the Gold image provided by CMS and enrich it with the dependencies needed to make the Golden Image an eAPD image. We use Packer to create a Preview AMI, a Staging/Production (Backend) AMI, and Mongo AMIs. Running packer requires 3 files; a Packer definition file (.pkr.hcl), a script (.sh), and a var file (.hcl).
Download and Install Packer
Packer is a command line tool, download it, add it to your shell, and then can run commands like you would *nix commands.
https://learn.hashicorp.com/tutorials/packer/get-started-install-cli
Running Packer/Building AMIs
Using a CLI/terminal program navigate to the the "packer" directory in the eAPD GitHub Repo run these commands to build AMIs
Preview AMI
packer build -var-file="/path/to/app-preview.hcl" preview-ami.pkr.hcl
Backend AMI (Staging/Production)
packer build backend-ami.pkr.hcl -var-file="/path/to/backend.hcl" backend-ami.pkr.hcl
Mongo Staging AMI
packer build -var-file="/path/to/mongo-staging.hcl" mongo-ami.pkr.hcl
Mongo Production AMI
packer build -var-file="/path/to/mongo-prod.hcl" mongo-ami.pkr.hcl
Variable values can be found in Keybase in the "infrastructureascode/packer" directory