HashiCorp Packer

February 2, 2025 ยท View on GitHub

https://www.packer.io/

Packer is a tool for automating building virtual machines templates such as importable .ova files.

This usually involves running automated installers that are native to each Linux distribution such as:

Packer can be used to create AMI + Vagrant box at same time.

Configs

See HariSekhon/Packer repo.

Readme Card

Convert an Old Packer JSON template to HCL

packer hcl2_upgrade "$file.json"

Output:

Successfully created "$file.json.pkr.hcl". Exit 0

Sharing AMIs Between AWS Accounts

Packer can build in your CI/CD AWS account, and then you can share to your other AWS Accounts from this central place.

See AWS - Sharing AMIs Between Accounts.

Troubleshooting

Debug Mode

PACKER_LOG=1 packer build "$file.pkr.hcl"