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

This commit is contained in:
Mitchell Hashimoto 2015-05-28 09:35:02 -07:00
commit 3031886aaf
1 changed files with 8 additions and 2 deletions

View File

@ -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
} }
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
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
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(),
}, },
}) })