This folder contains a Packer template to demonstrate how you can use Terratest to write automated tests for your
Packer templates. The template creates an Ubuntu AMI with a simple web app (built on top of Ruby / Sinatra) installed.
This template also creates a Docker image with the same web app installed, and contains a docker-compose.yml
file
for running that Docker image. These allow you to test your Packer template completely locally, without having to
deploy to AWS.
Check out test/packer_docker_example_test.go to see how you can write automated tests for this simple template.
The Docker-based tests in this folder are in some sense "unit tests" for the Packer template. To see an example of "integration tests" that deploy the AMI to AWS, check out the terraform-packer-example.
- Install Packer and make sure it's on your
PATH
. - Install Docker and make sure it's on your
PATH
. - Run
packer build -only=ubuntu-docker build.json
. - Run
docker-compose up
. - You should now be able to access the sample web app at http://localhost:8080
- Sign up for AWS.
- Configure your AWS credentials using one of the supported methods for AWS CLI
tools, such as setting the
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
environment variables. - Install Packer and make sure it's on your
PATH
. - Run
packer build -only=ubuntu-ami build.json
.