Skip to main content

How to Setup an EC2 Instance on AWS?

In this article, we will discuss "How to Setup an EC2 Instance on AWS?". An Amazon EC2 instance is a virtual server in Amazon's Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure. It provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. There are four main options to purchase Amazon EC2 Instances such as On-Demand Instances, Reserved Instances, Spot Instances, and Savings Plans. Basically, Amazon Elastic Compute Cloud (EC2) is the Amazon Web Service we use to create and run virtual machines in the cloud.

Amazon provides EC2 instances under the free tier, it includes 750 hours of Linux and Windows t2.micro instances. For more details on the free tier click here. After the free tier period is over, AWS charged us as per the instance configuration. Click here to check the pricing details.

Prerequisites



  • AWS Account

  • AWS Management Console Access


Login to AWS Management Console


Login to your AWS account and go to EC2 Instance Console. Then, click on the "Instances" tab as per the following screenshot.



After that click on the "Launch instances" button.


Setup EC2 instance


We have redirected to the "Launch Instance Wizard". Follow the given steps:

Choose AMI


Choose an Amazon Machine Image (AMI). Here, I'm choosing "Ubuntu Server 20.04 LTS". Note that it's available in AWS free tier, you can choose AMI as per your requirement or experience.


Choose Instance Type


Amazon EC2 provides a wide selection of instance types optimized to fit different use cases. Instances are virtual servers that can run applications. They have varying combinations of CPU, memory, storage, and networking capacity, and give you the flexibility to choose the appropriate mix of resources for your applications. As per the free tier, I choose t2.micro for this demo.


Configure Instance


In this step, we can configure our instance as per our requirements. You can launch multiple instances from the same AMI, request spot instances for lower pricing, assign roles and etc.


Add Storage


Here, we can increase or decrease the size of instance storage while creating it. The free tier is eligible upto 30GB, if you need more storage, it will be billed according to Elastic Block Store.


Add Tags


Here, we can add tags to our instance and storage, these tags are key-value pairs that are very useful to add properties to our resources, especially when we have multiple instances.


Configure Security Group


We can define the firewall rules in a security group attached to our instance. With the help of these rules, we can control the traffic to our instance. Click on the Review and Launch Button.


Review


Once, we are done with firewall rules, we can review the complete detail of our new instance on a single page, and here we can click the Launch button to launch the instance.



When we click Launch, it will open a pop-up that will require you to select a pre-existing public-private key pair or create one to connect to our instance securely. Once you select/download the key, you will be able to launch the instance.

I recommend choosing the new key pair for each instance, adding the key pair name, and download the file. This will provide us a "*.pem" file, which help us to connect with the instance using putty, FileZilla or etc.

After that click on the Launch Instances button. Once the AWS EC2 is created, you will be presented with this screen.



Go back to the EC2 Instances dashboard, our newly created instance is available.


What next? Login to AWS EC2 using SSH


Select the instance and Click on Actions > Connect



After clicking on Connect as per the above screenshot, we will redirect to a Connect to instance page. Our default username is "ubuntu". Click on connect.



On the same screen, we got the other settings such as Session Manager, SSH Client, and EC2 Serial Console.

Let's click on the Connect button. You will be redirected to the new tab in the browser.



In the end, we successfully connected with the EC2 Instance.

Conclusion


In this article, we are discussing "How to Setup an EC2 Instance on AWS?". Hope you like this article, I tried to explain the EC2 Instance set up in a simple and easy way. Please feel free to add comments if any queries or also send me feedback.

Keep learning and stay safe ;)




You may like:

Basic Understanding on AWS Lambda

Manage AWS Lambda Versioning and Aliases

How to Upload File to AWS S3 Bucket Laravel

How to Send SMS with AWS SNS using Lambda & Python

Setup AWS Pinpoint (Part 1)

Comments

Popular posts from this blog

Laravel Logging Guzzle Requests in File

In this article, we will discuss “Laravel Logging Guzzle Requests in File”. In the multiple scenarios, we have to use third-party API’s in our project and test those API using postman or any other tool. But also required to maintain a log for each request, such as what we send (request)? and what we receive (response)? Today, […] Read out the full post at here

How to Use SSH with AWS EC2 Instance?

In this article, we will discuss "How to Use SSH with AWS EC2 Instance?" . As I already explain the setup of EC2 Instance and the use of an Elastic IP in my previous article. Today, we will learn how to connect an EC2 instance using SSH. If still, you have not read my previous articles then I recommend checking them once for a better understanding. Prerequisites A running EC2 Instance . Elastic IP (Optional for this article) ".pem" file, which is downloaded when setup the EC2 Instance. If not having the ".pem" file, then you have to create new key/value pairs. Connect via Terminal or WSL(Window Subsystem for Linux) Open your terminal and go to the directory where you downloaded your ".pem" file. Use the following command to connect with the server. ssh -i "****.pem" username@<publicDNS> or <IP Address> The same terminal command can be used in the windows Linux terminal. I'm using ubuntu on my windows machine...

How to Setup and Install Next.js App?

In this article, we will discuss "How to Setup and Install Next.js App" from scratch. What is React.js and Next.js? "React.js" is a JavaScript library for building user interfaces (elements that users see and interacting on-screen). Basically, React provide us some helpful functions to build UI, and leaves it on us where to use those functions in the application. "Next.js" is a React framework. It is maintained by "Vercel" . Next.js features to solve common application requirements such as routing, data fetching, integrations - all while improving the developer and end-user experience. Why we use Next.js ? Next.js comes with the some additional features to solve come application requirements such as: We can build SSG (Static Site Generation), SSR (Server-Side Rendering) and SPA (Single Page Application) apps. Hot code Reloading: Reload the page when it detects any change saved. Routing: No need to configure any route. Files put in the pages fol...