Create your first AWS EC2 (Elastic Compute Cloud) Instance

We are running a series on basic AWS services, and this blog is about the most famous service of AWS — EC2 or Elastic Compute Cloud.

This service is about creating a Virtual Machine with a custom configuration in a few clicks. The most exciting part of EC2 is “how they sync the usage of hardware with a software service (i.e. AWS)”. If we think of “What is behind AWS”, its answer would be “there are a lot of servers/machines that are placed on the Amazon server rooms”.

What is AWS Nitro System?

There is an “AWS Nitro System”, which is used as virtualization to emulate the Machine Instance. This makes the EC2 instances more powerful and efficient If you want to read more about it go to AWS Nitro System.

EC2 Console 

Using the EC2 console, we can customize our own machine and select Machine Image (AMI), Architecture, memory, storage, and Instance type. Here is the game change - Instance type. Instance type helps us to select how much memory and CPUs, we need for our machine.

Instance type

There is a long list of Families that AWS provides, it starts from 1 vCPUs to 448 vCPUs and for memory, we have a range of 0.5 GB to 4096 GB. It’s shows the efficiency of EC2 machines. But we must also know that “Nothing comes for free in this world”, so Amazon charges per-hour of usage of EC2 machine. But we will be using the free tier t2.micro machine (It comes with 1 GB ram and 1vCPU).

Creating our First EC2 Instance 💻

To create an instance go to AWS console and login into your account using Root or IAM user. Once you are logged in you will see a “services” button and search EC2.


Once you are navigated to the EC2 section, you will see a dashboard, showing Resources used in that Region. 

EC2 Service

What are AWS EC2 Regions?

Now you must be wondering “what is region”. If you have read the introductory part of AWS, then you must know that “Region is the outermost layer, where our servers actually exist”. EC2 instances are distributed according to Regions and then the Availability Zones.

This means you can allocate your instances according to your requirements. If you are living in India then create your EC2 instance in Asia Pacific Mumbai region (ap-south-1). This factor will affect the Response time and availability of your EC2 instance. To change the Region, there is am option on left of the Header.


How to Configure the EC2 Instance?

 Select your preferred Region (will be using Oregon for this series of blogs) and create an EC2 Instance by clicking on “Launch Instance”. Now it will take you to the screen where you have to enter the instance name and select the Machine Image (AMI), Architecture (64 bit x86 or Arm), instance type, key pair (to login into the machine using ssh), Network settings (VPC, subnets and more), Storage Config.

  1. Instance Name:- It's just the instance name, you can keep it whatever you want.
  2. Amazon machine Image:- It's about, which Operating system image to be installed in the EC2 instance. It can be Linux, macOS, Red Hat, Ubuntu, Debian, Windows, or SUSE. Each of the OS images has different versions available. You can select any of the OS images that you require (we will be using Amazon Linux Image).
  3. Instance type:- There are a lot of instance types available. Instance type differs according to vCPUs and Memory. The naming of the Family is like t2, c3 etc (we will be using t2.micro).
  4. Key Pair login:- Here we generate the new key pair, as this key pair will help us to login into the instance using ssh. To create it click on “Create new key pair”, enter the key pair name (we can enter any name), and select RSA as key pair type and .pem as Private key format (they are by default selected). Once you click on “create key pair” a .pem file will be downloaded.

Creating key pair

5. Network settings:- This is one of the most important parts, as it manages the network-related configurations. Such as Security groups, VPCs, etc. I have already explained the security groups in the previous introductory blog. And VPC itself is a topic that we will be covering later in this series of AWS. For now, we do not have to edit anything, just go with default settings.

6. Storage Configuration:- It's about adding hard disk storage for the EC2 instances. And 8GiB will be sufficient for our initial use.

NOTE :- We do not have look into Advanced Details for now.

Now click on Launch instance to launch the EC2 instance. And we are ready to experiment on that Instance. You will see the below screen once the instance is launched.

Launched EC2 Instance

Now if you check the running instance, you will see one instance is up and running.

Running Instance

Once we will look at the details associated with the EC2 instance, it includes Instance public IP, private IP, and VPC-related information.

EC2 Details

How to add Security Group to EC2 — inbound and outbound rules? 

Now select this instance and go to the Security tab. And in the security tab, click on security groups. Once you click on it, you will see the Inbound and Outbound rules.

Inbound rules

Here in Inbound rules, we can see only SSH is enabled. So we can only SSH into the machine. Neither we can do HTTP or HTTPS into this EC2 machine. Let's add an HTTP and HTTPS, click on “Edit inbound rules”.

Inbounds rules

Now click on “Add rule”, and select HTTP and HTTPS from type. Here means allowing everyone to go into the EC2 using HTTP, HTTPS, and SSH. Click on “Save rules” to save the inbound rules. As we know, Inbound and outbound rules go both ways. As we have enabled HTTP, HTTPS, and SSH in inbound rules then it’s automatically allowed for outbound rules.

We will try to login into the machine and run some of the Linux commands. There are different ways to connect with a machine.

Connect to EC2 machine

How to Connect to AWS EC2 instance from terminal?

AWS also provides a terminal-like interface (EC2 instance connect) to connect and login into the machine. But logging into the machine using SSH is widely used. It is about connecting to an EC2 machine using our PC.

If you have a window PC then download Putty which will help you to do SSH to an EC2 machine. And if you have Linux or macOS, then we just have to use the ssh command.

$ ssh -i key_pair.pem public_username@public_ip

After that it will ask for fingerprints, you just have to type y (yes). Let's do it for our EC2 instance. Use your key_pair name and public_username (default username/alias is ec2-user). Public IP can be seen in Instance details. If the below command does not work, add “sudo” before the command.

SSH into EC2 Machine

Once you type “yes” and press enter, you will be entered into the machine.

Check IP Address on EC2 Instance :

 To check the IP Address of the Machine run the below command into the EC2 machine.

$ dig +short

It will display the public IP of EC2 Instance, check the below screenshot:-

EC2 IP check

Now if we try to ping into the machine, it will give us the response as we have added HTTPS to the Inbound and outbound rules. Let's try to ping google from our machine.


Security groups work in this way, later in the series, we will see how to create a private subnet in VPCs. In the Private subnet, EC2 will be able to access the Internet but the outer world (Internet) will not be able to enter into the machine.


Now we know the basics of EC2 machine and we are ready to kickstart our AWS journey. 

Now you know the answers to : How to create an AWS EC2 instance? How to configure an AWS EC2 instance? How to configure security groups on AWS EC2? How to set up inbound and outbound rules? How to Connect EC2 from a terminal or PuTTY.

We will be doing a lot of experiments on our EC2 instance. And one more important factor to keep in mind is the pricing of EC2. Goto EC2 Pricing to check, how much you have to pay for using different families of the EC2 instances.

Next Steps

If you liked this blog, you will also find the following blogs interesting and helpful. Feel free to ask any questions in the comment section

Ionic Capacitor

Ionic Cordova

Ionic React Full App with Capacitor

If you need a base to start your next Ionic 5 React Capacitor app, you can make your next awesome app using Ionic 5 React Full App in Capacitor

Ionic 5 React Full App in Capacitor from Enappd

Ionic 5 React Full App in Capacitor from Enappd

Ionic Capacitor Full App (Angular)

If you need a base to start your next Angular Capacitor app, you can make your next awesome app using Capacitor Full App

Capacitor Full App with huge number of layouts and features

Capacitor Full App with huge number of layouts and features

Ionic Full App (Angular and Cordova)

If you need a base to start your next Ionic 5 app, you can make your next awesome app using Ionic 5 Full App

Ionic Full App with huge number of layouts and features

Ionic Full App in Cordova, with a huge number of layouts and features


Vaibhav Gehani

Full Stack Developer




Vaibhav Gehani

Full Stack Developer