Skip to content

Commit

Permalink
Merge pull request #16459 from Tensho/workspaces-error-codes
Browse files Browse the repository at this point in the history
[aws_workspaces_workspace] Add Failed Request Error Code Along With Message
  • Loading branch information
breathingdust committed Dec 8, 2020
2 parents dbef45e + 5e22dfc commit c5a8e71
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions aws/resource_aws_workspaces_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func resourceAwsWorkspacesWorkspaceCreate(d *schema.ResourceData, meta interface

wsFail := resp.FailedRequests
if len(wsFail) > 0 {
return fmt.Errorf("workspace creation failed: %s", *wsFail[0].ErrorMessage)
return fmt.Errorf("workspace creation failed: %s: %s", aws.StringValue(wsFail[0].ErrorCode), aws.StringValue(wsFail[0].ErrorMessage))
}

workspaceID := aws.StringValue(resp.PendingRequests[0].WorkspaceId)
Expand Down Expand Up @@ -288,7 +288,7 @@ func resourceAwsWorkspacesWorkspaceDelete(d *schema.ResourceData, meta interface

func workspaceDelete(conn *workspaces.WorkSpaces, id string, timeout time.Duration) error {
log.Printf("[DEBUG] Terminating workspace %q", id)
_, err := conn.TerminateWorkspaces(&workspaces.TerminateWorkspacesInput{
resp, err := conn.TerminateWorkspaces(&workspaces.TerminateWorkspacesInput{
TerminateWorkspaceRequests: []*workspaces.TerminateRequest{
{
WorkspaceId: aws.String(id),
Expand All @@ -299,6 +299,11 @@ func workspaceDelete(conn *workspaces.WorkSpaces, id string, timeout time.Durati
return err
}

wsFail := resp.FailedRequests
if len(wsFail) > 0 {
return fmt.Errorf("workspace termination failed: %s: %s", aws.StringValue(wsFail[0].ErrorCode), aws.StringValue(wsFail[0].ErrorMessage))
}

log.Printf("[DEBUG] Waiting for workspace %q to be terminated", id)
_, err = waiter.WorkspaceTerminated(conn, id, timeout)
if err != nil {
Expand Down

0 comments on commit c5a8e71

Please sign in to comment.