func displayProgress(stack string, CloudFormation *cloudformation.CloudFormation, isDeleting bool) error { res, err := CloudFormation.DescribeStackEvents(&cloudformation.DescribeStackEventsInput{ StackName: aws.String(stack), }) if err != nil { return err } for _, event := range res.StackEvents { if events[*event.EventID] == true { continue } events[*event.EventID] = true name := friendlyName(*event.ResourceType) if name == "" { continue } switch *event.ResourceStatus { case "CREATE_IN_PROGRESS": case "CREATE_COMPLETE": if !isDeleting { id := *event.PhysicalResourceID if strings.HasPrefix(id, "arn:") { id = *event.LogicalResourceID } fmt.Printf("Created %s: %s\n", name, id) } case "CREATE_FAILED": return fmt.Errorf("stack creation failed") case "DELETE_IN_PROGRESS": case "DELETE_COMPLETE": id := *event.PhysicalResourceID if strings.HasPrefix(id, "arn:") { id = *event.LogicalResourceID } fmt.Printf("Deleted %s: %s\n", name, id) case "DELETE_FAILED": return fmt.Errorf("stack deletion failed") case "UPDATE_IN_PROGRESS", "UPDATE_COMPLETE", "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS", "UPDATE_FAILED", "UPDATE_ROLLBACK_IN_PROGRESS", "UPDATE_ROLLBACK_COMPLETE", "UPDATE_ROLLBACK_FAILED": default: return fmt.Errorf("Unhandled status: %s\n", *event.ResourceStatus) } } return nil }