Merge pull request #6217 from alessiot77/5887

Feature Request: Log reason why AMI creation failed
This commit is contained in:
Matthew Hooker 2018-05-03 10:57:46 -07:00 committed by GitHub
commit 7d5ebd5500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -53,6 +53,14 @@ func (s *stepCreateAMI) Run(_ context.Context, state multistep.StateBag) multist
ui.Say("Waiting for AMI to become ready...")
if _, err := awscommon.WaitForState(&stateChange); err != nil {
err := fmt.Errorf("Error waiting for AMI: %s", err)
imagesResp, err := ec2conn.DescribeImages(&ec2.DescribeImagesInput{ImageIds: []*string{createResp.ImageId}})
if err != nil {
stateReason := imagesResp.Images[0].StateReason.Message
if stateReason != nil {
err = fmt.Errorf("%s. Root cause: %s", err.Error(), *stateReason)
}
}
state.Put("error", err)
ui.Error(err.Error())
return multistep.ActionHalt