Skip to content

Commit

Permalink
Fix SetId
Browse files Browse the repository at this point in the history
  • Loading branch information
Tensho committed Jul 9, 2020
1 parent 3bb8b5c commit 1beca9d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions aws/data_source_aws_workspaces_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,18 @@ func dataSourceAwsWorkspacesDirectoryRead(d *schema.ResourceData, meta interface
conn := meta.(*AWSClient).workspacesconn
ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig

rawOutput, state, err := waiter.DirectoryState(conn, d.Id())()
directoryID := d.Get("directory_id").(string)

rawOutput, state, err := waiter.DirectoryState(conn, directoryID)()
if err != nil {
return fmt.Errorf("error getting WorkSpaces Directory (%s): %s", d.Id(), err)
return fmt.Errorf("error getting WorkSpaces Directory (%s): %s", directoryID, err)
}
if state == workspaces.WorkspaceDirectoryStateDeregistered {
return fmt.Errorf("WorkSpaces directory %s was not found", d.Id())
return fmt.Errorf("WorkSpaces directory %s was not found", directoryID)
}

d.SetId(directoryID)

directory := rawOutput.(*workspaces.WorkspaceDirectory)
d.Set("directory_id", directory.DirectoryId)
d.Set("workspace_security_group_id", directory.WorkspaceSecurityGroupId)
Expand Down

0 comments on commit 1beca9d

Please sign in to comment.