amazon-ebs: log state details on change

This commit is contained in:
Aleksandr Serbin 2020-10-31 16:00:19 +01:00
parent a64d3baf8e
commit 4669c0f852
1 changed files with 10 additions and 0 deletions

View File

@ -245,6 +245,16 @@ func (s *StepRunSourceInstance) Run(ctx context.Context, state multistep.StateBa
err := fmt.Errorf("Error waiting for instance (%s) to become ready: %s", instanceId, err)
state.Put("error", err)
ui.Error(err.Error())
// try to get some context from AWS on why was instance
// transitioned to the unexpected state
if resp, e := ec2conn.DescribeInstances(describeInstance); e == nil {
if len(resp.Reservations) > 0 && len(resp.Reservations[0].Instances) > 0 {
instance := resp.Reservations[0].Instances[0]
ui.Error(fmt.Sprintf("Instance state change details: %s: %s",
*instance.StateTransitionReason, *instance.StateReason.Message))
}
}
return multistep.ActionHalt
}