Build AWS Amazon Machine Image (AMI) with Packer
Make sure you do this setup first:
-
Install Packer via Homebrew:
# install brew tap hashicorp/tap brew install hashicorp/tap/packer # verify packer -help
Configure the project:
source configure.sh
Format configuration:
packer fmt .
Validate configuration:
packer validate .
packer build .
This script will launch an instance from the AMI and run tests on it:
./test.sh
Deregister the AMI image and delete ALL image snapshots.
./cleanup.sh
# create main.pkr.hcl
cat << 'EOF' > main.pkr.hcl
packer {
required_plugins {
amazon = {
version = ">= 1.2.8"
source = "github.com/hashicorp/amazon"
}
}
}
EOF
# initialize the project
packer init .