DEV Community

Ajanaku Temitope Grace
Ajanaku Temitope Grace

Posted on

Creating a Virtual machine on AWS

As the name implies, this is a machine that cannot be seen; you can think of it as a digital computer. It can perform the same tasks as your physical computer, and much more. It can connect to networks, store data, and like your physical computer, it requires maintenance and updates.

There are several cloud platforms where you can create your virtual machine, and in this article, we will be focusing on creating a virtual machine on AWS using the following steps.

While you may see the term "Virtual Machine" on platforms like Azure, on AWS, you will see the term "instance". Don't worry, they mean the same thing.

Step 1: Setup your AWS Account.

While this is not a difficult process, you will be required to add a billing card to connect to Amazon Web Services. Amazon will hold on to $1 until the card is successfully verified. Access to Amazon Web Services will not be granted until a billing card has been added and verified. A virtual dollar card can be used for this purpose.

Step 2:

Congratulations on setting up your AWS account! We are now ready to create our first instance aka virtual machine

To create an instance, click on EC2 - Elastic Cloud Compute as seen in the attached image.

AWS EC2

You will be routed to the Elastic Cloud compute dashboard.

EC2 dashboard

If not already open, click on the instances drop down and select launch instances.

launch instance



Provide all the required details, including:

  • Instance name
  • Select your AMI - Amazon Machine Image. Note that this has nothing to do with your physical machine's operating system. For example, you could be using macOS but choose an Ubuntu AMI. If you're using a free AMI, make sure it is eligible for the free tier.
  • Key pair name - create one if you don't already have it. While this field is not required, it is important, and you will use it when connecting to your virtual machine. The key pair is downloaded as a file with a .pem extension.

  • Network settings - this is another crucial section. As a cloud engineer, you manage the server via SSH, so be sure to select "Allow SSH traffic from Anywhere" or your specified IP address. Users interact with your machine via HTTPS (Secure Hypertext Transfer Protocol), so to ensure that it is discoverable, select "HTTPS traffic from the internet."

  • Configure your storage.

  • You can launch multiple instances at once, so you have the option to input the number of instances you want to launch.

  • Confirm your details.

  • Launch your instance.

successful instance

Step 3: Connect your virtual machine

  • Route to your instances list and select the instance you want to connect
  • Click connect instance

connect your instance

We will be using SSH client to connect this on MacOS

  • Open your SSH client - you can use your terminal

  • Local your private key file - this is the key pair your created that got downloaded using this command cd downloads (downloads is my file path. Be sure to use yours)

  • Run this command chmod 400 teminstance.pem - A common mistake to avoid is using the wrong key pair file name. Be sure that is the right name in your file path.

  • Connect your virtual machine using its public DNS. Sample ssh -i "temiinstance.pem" ubuntu@ec2-54-222-141-75.compute-1.amazonaws.com

  • Once this is successfully connected, you will see your virtual machine name like below.

Virtual machine is ready

Terminating your virtual machine

It is important to terminate or stop instances you are not using to avoid incurring unnecessary bills. To stop or terminate your instance, check the instance and click the instance state. You can select the action you want.

terminate or stop your instance

Be sure to choose "Stop" only if you still care about the data on your virtual machine. If you choose to "Terminate," you will lose all the data.

I hope you find this information helpful. Kindly follow for more.

Top comments (0)