Creating a virtual machine with AWS
Tags: aws, virtualmachine, cloud, tutorial
Published: 2023-04-07 21:31:07

Creating a virtual machine on AWS is as simple as cutting a slice of birthday cake :). Whether you are a beginner or an expert in cloud computing and have difficulty in setting up a virtual machine in AWS, you can follow these simple steps: 

**1. Set up an account**
To set up an account head over to [AWS Free Cloud Computing Services](https://aws.amazon.com/free/?all-free-tier.sort-by=item.additionalFields.SortRank&all-free-tier.sort-order=asc&awsf.Free%20Tier%20Types=*all&awsf.Free%20Tier%20Categories=*all) and create an account if you do not have one.

![AWS Set up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qvrpz0ckbewc72omih5c.PNG)
You have to fill in the correct details, and also set up your card details so that you can be able to access all features of AWS. AWS will only hold $1 for you to be able to create a virtual machine so this is very important for you to note. 

**2. EC2 Services.**
Once you have completed your account setup, you can login as root user and you'll be directed to the console home. On the navigation bar, you will see a services icon and that will lead you to a sub menu where you can pick the compute section and see the EC2 service where we will be able to create virtual servers in the cloud.

![EC2 Services](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gma5dhd6hxlllh496oig.PNG)

**3. Creating an instance**
After successfully heading to the EC2 dashboard, you will be able to see and monitor all EC2 resources that are running on your account. To create an instance, on the side bar, you will select the instances option and click on the 'launch instance' button.

![EC2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfhrvruj6yoj071ej8rg.PNG)

After clicking the button you will be able to see the following page where you can choose the features of your instance. The first step is naming your instance and you have to make sure it is a unique name so that it will not be rejected.

![Name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9f6jqopr0b7lry4abzg.PNG)

Then you will have to select the operating system that you want your virtual machine to run on such as aws linux,mac os, ubuntu, windows, redhat etc., but for this instance let us go with windows.

![Operating System](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4fxxvfkmd92pu05su0eo.PNG)

After that you can select the instance type. There are many instance types you can choose from with different storage capacities and pricing but for this instance, we will go with the default one.

![Instance Type](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19lnre2x2w83tleg99nr.PNG)

The third step is choosing a key pair. If you do not have one you will have to create one so that it will be able to connect with the RDP. 

![Create Key pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3rfhnfmn3n38xf31vic.PNG)
Use the OpenSSH (pem) key for this instance for ease of use. Click on the create key pair button and this will automatically download a file that will be used later. 

![pem](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vy3yf2fkgo5twmt8bq8.PNG)
After successfully creating a key pair, you leave the rest as default and head over to the summary section to ensure you got all the details of your instance correctly. If the details are okay, you can click on the 'launch instance' button to create your instance.

![key pair](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lybvyb8gvus5zh96r2f.PNG)
A successful instance launch will prompt the message below.

![success instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5ctddnsjngpc7szgklq.PNG)
**4. Connecting to RDP**
To connect to an RDP, you will head over to the instances and select the instance that we created and click on the connect button that is right above it.
![connect](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q20i7k3us5ia5cwygpdh.PNG)

If you are connecting it using a windows machine, head over to the RDP Client section and select it. This will lead you to the RDP client settings and you will be able to get the password for it.
![rdp](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iei3xgsvipgha53adjlm.PNG)
We previously had a file that automatically downloaded when we created a key pair. We will upload that file private key file here. Decrypt the password and copy it for later use.

![decrypt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/as5wwhu3spvb65drcocj.PNG)

Now we can download the Remote desktop file and run it.

![remote desktop file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zpyc8g0v40tz34u4xuc.PNG)

A window pop up will show up and you will have to enter the password that you had copied earlier. 
![password](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qaydsjdx42qwwrd9lsf1.PNG)

Allow connections to the RDP and wait for the virtual machine to load. The following will show up after successful connection.

![virtual machine](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ur6l8pvpu3xldywpu3gi.PNG)

You have successfully created a virtual machine! Hurray!!

**4. Terminating an instance**

Remember that you have to terminate an instance in order to not accumulate charges on your account. To terminate your instance you select the instance and click on instant state as shown below. You will have a choice on which instant state you want and select terminate instance.

![Terminate Instance](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/408bdk6v1lmdhrsn4amn.PNG)

After selecting terminate instance a pop up window will appear asking you to confirm if you want to terminate the instance. Click terminate and proceed.


![terminate pop up](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ovjd1dt2lpbwcgoamao.PNG) 

You will see a message showing that you have successfully terminated the instance and therefore it is not running anymore and you will not accrue any charges on your account.


![success termination](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a1ka6xdsm91gb19gbmky.PNG)

You have finally learnt how to create a virtual machine in AWS. Great Job !!