From da771c469ead683e64fd31241cb59d35c1846969 Mon Sep 17 00:00:00 2001 From: Adrian Bridgett Date: Tue, 6 Oct 2015 22:13:17 +0100 Subject: [PATCH 1/2] spot_price of "0" to mean on demand this helps avoid duplicating packer templates just to select spot instances or not --- builder/amazon/common/step_run_source_instance.go | 2 +- website/source/docs/builders/amazon-ebs.html.markdown | 3 ++- website/source/docs/builders/amazon-instance.html.markdown | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index be4120c19..ae8960268 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -135,7 +135,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi var instanceId string - if spotPrice == "" { + if spotPrice == "" || spotPrice == "0" { runOpts := &ec2.RunInstancesInput{ KeyName: &keyName, ImageId: &s.SourceAMI, diff --git a/website/source/docs/builders/amazon-ebs.html.markdown b/website/source/docs/builders/amazon-ebs.html.markdown index f97404d19..5b48b8a67 100644 --- a/website/source/docs/builders/amazon-ebs.html.markdown +++ b/website/source/docs/builders/amazon-ebs.html.markdown @@ -150,7 +150,8 @@ builder. when the current spot price is less than the maximum price you specify. Spot price will be updated based on available spot instance capacity and current spot instance requests. It may save you some costs. You can set this to - "auto" for Packer to automatically discover the best spot price. + "auto" for Packer to automatically discover the best spot price or to "0" + to use an on demand instance (default). - `spot_price_auto_product` (string) - Required if `spot_price` is set to "auto". This tells Packer what sort of AMI you're launching to find the diff --git a/website/source/docs/builders/amazon-instance.html.markdown b/website/source/docs/builders/amazon-instance.html.markdown index 13ab1f293..726a5c4f4 100644 --- a/website/source/docs/builders/amazon-instance.html.markdown +++ b/website/source/docs/builders/amazon-instance.html.markdown @@ -191,7 +191,8 @@ builder. maximum price that you specify exceeds the current spot price. Spot price will be updated based on available spot instance capacity and current spot Instance requests. It may save you some costs. You can set this to "auto" - for Packer to automatically discover the best spot price. + for Packer to automatically discover the best spot price or to "0" to use + an on demand instance (default). - `spot_price_auto_product` (string) - Required if `spot_price` is set to "auto". This tells Packer what sort of AMI you're launching to find the From 3257b26fa773cd2df5de3e23279e62f59781786b Mon Sep 17 00:00:00 2001 From: Adrian Bridgett Date: Mon, 26 Oct 2015 10:20:49 +0000 Subject: [PATCH 2/2] one more place to check SpotPrice --- builder/amazon/ebs/step_stop_instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builder/amazon/ebs/step_stop_instance.go b/builder/amazon/ebs/step_stop_instance.go index 77bcd2d7b..d6f135368 100644 --- a/builder/amazon/ebs/step_stop_instance.go +++ b/builder/amazon/ebs/step_stop_instance.go @@ -19,7 +19,7 @@ func (s *stepStopInstance) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) // Skip when it is a spot instance - if s.SpotPrice != "" { + if s.SpotPrice != "" && s.SpotPrice != "0" { return multistep.ActionContinue }