Introduction to Elastic Compute Cloud

learn how to create your first virtual machine in the cloud

Cloud technologies have become an integral part of modern architecture, whether partially or fully implemented. They could be used to harness the platform's extensive features for entire applications or to host portfolios and personal projects. Gaining proficiency in cloud technologies provides numerous advantages and can significantly enhance your skill set.

In this article, we will explore a specific cloud technology: AWS (Amazon Web Services). I will introduce some of the platform's most popular technologies and demonstrate how to create your first virtual machine in the cloud. Virtual machines are among the most widely used cloud services. I will also explain how to get access to it as well as how to regain access if the private key was not properly configured or has been lost.

Amazon Web Services

As its name suggests, AWS (Amazon Web Services) is a collection of on-demand technology services delivered via the internet. As the pioneer of cloud computing, AWS played a key role in shaping the cloud market by empowering organizations of all types and sizes to build and scale their infrastructures and applications. By reducing costs, increasing agility, and fostering innovation, AWS successfully attracted many players in the tech industry with its pay-as-you-go business model where you pay for what you use, making of it a very profitable solution .

Among these variety of services we have Amazon Simple Storage Service (S3). what is it exactly? it’s a service that utilizes the object-based storage model, where data is stored as 'objects' rather than files or blocks. This approach makes it highly scalable and efficient for specific use cases, particularly with unstructured data. When storing data in S3, you can place large volumes of it into a 'bucket.' The bucket ensures data integrity, high availability, and security, with access provided through APIs.

For my part, I used S3 to host the front end of my virtual bank portfolio project, which was a dynamic web application composed of HTML, CSS, and JavaScript files. It was very practical, as the back end was hosted on a virtual machine (EC2, which we’ll discuss below). Another popular service I used for my project is Route 53, a cost-effective Domain Name System (DNS) ,the great thing about Route 53 is that it can be used with both AWS and non-AWS resources. Additionally, AWS offers free access to these services for up to 365 days, so if you have a domain name for your site, you can create an account and use Route 53. I also used another service called Elastic IP, which provides a static IP address, ensuring that the DNS can reliably locate my application, since EC2 instances have dynamic IPs.

With all this in mind, let’s now move on to creating our virtual machine.

Create your EC2 (Elastic Compute Cloud) Instance

first thing first go to aws.amazon.com and create a new aws account

Once you click, you will be redirected to the page below. Click on Create a New Account and fill in all the required information. The email address you provide will be your root user ID, which you'll use to access your account. Please note that when you reach the step where you are asked to enter a payment method, if you encounter any issues while entering your information, you can always contact customer support. They will assist you in resolving any issues via chat support, and they typically respond quickly. In my case, the issue was resolved within 24 hours!

Your registration is complete. Now, it's time to access your account and explore all the services the platform has to offer. Select EC2 to get started:

After that, you will be redirected to this page. Click on Launch Instance to proceed.

Once you are on the Launch Instance page, in the Name and Tags section, give your machine a name. In the Application and OS Images section, choose the operating system you want to use. You can select from a range of distributions, but make sure the version you choose is eligible for the Free Tier. Scroll down to the Key Pair section and click on Create New Key Pair.

A pop-up window will appear where you can give your key a name, choose its type, and select the format, as shown in the image above. Once you create your key, another window will appear, allowing you to download it. Be sure to store the file in a secure directory, as it contains the private key needed to access your machine.

The final section is where we configure the network settings and define the types of access allowed to connect to our machine. In this case, I chose to enable SSH for secure access between my workplace and the machine, and I also allowed HTTP and HTTPS to enable incoming requests from the internet, allowing end users to access the application.

Now, it's time to access our machine using the following command:

ssh -i Downloads/my_key.pem ubuntu@13.60.59.113

In my case the key file was located in the Download folder so i pointed the command to this placement, keep in mind that in order to connect without any issue you need to accord the permission to your .pem file if it is too permissive ssh will throw an error saying that permission are too open if it is your case you need to edit the permission , go to the folder where your file is located open the terminal and execute the following command :

chmod 600 my_key.pem

if you try to connect once again you should get this output instead :

Restore access to your machine

Imagine you lose your .pem file—will you still be able to access your machine? . If SSM (AWS Systems Manager) is enabled, the answer is yes. Even if you've lost your key, you can still access the instance.

SSM is a secure, automated, and centralized access method, particularly useful when SSH access is unavailable (e.g., due to lost keys or security concerns). It is ideal for scenarios where you want to minimize the exposure of your infrastructure to the internet, or when you need greater control over access, auditing, and automation.

But what if SSM was disable and you lost your keys is there any other way to get back your instance ? the answer is yes and here are the steps to follow :

You will need to create a snapshot of the volume attached to your machine. To identify the correct volume, navigate to the Volumes section in the sidebar and locate the appropriate volume.

Once on the volume management page, scroll to the right and check the Attached Resources section.

Now, go to the Snapshots section in the sidebar. Once you're on the management page, click Create Snapshot choose the resource type and the description.

After that, all you need to do is create an image from the snapshot

Give the image a name and description, then click Create Image. Next, go to Images > AMIs in the sidebar menu and click Launch Instance from AMI. Since you're already familiar with creating an instance, we won’t go over the steps again. Simply fill in the required information as you did before, and be sure to select the correct key pair. Once you return to the instance management section, you should see your new instance listed.

With that in mind, I think it’s time to wrap things up. As always, feel free to ask any questions or share your experiences on this topic in the comments. Until next time, stay curious, keep exploring, and continue learning!