How to Setup A Windows Virtual Machine using AWS Management Console
Tags: devops, cloud, aws, virtualmachine
Published: 2023-04-08 09:22:13

Setting up a virtual machine is one of the first skills learned when learning about the cloud. It is very important as it is the foundation of cloud computing. A virtual machine or server is usually referred to as an instance and they are used interchangeably. **Amazon Elastic Compute Cloud (EC2)** is the service which provides scalable computing capacity in the **Amazon Web Services (AWS)** Cloud. Amazon EC2 is used to launch as many or as few virtual servers as needed, configure security and networking, and manage storage.

**Prerequisites:** You should have an AWS account or register [here](https://portal.aws.amazon.com/billing/signup) to create an account.


## Launching An Instance

1. When signed in to the AWS console, search and select EC2. 
![AWS Management Console Search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d82o1tj6n9isl5pctuao.png)

2. From the EC2 console dashboard, select the **Launch Instance** from the Launch Instance Dropdown to create a virtual server.
![AWS EC2 Console Dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d0vonhd175c0re5hcbrb.png)

3. Enter a descriptive name for the instance.
![Launching an instance - Name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbwkm6ql6efra4480dsk.png)

4. Under **Application and OS Images (Amazon Machine Image)**, select Windows as this is the desired operating system (OS) we are setting up for the instance.
For the **Amazon Machine Image (AMI)**, we can stick with the default which is Free tier eligible. An Amazon Machine Image (AMI) is a basic configuration that serves as a template for the instance.
![Launching an instance - Application and OS Images](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b99j2y0bbkusl0c9rfn9.png)

5. The **instance type** is usually used to set the hardware configurations of the instance such as storage capacity, storage type(ssd or hdd), CPU, memory or network performance. We would just leave this as default.
![Launching an instance - Instance Type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uq2a3xlvkleei2a9n5bj.png)

6. Under **Key pair**, create a key pair or use a previously created one. This allows a secure connection to the instance and is a step that should not be skipped as one would not be able to connect to the instance without it. A file gets downloaded on creation of the key pair.
![Launching an instance - Key pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/82426i7woj4e28pcm01q.png)

7. Keep the default selections for other configurations, review the summary of the configurations and launch the instance.

8. Once successfully launched, we are able to see it running on the EC2 dashboard. More information of the instance can be viewed by clicking it.
![AWS EC2 Instance Running](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxswd5u7rqjfojive26o.png)


## Connecting to the Launched Instance

1. Select the instance and click the **connect** button
![Connecting to an Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/le57kb3lup7vliv1u481.png)

2. Navigate to the **RDP Client tab** and download Remote desktop file.
![Connecting to an Instance using the RDP Client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wdlwphh614n1modtji6l.png)

3. **Generate password** by uploading the key pair file and decrypt password. Copy the generated password as this password would be used to connect with the remote client.
![Generating Password using Key Pair file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pnj3kvg45n9fggahsshh.png)

4. Open the Remote Desktop file with a suitable application. I used the Microsoft Remote Desktop App from App Store. Enter the password generated in step 3 and the virtual instance is started.
![Entering password to connect to Remote Desktop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hnnp2d0b5ubvotgczq4t.png)

On getting this prompt, click continue
![RDP Connection Prompt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa8eneb1owe734g31xi4.png)
![AWS Windows Virtual Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ft4uiyqqk9kx4uekhoac.png)
![AWS Windows Virtual Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/joqai5cuyk1ounrpi1kl.png)

Feel free to also perform some actions. I browsed and also confirmed the storage was 30gb.
![Browsing in the Virtual Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0b9ex2o8co1v1zbgok30.png)
![Storage of Virtual Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0j4xxldm4p7shz7hndd.png)


## Terminating the Instance

Once done with an instance, it should be terminated as resources not needed should not be left running as it incurs costs.

1. Select the instance and Choose **Terminate instance** in the **Instance state** dropdown.
![AWS EC2 Instance termination](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oi7mufnhuya5sttw01xw.png)

2. Choose **Terminate** when prompted for confirmation.
![Modal to Confirm AWS EC2 Instance termination](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ysve1xcyu3qzbtkk047.png)
![Instance showing terminated state](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hl7n9w3ysxix2oj7jb61.png)

After the instance is terminated, it remains visible on the console for a short while before being removed from the console.