AWS: Setting Up AWS Virtual Machine
A beginner’s guide to creating an AWS VM
Introduction
👋🏽 Hi, Tech Family! 🚀 We are back again with another step-by-step engagement on setting up a VM on Amazon Web Services (AWS). ☁️💻
Amazon Web Services (AWS) is a leading cloud computing platform that provides on-demand access to computing resources, storage, networking, databases, and other IT services. Through its global infrastructure of Regions and Availability Zones, AWS enables users to deploy applications and build secure, reliable, and scalable cloud solutions.
On AWS, virtual machines are commonly launched using Amazon Elastic Compute Cloud (Amazon EC2), which allows users to create and manage virtual servers with control over computing capacity, operating systems, networking, and security configurations.
let me explain it with something I love: cooking.
Think of it like preparing Party Jollof Rice! 😂🔥
Instead of building your own kitchen from scratch, you pay an external kitchen to do the cooking. You rent their kitchen appliances, use their resources, and enjoy their services. However, the final product, your delicious PARTY JOLLOF RICE, belongs to you! 😋🎉
That’s similar to AWS! You leverage AWS infrastructure and resources to run your virtual machine and applications without having to own and maintain the physical hardware.
Let’s get started! 🚀
Step 1: Create and Sign-in to Your AWS Account
Initially, we start by creating an AWS account by visiting the AWS Management Console. After signing up, sign in to your account. Once you have successfully signed in, you will be redirected to the AWS Management Console, where you can access and manage AWS services.
N.B.: Enable Multi-Factor Authentication (MFA) to add an extra layer of security to your AWS account.
After signing in, choosing your location is the next thing to do. locate the Region Selector in the top-right corner of the AWS Management Console and choose your preferred AWS Region. Due to varying prices, you should always choose a region that meets your application’s needs in terms of cost, performance, compliance, and availability to users. I had to choose Stockholm because it seems to give me a better pricing option.
N.B.: The AWS Region you pick matters because it affects several factors, including Latency, Cost, Compliance, Resilience, Availability to Users.
Step 2: Launching Our Virtual Machine (EC2)
After selecting our preferred AWS Region, navigate to the All Services section in the AWS Management Console. Under the Compute category, select EC2 (Elastic Compute Cloud), which is AWS’s service for creating and managing virtual machines (VMs). With EC2, we can launch a virtual server in the cloud without needing to purchase or maintain physical hardware.
N.B.: EC2 is the AWS service, while an EC2 instance is the virtual machine we create and run using that service.
Once we click on EC2, we will be directed to the EC2 Dashboard. On the dashboard, locate and click the Launch instances button to begin creating our virtual machine in the cloud. This will take us to the instance configuration page, where we can choose our operating system, instance type, storage, and other settings.
Step 3: Configuring Our EC2 Instance
On the EC2 instance launch page, we will begin configuring our virtual machine. Since we are only launching a demo instance for learning purposes, we will start with the Names and Tags section. Under the Name field, enter: MY_FIRST_AWS_VM (You can choose any name you prefer, fellas! 😎)
Under the Application and OS Images (Amazon Machine Image) section, I selected Ubuntu as our operating system (You can also choose another operating system based on your needs and preferences). Next, I selected the appropriate Ubuntu AMI version for our demo instance. Since we are only using this instance for DEMO purposes, we will choose an option eligible for the AWS Free Tier, where available. Under the architecture option, I recommend users using 64-bit (x86) because it offers broad compatibility with most software packages.
N.B.: Prior to now, I had always thought Images in cloud engineering was about pictures😎 but after a deeper understanding, I found that AMI (Amazon Machine Image) is that resources that provides the operating system and software configuration for your virtual machine.
Step 4: Choosing Our Instance Type
Remember, we started our discussion by explaining that our EC2 instance is a virtual machine (VM) that provides computing resources similar to those of a physical computer, including CPU, memory (RAM), and networking capacity. The only difference is that our virtual machine runs on AWS infrastructure and is managed remotely.
The Instance Type we choose determines the amount of computing resources allocated to our virtual machine, including its CPU, memory, and networking capacity. For this demo, we will select a small instance suitable for basic learning and testing, such as t3.micro.
Always choose an instance type that meets your workload requirements without incurring unnecessary costs.
N.B.: While choosing your instance type, always be mindful of the cost implications. Remember to stop your EC2 instance when you are no longer using it to avoid unnecessary charges unless BODY GO TELL YOU WHEN YOU SEE THE COST YOU’VE ACCUMULATED 😂💸.
Step 5: Creating a Key Pair
In this step, I created a key pair for my EC2 instance. what a key pair helps me with primarily is that it helps me securely authenticate my identity when connecting to my virtual machine (VM). For this demo, I configured my key pair using Key Pair Name:(MY_FIRST_AWS_KEY) then Key Pair Type (RSA) and Private Key File Format (.pem).
Immediately after creating the key pair, my browser automatically downloaded the private key file to my computer. The public key is stored on the instance, while the private key remains with you. Keep your private key safe!
N.B.: I made use of RSA because it is a widely supported public-key pair type that works with many SSH clients, making it suitable for learning how to connect securely to our AWS EC2 instance and I made use of .pem format because it allows the private key to be stored in a file that compatible SSH clients can use for authentication when connecting to the instance.
Step 6: Configuring My Network Settings
Since we don’t have any specific networking requirements for this demo instance, I used the default Virtual Private Cloud (VPC) and subnet settings. I also created a new Security Group (virtual firewall) which controlled the incoming and outgoing traffic allowed to and from my EC2 instance. To enable a secure connection from my computer to the virtual machine, I allowed SSH traffic on port 22.
N.B.: It is always good to avoid allowing SSH from anywhere (0.0.0.0/0) unless there is a specific, justified need.
Step 7: Configuring our storage
Since I am working with a demo instance, I will be using using the default root volume for our storage configuration. I kept the storage size at its default setting because it is sufficient for this beginner exercise. It provides space for the Ubuntu operating system and the files required by our virtual machine.
Since I am setting up a basic Ubuntu VM for learning purposes, I do not need to attach an additional file system. Therefore, I selected None (No additional file system attached). For storing and retrieving files and other objects, I would have picked S3 files, For sharing file storage that multiple instances can access, it is best recommended to pick EFS, For managing file systems designed for specific workloads and requirements, FSx is used.
Get Sheyi John’s stories in your inbox
Join Medium for free to get updates from this writer.
N.B.: For this demo, our default root volume is sufficient, so we do not need any additional file systems.
Step 8: Launching Our Virtual Machine 🚀
Finally, guyssssss! We are almost there! At this stage, it is advisable to perform a final review of our EC2 instance configuration before launching it. Checking the important details, including your instance name, operating system (AMI), instance type, key pair, network settings, and storage configuration is best implemented.
Once you have confirmed that everything is correct, click the Launch instances button then wait for the success notification, To see all EC2 instances, I clicked on the View all instances. On the Instances page, to see if my instance is running, I check the Instance State column.
Step 9: Using SSH (Secure Shell) to Connect to Our EC2 Instance
Once our EC2 instance is up and running, the next step is to connect to it using SSH (Secure Shell). To get started, I navigated to my EC2 instance details in the AWS Management Console and copied its Public IPv4 address. I would use this address to establish an SSH connection to my instance from my local terminal.
N.B.: SSH client uses an identity file which contains our downloaded Key_Pair.
Step 10: Checking the Location of Your Private Key Pair
Remember that when we launched our EC2 instance, we created and downloaded a key pair (.pem file). Before connecting to our instance via SSH, we need to locate the downloaded .pem file on our computer, as it will be required to authenticate our connection to the EC2 instance.
Now that we’ve located the downloaded .pem file on our computer, the next step is to navigate to the folder containing the file using our terminal using cd C:\Users\HomePC\Downloads\MY KEY-PAIR. Once there, we can use the ls command to list the files in the directory and confirm that our private key pair is present.
Next, we will use the cat command to check the contents of our .pem file and confirm that the file is present and readable. But note that since our private key is sensitive information, it is best to avoid displaying its contents in the terminal.
Now I added restricted access to my private key to ensure that SSH can use it securely. We can do this by using the chmod 400 MY_FIRST_AWS_KEY.pem command, which grants read permission only to the file owner and removes all permissions for the group and others.
Step 11: Allowing SSH Traffic in the AWS Console
To connect to our EC2 instance from our local terminal, I configured my EC2 instance to ensure that the instance’s security group allows SSH traffic.
To do this, I navigate to the Security tab in the AWS Management Console and select Edit inbound rules. Here, we can configure and verify the rule’s type, protocol, port range, and source to ensure that SSH connections are allowed.
For my standard SSH connection, the settings are Type: SSH, Protocol: TCP, Port Range: 22 and Source: My IP (highly recommended for better security)
N.B.: Making use of these settings allow SSH connections from your current public IP address while limiting access to your instance.
Step 12: Connecting to Our EC2 Instance
Since I selected Ubuntu as the operating system for my EC2 instance, I will use the SSH command to establish a secure connection from our local terminal. Running the following command: ssh -i “MY_FIRST_AWS_KEY.pem” ubuntu@51.20.54.71 will secure a connection frm my local machine to my EC2 instance.
Once the connection is successful, you should be able to access and manage your EC2 instance directly from your terminal.
N.B.: Replace the PUBLIC_IP with the public IPv4 address of your EC2 instance.
Step 13: Allowing HTTP Traffic in Our AWS Console
Since my SSH rule can remain restricted to your MY IP, accessing the web browser won’t be possible but I can separately allow HTTP traffic so visitors can access your Nginx web server by configuring my EC2 instance’s security group . I configured the inbound rules with the following settings Type: HTTP, Protocol: TCP, Port Range: 80 and Source: Anywhere-IPv4 (0.0.0.0/0)
N.B.: By selecting Anywhere-IPv4 as the source, I allow visitors from any IPv4 address to access our web server over HTTP. Once Nginx is installed and running on our EC2 instance, we can enter its Public IPv4 address into a web browser to confirm that the server is accessible.
Using the command sudo apt update and sudo apt install nginx -y, I updated and installed nginx. I also used the command sudo systemctl start nginx and sudo systemctl enable nginx to start and configure it.
To Confirm if connection was successful by opening nginx on our browser, Open Chrome or Edge and enter HTTP://YOUR_PUBLIC_IP
If you see the above image, then you are good to go 100%.
And guyssssssss, that’s a big wrap! 🎉
We’ve successfully created a virtual machine using an AWS EC2 instance and deployed an application to run directly on it!
Don’t forget to give me a big round of applause 👏 and follow me for more exciting tech tutorials and updates.
Thank you so muchhhhh! ❤️









