How to Create a Virtual Machine (EC2) in AWS on Windows 10
Published: 2023-04-07 15:52:40

AWS EC2 (Elastic Compute 2) is one of the numerous services run and offered by Amazon. It is an essential part of modern business operations. 

Whether you're here for some research, study or other purposes, this article will teach and show you how to create an Amazon Web Service (AWS) EC2 or a virtual machine on Microsoft Windows 10 and also how to terminate it to avoid unnecessary billing.

For better understanding, the article will be divided into three parts.

**Part A:** Creating an EC2 Instance
**Part B:** Connecting the Instance and
**Part C:** Terminating the EC2 Instance.

Let's head right in!

**Part A**
How to Create an EC2 Instance

Step 1. The first step before any other process is to create and Login to your AWS account. You can create a free one [here](https://aws.amazon.com/free/?trk=99f831a2-d162-429a-9a77-a89f6b3bd6cd&sc_channel=ps&ef_id=Cj0KCQjw_r6hBhDdARIsAMIDhV_w-SfhWOF6XM1iD4o5xFRChmqZ-b9Vg7n9fZhGsOJ3HkUINdSrt20aAl19EALw_wcB:G:s&s_kwcid=AL!4422!3!645125273267!e!!g!!aws%20free%20tier!19574556890!145779847112&all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all) if you do not already have an account and then follow the prompt.

Step 2. Navigate to the AWS Management Console or simply search for EC2 in the search bar and open the dashboard.

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

Step 3. The image below is what your dashboard should look like. You can see you have 0 instances running because you haven't created any. Now, click on Launch Instance.

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

Step 4: You need to choose a name for the instance you want to create. I chose mine as (Instance). You can pick your name or any other preferred word. Also, at the right hand side, you can choose the number of instances you want to create. Now, we are creating just 1.

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

Step 5: This step requires picking your AMI (Amazon Machine Image). This contains your operating system. (Linux, Ubuntu, Windows, Mac etc). We are creating a virtual machine on Windows 10, so, select Microsoft Windows.

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

Step 6: This is a very important step. You need to create a unique key pair for your instance. You will need this to login later on. Click on "Create new key pair"
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vydrnirt3jl2xu50xwjy.png)

Step 7: Choose a unique name for your key pair (A name that has not been used before). I chose mine as Vick. I also selected the .pem file because the .ppk file could not decrypt the password. Now, click on Create Key Pair.

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

Step 8: Here, the Key Pair has been created and automatically downloaded. (Take a look at the file highlighted in red below the screen)

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

Step 9: You will get a notification that your instance has been launched successfully.

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

**Note:** These are the necessary steps in this part. You can choose to configure other settings and the security group to your preference or just leave them as they are.

**Part B**
How to Connect an EC2 Instance

This part involves the necessary steps needed to connect your instance or virtual machine after it has been created.

Step 1: Go back to your instance. Click on it and select Connect at the top right of the screen. (Marked in red)

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

Step 2: Connect using RDP. Download the Remote Desktop File (RDP File). You should see it downloaded below your screen (Marked in red). Now, click on get password. 

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

Step 3: To get the login password, you need the key pair that was created when you launched your instance. Remember it was “Vick.pem”. Click on “upload private key pair”. Select the .pem file and open.

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


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

Step 4: The image below is what your private key contents should look like. It MUST begin with “——-BEGIN RSA PRIVATE KEY——-”. Then, click on Decrypt password.

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

Step 5: Now, these are your login details. The Public DNS, Username and password. Copy them out and save somewhere.

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

Step 6: Click on the RDP file that was downloaded. It is marked in red below the screen

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

Step 7: This is what your Remote Desktop Connection should look like. Click on connect

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

Step 8: Enter the password that you saved somewhere and click ok.

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

Step 9: Here we go! The virtual machine has been connected successfully. Click the “x” button to leave the interface.

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

**Part C**
How to Terminate an EC2 Instance

This part involves the steps needed to terminate the instance in order to avoid unnecessary billing.

Step 1: Go back to your EC2 Dashboard and click Instances. You should have 1 instance running now.

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

Step 2: Select the instance and click “Instance State”. (Marked in red). From the drop down options, choose terminate instance.

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

Step 3: Confirm you want to terminate.

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

Step 4: The instance status will change from “running” to “shutting down”.


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

Step 5: Now, the instance status will change again from “shutting down” to “terminated”.

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

Congratulations! You just created, connected and terminated an AWS EC2 or Virtual Machine on Windows 10. 

I hope this article was the perfect guide. I also hope it helped. Feel free to leave your questions and/or comments (if any). I'll be glad to help further.