don't error for no mappings if no mappings were set.

This commit is contained in:
Megan Marsh 2020-07-08 11:55:56 -07:00
parent 2322d3ae6b
commit a885e620ee
1 changed files with 4 additions and 2 deletions

View File

@ -324,8 +324,10 @@ func (s *StepRunSpotInstance) Run(ctx context.Context, state multistep.StateBag)
describeOutput, err = ec2conn.DescribeInstances(&ec2.DescribeInstancesInput{
InstanceIds: []*string{aws.String(instanceId)},
})
if len(describeOutput.Reservations) > 0 && len(describeOutput.Reservations[0].Instances) > 0 && len(describeOutput.Reservations[0].Instances[0].BlockDeviceMappings) == 0 {
return fmt.Errorf("Instance has no block devices")
if len(describeOutput.Reservations) > 0 && len(describeOutput.Reservations[0].Instances) > 0 {
if len(s.LaunchMappings.BuildEC2BlockDeviceMappings()) > 0 && len(describeOutput.Reservations[0].Instances[0].BlockDeviceMappings) == 0 {
return fmt.Errorf("Instance has no block devices")
}
}
return err
})