'How do I create a user for a workspace in a single terraform project?

Setting up an AWS workspace using the Terraform aws_workspaces_workspace resource requires an aws_workspace_directory which then requires a aws_directory_service_directory, however it also requires a user with the correct username to be set up in the directory, and without it I'm getting this error:

Error: workspace creation failed: ResourceNotFound.User: The specified user could not be found in the directory.

How do I add the directory entry from my terraform code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source