fix nil pointer dereference

This commit is contained in:
Megan Marsh 2020-12-07 15:41:40 -08:00
parent 00c61f9987
commit 3c346867f4
1 changed files with 4 additions and 2 deletions

View File

@ -251,8 +251,10 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
if resp, e := ec2conn.DescribeInstances(describeInstance); e == nil { if resp, e := ec2conn.DescribeInstances(describeInstance); e == nil {
if len(resp.Reservations) > 0 && len(resp.Reservations[0].Instances) > 0 { if len(resp.Reservations) > 0 && len(resp.Reservations[0].Instances) > 0 {
instance := resp.Reservations[0].Instances[0] instance := resp.Reservations[0].Instances[0]
ui.Error(fmt.Sprintf("Instance state change details: %s: %s", if instance.StateTransitionReason != nil && instance.StateReason.Message != nil {
*instance.StateTransitionReason, *instance.StateReason.Message)) ui.Error(fmt.Sprintf("Instance state change details: %s: %s",
*instance.StateTransitionReason, *instance.StateReason.Message))
}
} }
} }
return multistep.ActionHalt return multistep.ActionHalt