To run this demo:
-
Install Packer. (see our installation guide for details, if you need them).
-
Add valid AWS credentials to your environment:
export AWS_ACCESS_KEY_ID=<YOUR KEY HERE>
andexport AWS_SECRET_ACCESS_KEY=<YOUR KEY HERE>
.
Once you've exported those credentials, save the above file and run:
packer build packer_demo.json
This demo grabs a basic ubuntu image from the AWS marketplace, provided by Cannonical (the makers of ubuntu) It uses the ubuntu package manager (apt) to install a silly program called cowsay.
Finally, it uses cowsay to print "packer!!" in a speech bubble from a cow:
amazon-ebs: __________
amazon-ebs: < packer!! >
amazon-ebs: ----------
amazon-ebs: \ ^__^
amazon-ebs: \ (oo)\_______
amazon-ebs: (__)\ )\/\
amazon-ebs: ||----w |
amazon-ebs: || ||
It saves the image, which now has cowsay installed, as a new AMI, and deletes the instance it launched to create that image. If you navigate to your AWS EC2 console, you will be able to see the AMI, whose name will be "packer-cowsay-example-" followed by the epoch time.