Commit 3031886a authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

Merge branch 'master' of https://github.com/aocsolutions/packer into aocsolutions-master

parents 11e2fad6 6686b623
...@@ -79,6 +79,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -79,6 +79,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
} }
spotPrice := s.SpotPrice spotPrice := s.SpotPrice
availabilityZone := s.AvailabilityZone
if spotPrice == "auto" { if spotPrice == "auto" {
ui.Message(fmt.Sprintf( ui.Message(fmt.Sprintf(
"Finding spot price for %s %s...", "Finding spot price for %s %s...",
...@@ -109,6 +110,9 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -109,6 +110,9 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
} }
if price == 0 || current < price { if price == 0 || current < price {
price = current price = current
if s.AvailabilityZone == "" {
availabilityZone = history.AvailabilityZone
}
} }
} }
if price == 0 { if price == 0 {
...@@ -163,7 +167,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -163,7 +167,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
ui.Message(fmt.Sprintf( ui.Message(fmt.Sprintf(
"Requesting spot instance '%s' for: %s", "Requesting spot instance '%s' for: %s",
s.InstanceType, spotPrice)) s.InstanceType, spotPrice))
D
runSpotResp, err := ec2conn.RequestSpotInstances(&ec2.RequestSpotInstancesInput{ runSpotResp, err := ec2conn.RequestSpotInstances(&ec2.RequestSpotInstancesInput{
SpotPrice: &spotPrice, SpotPrice: &spotPrice,
LaunchSpecification: &ec2.RequestSpotLaunchSpecification{ LaunchSpecification: &ec2.RequestSpotLaunchSpecification{
...@@ -177,7 +181,9 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi ...@@ -177,7 +181,9 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{ NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{
&ec2.InstanceNetworkInterfaceSpecification{AssociatePublicIPAddress: &s.AssociatePublicIpAddress}, &ec2.InstanceNetworkInterfaceSpecification{AssociatePublicIPAddress: &s.AssociatePublicIpAddress},
}, },
Placement: &ec2.SpotPlacement{AvailabilityZone: &s.AvailabilityZone}, Placement: &ec2.SpotPlacement{
AvailabilityZone: &availabilityZone,
},
BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(), BlockDeviceMappings: s.BlockDevices.BuildLaunchDevices(),
}, },
}) })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment