Finding Packer-generated AMIs automatically after builds
The basic technique is to have Packer add a tag with a unique value during the build, and use AWS' built-in filtering capabilities to find that specific AMI after the build finishes.
- template.json - Shows the settings that need to be added to your template
- build.sh - Shows how to use the template to do a build and retrieve the AMI information
Oops! Missed the
--raw-output
flag when I translated this from my overly-complicated build scripts to a gist. I've updated it now. Thanks for pointing that out.As for using a timestamp -- definitely works. We run this from inside Jenkins, though, so I needed to be able to guarantee that two builds wouldn't collide. Hence the UUID.