Merge pull request #6697 from hashicorp/fix_6696

spot instance creation, only set blockDurationMinutes when > 0
This commit is contained in:
Adrien Delorme 2018-09-12 10:31:28 -07:00 committed by GitHub
commit 70b0380558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -186,12 +186,15 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
if s.Comm.SSHKeyPairName != "" {
runOpts.KeyName = &s.Comm.SSHKeyPairName
}
spotInstanceInput := &ec2.RequestSpotInstancesInput{
LaunchSpecification: runOpts,
SpotPrice: &spotPrice,
}
if s.BlockDurationMinutes != 0 {
spotInstanceInput.BlockDurationMinutes = &s.BlockDurationMinutes
}
runSpotResp, err := ec2conn.RequestSpotInstances(&ec2.RequestSpotInstancesInput{
BlockDurationMinutes: &s.BlockDurationMinutes,
LaunchSpecification: runOpts,
SpotPrice: &spotPrice,
})
runSpotResp, err := ec2conn.RequestSpotInstances(spotInstanceInput)
if err != nil {
err := fmt.Errorf("Error launching source spot instance: %s", err)
state.Put("error", err)