- 14th Jan, 2025
- Aanya G.
17th Apr, 2025 | Jugal S.
Amazon EC2 (Elastic Compute Cloud) is a web service by AWS that allows users to rent virtual servers in the cloud. It provides scalable compute capacity, making it easier to build and deploy applications without owning physical hardware.
A major advantage of AWS EC2 is its flexibility, allowing users to select from a wide range of instance types and operating systems.
With EC2, you can adjust the size of your instances as needed, making it easier for organizations to handle changes in traffic and use their resources more efficiently.
Instances can be launched and terminated on demand ,enabling quick deployment of applications and services while minimizing downtime.
With EC2, you only pay for what you use. You can also choose from different pricing options like Reserved and Spot Instances to lower your costs even more.
You can launch your applications anywhere in the world, thanks to AWS data centers located in multiple regions.
With AWS, you can choose from a wide range of instance types and configurations. For example, you can select an instance with 16 GB RAM and 4 vCPUs and run it on Ubuntu, Windows, or other operating systems—whatever suits your application best.
Let’s launch our first EC2 instance and explore related concepts like SSH, user data scripts, and security groups along the way.
So let’s go to AWS Console
So this is my AWS console
Now, head to the search bar at the top left, type in “EC2,” and click on the EC2 service from the results.
So now I am on the EC2 instance dashboard, and you can see the instance running. Click on that, and you will get a list of all EC2 instances that are running.
Here’s a list of EC2 instances that are currently running. Let’s go ahead and create our first EC2 instance. Click on button Launch Instances (on top right).
Now give a name to you ec2 instance and select AMI
Wait a second - what does AMI mean?
AMI stands for Amazon Machine Image
An AMI is like a ready-made setup that has everything needed to start a virtual machine on AWS. It can include the operating system, software, and settings so you don’t have to set everything up from scratch each time.
Before, setting up servers meant handling real machines, which was slow and hard. Virtual machines made things easier but still needed manual setup. AMIs solve this by giving you ready-made server templates on AWS, so you can launch and manage servers quickly and easily.
You can start EC2 instances using different types of AMIs:
Lets give instance name as “web-app” and select free tier eligible Ubuntu AMI
Now, choose an instance type. But a question pops into your mind — what exactly is an instance type?
Think of instance type as choosing the size and power of your virtual computer.
I have selected t2.micro Instance type (free tier eligible)
Now what’s next?
1 . Click on Create new key pair.
a. Give a name to key pair , i have given “web-app-key-pair”.
b. Select Key pair type (I have selected RSA) and private key file format (.pem). c. Click on "Create key pair" - once clicked, the private key will be downloaded to your local system. Save it to your preferred directory.
In the network settings, let's use the default VPC and subnet and enable auto-assign public IP for now.
Let’s focus on Security groups for now.
Rules are defined using:
These control who can send traffic to your EC2 instance. Example: If you want to SSH into your instance, you need to allow inbound traffic on port 22.
In short: Inbound = who can reach your server Outbound = who your server can talk to
In the security group, I am allowing SSH traffic on port number 20 from anywhere (0.0.0.0/0) and also HTTP traffic on port number 80 from anywhere.
Currently we will go with Auto assign public IP; later we will discuss elastic IP addresses.
And also we are not concentrating on VPC, so we will go with default VPC.
When you launch an EC2 instance, you need to attach storage volumes where your OS, apps, and data will be saved. It is like root volume of your ubuntu or C drive in windows
AWS give you following storage options:
Types:
1. Install software (e.g., NGINX, [Apache](https://www.apache.org/), [Node.js](https://nodejs.org/en))
2. Run configuration commands
3. Update packages
4. Start service etc .
E,g Here's a User Data script to install and start NGINX on an EC2 instance running Ubuntu:
We're not using a user data script for this setup. Instead, we'll install NGINX manually on the EC2 instance.
Lets click on “Launch Instance” Button on bottom right corner.
So out instance is created and launched successfully, so lets go to listing of ec2 instances.
Here is the our web-app instance with state Running
Let’s install NGINX directly on our EC2 instance and start the server.
So first we need to connect to instance, so check the ec2 “web-app” ec2 instance and click on connect.
Now select EC2 Instance Connect and click on Connect
Now you will find a terminal like this:
Now to install nginx, Run this command step by step
After starting nginx, Open your public IPv4 address, or public IPv4 addresses in your browser.
You will get something like this:
By default, NGINX runs on port 80, which is the standard port for HTTP traffic.
So, when you enter your EC2 instance’s public IP in the browser, you’ll see the default NGINX welcome page. This confirms that NGINX is installed and running successfully.
Select ec2 instance, go to Instance State, and click on Terminate (delete instance).
Go to the key pairs section, select a key pair , click on Action, and then delete.
Go to the security group section, select security groups, click on action and then delete.
Get insights on the latest trends in technology and industry, delivered straight to your inbox.