A Beginner's Guide to Creating a Virtual Machine (EC2) in AWS.
Tags: scacloudschool, aws, beginners
Published: 2023-04-08 09:01:26

I recently got into the shecode africa cloud school and it's been exciting. Our first take home task was to create a virtual machine in AWS. 

According to AWS; Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. 

Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.

Amazon EC2 provides Virtual computing environments (vm), known as instances.

In this tutorial, I'll be discussing the following:

- How To Create an EC2 Instance
- Connecting the Instance. 
- Stopping the EC2 Instance.

_**Note: I use a windows 11 operating system on a hp probook. **_

## How To Create an EC2 Instance.

Step 1. Log into your AWS Console. If you don't have an account, create a free AWS account [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). 

Step 2.
Once on your dashboard search for EC2 or click on it

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

Step 3.
On your dashboard you'll see the resources tab, that kinda serves as a status bar. Click on Launch Instance to create a new instance.

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

Step 4: Choose a name for the instance you want to create.

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

Step 5: Time to pick your AMI (Amazon Machine Image). This contains operating systems (Ubuntu, Windows, Mac etc). I am creating a vm on Windows 11, so, select Microsoft Windows.

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

Step 6: Scroll down to create a unique key pair for your instance. Click on Create new key pair. Select the .pem file, then click on Create Key Pair. The Key Pair will be created and automatically downloaded.
 
Step 7: Click Launch instance and you will get a notification that your instance has been launched successfully.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ofxzclrxma9je095kwm.png)


**Connecting the Instance.**

- Go back to your instances tab. Click on it and select Connect at the top corner right of the screen.

- Connect using RDP. Download the Remote Desktop File (RDP File).  Now, click on get password.

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

- Generate password by uploading the key pair file and decrypt password. Copy the generated password and other details.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzpmm4jjq20trae1byfd.png)

- Open the Remote Desktop file and paste the generated password upon request

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3gh9g8mt5duiu1r2av89.png)
 
**Stopping the EC2 Instance.**
To avoid unneccesray bills and charges. You definitely need to terminate the running instance

Select the running instance and click “Instance State” From the drop down options, choose terminate instance.

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

The end.