Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aws_workspaces_workspace] Add Failed Request Error Code Along With Message #16459

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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