mitchellh/packer — pull request #1139 by henrysher (2014-05-07 17:24:37+00:00)
Title: Add the support of launching spot instances in "amazon-ebs" AMI

Hi,

It is working on the support of launching spot instances in "amazon-ebs" AMI.
Current solution is to patch on "step_run_source_instance" and "step_stop_instance" if "spot_price" is defined in the user configuration.
1. "step_run_source_instance" would call "RequestSpotInstances" and "DescribeSpotRequests" APIs from **goamz** (also patched) to wait for the spot request switching from "open" to "active" (a new func added to check spot request status). Then everything goes as the previous steps.
1. "step_stop_instance" would skip to stop the instance as spot instance does NOT support that operation.

I have tested both in the on-demand and spot instance launching. It works well.
The potential issue would be:
1. when any interrupt in the "spot request", the cleanup of "spot request" is not ready now.
1. it is better to check the "spot_price" in the "builder" initialization, so it is easy to seperate "on-demand" and "spot" instance launching in two different ways at the beginning.

Please help review.

Thanks
Henry