Skip to content

Commit

Permalink
Print error info when a stack action fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ipmb committed Nov 8, 2021
1 parent 2d236de commit 8a4e773
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,10 @@ var pipelineCmd = &cobra.Command{
},
}

// stackHasFailure is used to track the first occurrence of a failure while waiting for a Cloudformation stack
var stackHasFailure = false

// waitForCloudformationStack displays the progress of a Stack while it waits for it to complete
func waitForCloudformationStack(cfnSvc *cloudformation.CloudFormation, stackName string) (*cloudformation.Stack, error) {
startSpinner()
stackDesc, err := cfnSvc.DescribeStacks(&cloudformation.DescribeStacksInput{
Expand Down Expand Up @@ -1007,6 +1011,14 @@ func waitForCloudformationStack(cfnSvc *cloudformation.CloudFormation, stackName
for _, resource := range stackresources.StackResources {
// CREATE_IN_PROGRESS | CREATE_FAILED | CREATE_COMPLETE | DELETE_IN_PROGRESS | DELETE_FAILED | DELETE_COMPLETE | DELETE_SKIPPED | UPDATE_IN_PROGRESS | UPDATE_FAILED | UPDATE_COMPLETE | IMPORT_FAILED | IMPORT_COMPLETE | IMPORT_IN_PROGRESS | IMPORT_ROLLBACK_IN_PROGRESS | IMPORT_ROLLBACK_FAILED | IMPORT_ROLLBACK_COMPLETE
if strings.HasSuffix(*resource.ResourceStatus, "_FAILED") {
// only warn on the first failure
// failures will cascade and end up being extra noise
if !stackHasFailure {
Spinner.Stop()
printError(fmt.Sprintf("%s failed: %s", *resource.LogicalResourceId, *resource.ResourceStatusReason))
startSpinner()
stackHasFailure = true
}
failed = append(failed, *resource.ResourceStatus)
} else if strings.HasSuffix(*resource.ResourceStatus, "_IN_PROGRESS") {
inProgress = append(inProgress, *resource.ResourceStatus)
Expand Down

0 comments on commit 8a4e773

Please sign in to comment.