Deploy Amazon Workspaces using Service Catalog
Tags: aws, automation, workspaces
Published: 2023-06-15 20:29:22

In this post we are going to discuss about Amazon Workspaces and how you can automate the deployment.

But first let's have a brief introduction about that service.

**Amazon WorkSpaces** is a cloud-based virtual desktop service that allows you to provision virtual desktops in the cloud and access them from anywhere. It provides a fully managed, secure, and scalable desktop computing environment without the need for you to manage any hardware or software and you can access the desktop from any supported device.


## WorkSpaces requirements
In order to deploy Amazon Workspaces a few things need to be in place.
* **Active Directory** to authenticate users and provide access to their WorkSpace. This can be AWS Managed Microsoft AD or On-premises AD. Or you can use an AWS AD Connector that will act as a proxy service for an existing Active Directory. If you're using AWS Managed Microsoft AD or Simple AD, your directory can be in a dedicated private subnet, as long as the directory has access to the VPC where the WorkSpaces are located.
(To allow WorkSpaces to use an existing AWS Directory Service, you must first register it with WorkSpaces. After you register a directory, you can start launching WorkSpaces.)
* **VPC** You’ll need a minimum of two subnets for an Amazon WorkSpaces deployment because each AWS Directory Service construct requires two subnets in a multi-AZ deployment.

For more details about the requirements and deployments scenarios, you may refer to this link:
> [Best Practices for Deploying Amazon WorkSpaces] (https://docs.aws.amazon.com/whitepapers/latest/best-practices-deploying-amazon-workspaces/best-practices-deploying-amazon-workspaces.html)

## Assumptions
In this guide we are going to focus on Automating the Workspaces deployment and AD configuration is out of scope. We are going to consider that AD and users are already configured.

## Directory Registration
The first step is to register the Directory in Amazon Workspaces.
In the AWS Console click on **Workspaces** and then Directories, on the left.
Select your Directory, Click on Actions and then Register

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i5p3cuj0qelx0tppjstu.png)

Now, you have to select 2 subnets in your Workspaces VPC and click on Register again.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xj3hzgz14lonbnym46ai.png)
The Directory Registration process has begun and few minutes later the Registered status will be shown as True.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oii0bb5nt7ywiqbjj3pt.png)

## Service Catalog Configuration

Clone the following Github repo to your PC.
[Amazon Workspaces](https://github.com/nikitasg/Amazon-workspaces).
It contains 2 files:
1. workspaces.yaml
2. sc-workspaces.yaml


* Update the required values in workspaces.yaml _(pDirectory, pUsername, pEncryptionKey, pWorkstationType)_
and then upload it, in your artefacts bucket (or a S3 bucket of your choice)
* Update sc-workspaces.yaml with the S3 URL for that file
* In AWS console, navigate to Cloudformation and deploy sc-workspaces.yaml

When deployment is complete, you are going to have a new Portfolio and Product in the Service Catalog.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmsaiqjbqgopkdgcufkn.png)

![Service Catalog Portfolio](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9p8iyoh3bmqca9kqhil6.png)

## Workspaces Deployment

Now you are ready to deploy your first Workspace by using SC.
Under Products, select Workspaces and lick on Launch Product
![Service Catalog Workspaces Product](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xl4fqsyebf0vwhznc2wu.png)

Select your product version _(There will be just one. More will be visible if you update the CF template in the future)_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sq75rl70ohp841j0k4e0.png)
Fill any required values and click Launch Product
(In **WorkSpace User** field enter the AD username of the Workspace owner. That user must exist in AD)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7eli9vbmgel1wfoqrjy9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wapzymvac9bmuz8ui4u.png)

In the next screen you can now see that Service catalog has started provisioning your Workspace.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lgiesakl3m6sva4k03fw.png)

You can also check the progress in Cloudformation
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5ufiz87qe5wm1107zp2.png)

Wait for a few minutes and then in AWS Console, click on Workspaces. Your newly provisioned workspace will now be visible

![Amazon Workspaces](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/erz6op4iayu1zy2rytp5.png)

Click on the workspace to view it's details and take a note of the Registration Code, as you are going to need it at the next step
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q2og5ltjs8oxeziam5c.png)

## Connect to your Workspace
* Download the [Amazon Workspaces Client](https://clients.amazonworkspaces.com/)
* Run the client, enter the Registration Code and click Continue
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tv8oxelstx1lql3d6cee.png)

Now enter the AD Username and Password and click on Sign In
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cal0wyz0mtub4tddgfve.png)

You have now successfully logged in your Amazon Workspace
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjy9kvlj1c5ltdyxh5ci.png)

## Terminate your Workspace
* In Service Catalog click on Provisioned Products.
* Select the Workspace that you want to Terminate
* Click on Actions and select Terminate

![Terminate Amazon Workspaces](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/woee60lf0y83rt7f7h3l.png)