How to create and connect to a Windows EC2 instance in AWS
Tags: aws, cloud
Published: 2023-04-06 14:33:53

In this post, I will be taking us through how to create and connect to a windows EC2 instance in AWS.
We first have to create an AWS account and connect to the AWS console. You can create an AWS account using [this link](https//:aws.amazon.com)

**Launching and configuring the instance**
Navigate to the EC2 console and click on launch new instance. Follow the following steps to setup your instance.

Enter a name for your instance
![Selection of instance name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smgb5w64izz9cyav4ejm.png)

Under select amazon machine image(AMI) select microsoft windows instance, it has a free tier eligible version
![Selection of AMI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b583g6795t1qgbofo0vk.png)

You can choose to create a new key pair if you do not already have one. please note that you will not be able to connect to the windows instance using the remote desktop protocol(RDP) if you choose to continue without a key pair
![Creation of keypair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oo5gwtmo4a4il09xd6mj.png)

Under network setting, make sure that your instance security group allows RDS traffic as it would be impossible to connect to the instance using RDS if the security group rules are not updated
![Network and security group setting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7oejsxlre9hngnamnme3.png)

Leave the other settings as default and proceed to create your instance. Once your instance has been provisioned, wait for it to be in a running state. 

**Connecting to the instance**
We will now try to connect to our instance. Select your instance and click on the connect bottom located at the top of the screen
![Instance information](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rzdebq4x6v0wo38oykmb.png)

Select remote desktop protocol as your mode for connecting to the instance. Download your remote desktop file and select get windows password
![Connecting to instance using RDP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/buk5pq16j2loma0soxs8.png)

This will direct you to a new window where you will upload the pem file that was downloaded to your local computer when you created a new keypair. After uploading your file, click on decrypt password 
![Decrypting image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytmtn6knqn0fxu7nrz8r.png)

This will take you back to the previous page but your password would have been decrypted
![Showing decrypted password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxpmgumtsxw2cugcwc8m.png)

Open the RDP file you downloaded to your system, this will prompt you to enter your password so that you can connect to your windows instance
![Connecting to windows instance prompt from RDP file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a51e3cu6x67iojduomw8.png)

You might get a pop-up that the security certificate is not trusted. Agree to connect despite the unknown security certificate
![Certificate not trusted pop-up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y12upd3g2ixqzhu1jh9f.png)

This will start the connection process and you should soon be connected to your instance as shown below
![Connected to instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t4dqnbj8ekfbb6yle0ow.png)

**Cleaning up resources**
It is always best practice to clean up resources not currently in use to reduce costs. After disconnecting from your instance, navigate to the EC2 dashboard on your AWS console and select running instances. Click on terminate instance from the instance actions dropdown.
![Termination and cleaning up of resources](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbdhy3cq0yzoqe6ua0t4.png)