The Insider's Guide to AWS EC2
Tags: aws, cloud, awsec2
Published: 2021-04-23 06:51:11

---
title: The Insider's Guide to AWS EC2
published: true
date: 2021-04-21 05:18:54 UTC
tags: aws,aws,cloud,awsec2
canonical_url: https://www.archerimagine.com/articles/aws/aws-ec2-tutorial.html
---

![AWS Made Easy | AWS EC2 | Launching Instance](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2.png "AWS Made Easy | AWS EC2 | Launching Instance")

## Introduction[¶](#introduction "Permanent link")

This is the shortest, easiest, and a beginner friendly step by step guide to launch and run a free tier AWS EC2 instance.

I am going to teach you everything, launch a free tier EC2 instance, connect to the EC2 instance using SSH or RDP. This post will teach you just enough to be dangerous.

If you ever wanted, just be able to launch a server (EC2) in the cloud and use that server, without worrying about the inner details. Even worried that it may cost you a fortune. This is the post you were waiting for.

> In seven days, God Created the world.

You need only seven steps to create an AWS EC2 instance in cloud.

Let's say **Hello World** to the cloud.

## What is AWS EC2 ?[¶](#what-is-aws-ec2 "Permanent link")

EC2 stands for Elastic Compute Cloud, AWS's virtual server in the cloud.

In order to create an AWS EC2 instance, you should understand

_What is AWS EC2?_  
_Why to use EC2?_  
_What is the benefit over your existing on premise server?_

Cloud computing is all about collection of servers running on someone else premise. In case of AWS it is Amazon's premise.

AWS EC2 is that single server in the school of servers on the cloud. AWS EC2 is one of the ingredients in the cloud recipe.

AWS EC2 is that virtual server running in the cloud. It is also referred to as an **instance** sometimes. You can select the amount of memory, storage and compute power each of your AWS EC2 should have.

You can even commission and decommission AWS EC2 on demand. This is was makes it a preferred choice compared to the on premise server. Due to this facility, cloud can always manage the traffic coming to them. When the load is high you can have more EC2 instance, and less instance when the load is low.

Cloud computing is all about paying what you use. You never pay for anything which you are not using.

_How do you create this AWS EC2 instance?_

Lets jump right into it.

## How to create EC2 instance in AWS ?[¶](#how-to-create-ec2-instance-in-aws "Permanent link")

You have learned about [AWS IAM](https://www.archerimagine.com/pages/aws-certification.html#aws-iam) before this, if not please read it. You have become comfortable with AWS Management console. You have still not seen anything happening in the cloud.

The purpose of this Blog, is to get your own private server running in the cloud. You will learn about all the inner details of the AWS EC2 instance, in future series of Blog.

In short you have still not said _Hello, World!_ to cloud. You will learn it today. Login into AWS Management console and follow along. You are entering The Matrix.

![AWS Made Easy | Matrix](https://www.archerimagine.com/images/aws/ec2/01-Generic-Matrix.jpg "AWS Made Easy | Matrix")

## EC2 DashBoard[¶](#ec2-dashboard "Permanent link")

In the AWS Management console, search for the service called EC2. It should launch an EC2 Dashboard just like this one.

![AWS Made Easy | AWS EC2 | DashBoard](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Dashboard.png "AWS Made Easy | AWS EC2 | DashBoard")

You have to select the **Launch Instance**. There are two ways to launch instances,

- Launch Instance
- Launch Instance with a template.
  - This is a basic configuration which can be saved as a template and be used to launch multiple instance with the same configuration.
  - You will learn more about this in future, when you learn Auto Scaling Group.

You will have this screen next.

![AWS Made Easy | AWS EC2 | Choose AMI](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Choose%20AMI.png "AWS Made Easy | AWS EC2 | Choose AMI")

You can clearly see that creating an EC2 instance is a 7 step process. These steps are.

1. Choose AMI
2. Choose Instance Type
3. Configure Instance
4. Add Storage
5. Add Tags
6. Confirm Security Group.
7. Review

You will have to proceed with these 7 steps to create your AWS EC2 Instance.

## Step 1: Choose an Amazon Machine Image (AMI)[¶](#step-1-choose-an-amazon-machine-image-ami "Permanent link")

An AMI or Amazon Machine Image, is a template which provide these information

- Operating System
- Application Server
- Application

An AMI is just like kids Stencil, which they use draw same diagram multiple times. Hope you remember these...

![AWS Made Easy | Stencil](https://www.archerimagine.com/images/aws/ec2/01-Generic-Stencil.jpg "AWS Made Easy | Stencil")

There are multiple vendor for AMIs, but you will not focus on them here. This is a battle for another day.

Please note, all the AMI listed at Quick Start are not free, please select the check box **Free tier only** , to list only 16 AMIs out of 40 AMIs. See the below image for reference.

![AWS Made Easy | AWS EC2 | Free Tier AMI](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Free-tier.png "AWS Made Easy | AWS EC2 | Free Tier AMI")

Broadly the AMI's are divided based on Operating System, Linux and Windows, and Linux is subdivided primarily based on its flavor.

![AWS Made Easy | AWS EC2 | Ubuntu AMI](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Ubuntu-AMI.png "AWS Made Easy | AWS EC2 | Ubuntu AMI")

You should go with **Ubuntu Server 20.04 LTS (HVM), SSD Volume Type**, Select 64-bit (x86) version and move to the next step to Choose the instance type.

## Step 2: Choose an Instance Type[¶](#step-2-choose-an-instance-type "Permanent link")

This step is analogous to choosing the hardware for your server. You have hardware which is optimized for database operation, some are optimized for Machine learning and AI application, some web application. You will understand the details on this in the very short future.

This screen looks like this.

![AWS Made Easy | AWS EC2 | Instance Type](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Instance-Type.png "AWS Made Easy | AWS EC2 | Instance Type")

The instance type tells us in detail about the family of hardware, the number of CPU cores it has, what type of instance storage it supports, Network performance, etc.You will learn about this, but as of now focus on the free tier instance type.

You have a `t2.micro`, which is eligible for free tier. You get 750 hrs of usage each month for the first year of joining. Please select this instance and proceed to the next step of, Configure Instance.

## Step 3: Configure Instance Details[¶](#step-3-configure-instance-details "Permanent link")

This is the step which will require an article on its own. Just look at the configuration you can do on this screen.

![AWS Made Easy | AWS EC2 | Configure Instance Type](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Configure-Instance.png "AWS Made Easy | AWS EC2 | Configure Instance Type")

You can configure all the below option.

- Number of instances you want to launch
- Do you need spot instance, a type of instance which is very cheap and can be used for non production work
- Do you want to use the default VPC, which will have an Internet gateway, making it easier for the instance to connect to the Internet.
- Do you want it to launch in the default subnet of into your own subnet, also do you want to Auto assign public IP.
  - Do not worry if you do not understand anything above 2 points, will make all of this information very easy to digest in a future Blog.
- What placement group, capacity reservation to do, any join directory, or any specific IAM role to use.
- How does the machine shutdown, hibernation needs to be enabled, any detailed Cloud watch monitoring to be done, please note this is a paid option so do not enable details cloud watch monitoring.
- What type of tenancy will you choose, dedicated instance, dedicated host or shared instance.
- Do you want your instance to burst from baseline performance in case of high load.
- Do you want to mount an EFS file system on the creation time?
- In certain advanced details, you can select to enable the Metadata information access, version, response hop limit etc.,
- There is also an option to create a bootstrapping script.

For the matter of simplicity, do not change any option in this screen and just proceed to the next step to Add Storage.

## Step 4: Add Storage[¶](#step-4-add-storage "Permanent link")

Every computer, be it server or desktop needs a hard disk. The hard disk can be magnetic or SSD. AWS provides all the options for hard drive. Depending on the type of instance chosen in the [step two](#step-2-choose-an-instance-type) the option of Hard drive may change.

The screen will look like this.

![AWS Made Easy | AWS EC2 | Add Storage](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Add-Storage.png "AWS Made Easy | AWS EC2 | Add Storage")

If you see the option carefully, you can observe that there is also option to encrypt the data. Even you can attach additional storage (EBS) later. Select the default option and move to the next step, Add Tags.

## Step 5: Add Tags[¶](#step-5-add-tags "Permanent link")

AWS gives you an option to add tags for everything. This will help in finding a particular instance and execute some script on those instances. The tags are case-sensitive.

The Add Tags screen looks like this.

![AWS Made Easy | AWS EC2 | Add Tags](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Add-Tags.png "AWS Made Easy | AWS EC2 | Add Tags")

Add a `Name` and value as `Webserver` tag. Proceed to next step a very important step to Configure the security group.

## Step 6: Configure Security Group[¶](#step-6-configure-security-group "Permanent link")

Security is important in AWS, and as you learned in the [Shared Responsibility model](https://www.archerimagine.com/articles/aws/general-aws.html#aws-shared-responsibility-model). The security of the instance is the user's responsibility.

The screen looks like this

![AWS Made Easy | AWS EC2 | Configure Security Groups](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Configure-Security-Group.png "AWS Made Easy | AWS EC2 | Configure Security Groups")

You have to understand few things about security group. Security group is basically a firewall to the instance. The default is to deny all traffic. The port which you open is the only traffic allowed.

You may be aware, there are two needs to communicate with your AWS EC2 instance.

- SSH to the AWS EC2 instance 
  - You should open port 22 for this.
  - You can open it from anywhere in the world, denoted by `0.0.0.0/0` Source, in the above screen shot.
  - You can even restrict the Source to be from just our public IP.
- The AWS EC2 instance, should behave as a Web Server
  - You can just open port 80 for this.

The default set in the above screen is allowing SSH to this particular AWS EC2 instance from anywhere in the world. This is good for our first AWS EC2 instance launch.

Select next and go to the last and final step of every AWS operation - **Review**.

## Step 7: Review Instance Launch[¶](#step-7-review-instance-launch "Permanent link")

Here you are in the EndGame. This screen looks like this.

![AWS Made Easy | AWS EC2 | Review and Launch](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Review.png "AWS Made Easy | AWS EC2 | Review and Launch")

This gives all the six steps you have done till now. This is the place you can review it. If you still want to change anything you can change it now. Press **Launch** if you have no changes to be done. It provides with a pop-up.

![AWS Made Easy | AWS EC2 | Key Pair](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Key-Pair.png "AWS Made Easy | AWS EC2 | Key Pair")

This Key Pair is necessary for SSH-ing to the Linux AWS EC2, and you can use this Key-Pair to generate RDP (Remote desktop) credentials in case of Windows AWS EC2. Save the eye pair (PEM file) in your local machine.

You are now ready to launch into Cloud, click **Launch instance**.

![AWS Made Easy | AWS EC2 | Start](https://www.archerimagine.com/images/aws/ec2/01-Generic-Start.jpg "AWS Made Easy | AWS EC2 | Start")

Once the AWS EC2 is created, you will be presented with this screen. This means the AWS EC2 is launching

![AWS Made Easy | AWS EC2 | Launch Status](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Launch-Status.png "AWS Made Easy | AWS EC2 | Launch Status")

Congratulation on launching your first AWS EC2 instance. Welcome to the Cloud.

## What next? Login to AWS EC2 using ssh[¶](#what-next-login-to-aws-ec2-using-ssh "Permanent link")

You have launched your first AWS EC2 instance. What Next....

_What do you do with it?_   
_How do you run the application on this server?_

You have to SSH to the AWS EC2 instance. To SSH into the AWS you need some information.

You should go to EC2 Dashboard > Instance, the screen will look like this.

![AWS Made Easy | AWS EC2 | Post Launch EC2 dashboard](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-DashBoard-Instances.png "AWS Made Easy | AWS EC2 | Post Launch EC2 dashboard")

If you see in the above screen, the AWS EC2 is still in _Initializing_ phase. Please click the Connect button to get the connect information, which would look like this.

![AWS Made Easy | AWS EC2 | EC2 Connect](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Connect.png "AWS Made Easy | AWS EC2 | EC2 Connect")

The above screen tells you all the information you need to connect.

To elaborate on the step, it is a two step process

1. Reduce the permission on the PEM key.
2. Connect to the AWS EC2 using the SSH command.

### Reduce permission of PEM File[¶](#reduce-permission-of-pem-file "Permanent link")

You should have the [PEM file downloaded before](#step-7-review-instance-launch), saved locally. Navigate to the directory where the PEM file is present. Execute this command to reduce the permission

```
chmod 400 <key_file>.pem

```

The `chmod` command above will only provide the read permission to only owner. Groups and Others have no permission on the files. Once you have reduced the permission move to the next step.

### SSH connect to AWS EC2[¶](#ssh-connect-to-aws-ec2 "Permanent link")

This is the big step, where you actually connect to AWS EC2. The general structure of the command is,

```
ssh -i "key_file_name.pem" ubuntu@ec2-12-66-176-143.<region>.compute.amazonaws.com

```

Once you have the SSH executed your terminal should look like this.

![AWS Made Easy | AWS EC2 | SSH Connect](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-SSH-connect.png "AWS Made Easy | AWS EC2 | SSH Connect")

You can execute some command on the SSH terminal, like for Ubuntu the most popular commands to execute is

```
sudo apt update && sudo apt upgrade -y

```

This is will update the software on the server.

Please think how you can launch an Apache2 Web Server in this AWS EC2 instance.

## Terminate of launched AWS EC2[¶](#terminate-of-launched-aws-ec2 "Permanent link")

You have launched the AWS EC2 instance, in the free tier, it does not mean that you have infinite free usage. You should terminate the launched AWS EC2 instance. This will prevent you from unwanted cost.

Go to EC2 Dashboard > Instance, and click on Action, it will look like this.

![AWS Made Easy | AWS EC2 | Terminate EC2](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminate.png "AWS Made Easy | AWS EC2 | Terminate EC2")

Select the Instance State > Terminate. This will ask for confirmation like this,

![AWS Made Easy | AWS EC2 | Termination Confirmation](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminate-Instance.png "AWS Made Easy | AWS EC2 | Termination Confirmation")

Once selecting Yes, Terminate, it will start the termination process, and once done you should a screen like this.

![AWS Made Easy | AWS EC2 | EC2 Terminated](https://www.archerimagine.com/images/aws/ec2/01-AWS-EC2-SS-EC2-Terminated.png "AWS Made Easy | AWS EC2 | EC2 Terminated")

With this, you have safely launched, executed and terminated an AWS EC2 instance. Congratulation on the big step.

![AWS Made Easy | AWS EC2 | Congratulations](https://www.archerimagine.com/images/aws/ec2/01-Generic-Congrats.png "AWS Made Easy | AWS EC2 | Congratulations")

## Conclusion[¶](#conclusion "Permanent link")

When this article started, you may not have known what is an AWS EC2 instance, How to make it work. You may have never thought it could be so easy to create one.

You may still do not understand a lot of options which were selected in the above process, but you will understand each and every detail in the coming series of article.

Launching a new free-tier EC2 instance is a 7 Step process, and you can login to the instance by SSH in case of Linux OS and RDP for Windows.

Now you have your own piece in the cloud, do not forget to terminate the instance else, this piece of cloud will put a hole in your pocket.

## Reference[¶](#reference "Permanent link")

- Image by [Comfreak](https://pixabay.com/users/comfreak-51581/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=356024) from [Pixabay](https://pixabay.com/?utm_source=link-attribution&utm_medium=referral&utm_campaign=image&utm_content=356024)
- Photo by [Anna Shvets](https://www.pexels.com/@shvetsa?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels) from [Pexels](https://www.pexels.com/photo/crop-man-transferring-sketch-on-bag-5642045/?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels)
- [Technology photo created by onlyyouqj - www.freepik.com](https://www.freepik.com/photos/technology)
- Photo by [Wil Stewart](https://unsplash.com/@wilstewart3?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/congratulations?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)