Creating a GCP Workstation
Tags: workstations, googlecloud, developmentenvasacode, gcpworkstations
Published: 2023-06-25 12:14:46

**Background Info:**

For traditional application development, we have multiple IDE's available in the market like VS Code, IntelliJ, JetBrains etc. Developers install these IDEs in local machines and use them to write code, debug and run to check the previews/outputs. 

**DrawBacks:**

1. Not suitable when developer need high compute power
2. Issues with In-consistency b/w the developer environments
3. Takes much time to set-up the environment

**Context:**
As the technology grows, we can create cloud-based / remote development environments. In addition to the IaaC, PaaC, FaaC & etc services, we have one more new service called as "Development Environment As a Code" (DEaaC). This service is named as "Workstations" in GCP. In which one can get their development environment working setup instantly which will be in cloud not local. We can pre-configure the required IDEs/extensions/services/access in a docker image and can use that to create the workstations to increase the productivity of the developer.

Today, will configure workstation in GCP using different resources of terraform. 

## Steps:
1. Pre-requisites
2. Create a Workstation Cluster
3. Create a Workstation configuration
4. Create a Workstation
5. Access the workstation

**Pre-requisites:**
Assuming you've followed the post [here](https://dev.to/aravinddussani99/configure-terraform-with-gcp-557f) for the pre-requisites configuration.

**Create a Workstation Cluster:**

Use the `google_workstations_workstation_cluster` to create the workstation cluster. the cluster is depended on the VPC, subnets, make sure that you've created them.

![workstationcluster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i63t9k0mem6odg5vbkr8.png)



**Create a Workstation configuration:**

Use the `` to create the workstation configuration. This configuration is the main part of the workstations, as we can define what and all we required here only. We can use the default/custom docker images with the pre-configurable options and machine types with RAM, CPU processors and service accounts access.


![workstationconfig](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25cptf5s21ndhkwvo8ic.png)

**Create a Workstation:**

Finally, after all we create the workstation based on the previous cluster and config creations.

![workstation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fm29xm4h67r4gddrl2c9.png)



**Access the workstation:**

To access the workstation, user required at least the `roles/workstations.user` role. So to add the roles to workstations, will use the `google_workstations_workstation_iam_binding` resource as shown below.

![workstationrole](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4lu6u6u78f9ahioqiysz.png)

Once the workstation is provisioned, you can see something like below.

![workstationlist](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbefbryx8vvbvucqu7it.png)

Please click on "Start" and "Launch", there you can see multiple ways to access the workstation and will use this "Launch" or "Connect to Port 80" option to access the workstation IDE from browser.

![workstationlaunch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkoid10y580dk4h0b3a7.png)

**Resources- References:**
Google Documentation - https://cloud.google.com/workstations
workstation roles - https://cloud.google.com/workstations/docs/access-control
terraform resources - https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/workstations_workstation
Github: https://github.com/aravind-dussani99/google-workstation



**Final words:**

Feel free to comment your queries here or at [LinkedIn](https://www.linkedin.com/in/dussani-aravind-4858a7266/) . Thanks.