fix bug in step_region_copy

This commit is contained in:
Megan Marsh 2019-11-14 16:12:39 -08:00 committed by Adrien Delorme
parent 261331ee2d
commit a35ac0127e
1 changed files with 10 additions and 6 deletions

View File

@ -66,15 +66,19 @@ func (s *stepCreateAMI) Run(ctx context.Context, state multistep.StateBag) multi
ui.Say("Waiting for AMI to become ready...")
if err := awscommon.WaitUntilAMIAvailable(ctx, ec2conn, *createResp.ImageId); err != nil {
log.Printf("Error waiting for AMI: %s", err)
imagesResp, err := ec2conn.DescribeImages(&ec2.DescribeImagesInput{ImageIds: []*string{createResp.ImageId}})
if err != nil {
imagesResp, imerr := ec2conn.DescribeImages(&ec2.DescribeImagesInput{ImageIds: []*string{createResp.ImageId}})
if imerr != nil {
log.Printf("Unable to determine reason waiting for AMI failed: %s", err)
err = fmt.Errorf("Unknown error waiting for AMI.")
err = fmt.Errorf("Unknown error waiting for AMI; %s", err)
} else {
stateReason := imagesResp.Images[0].StateReason
err = fmt.Errorf("Error waiting for AMI. Reason: %s", stateReason)
if imagesResp != nil && len(imagesResp.Images) > 0 {
image := imagesResp.Images[0]
if image != nil {
stateReason := image.StateReason
err = fmt.Errorf("Error waiting for AMI. Reason: %s", stateReason)
}
}
}
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt