AWS EC2 – All that you need to know for a good start with AWS

  • by

In our last article, we’ve understood the process of AWS account creation. If you don’t know about the procedure of opening an account with AWS, I suggest you checkout that article first. It will help you in better understanding. In this article, we will perform a deep dive on AWS EC2. In the first section, we will pay our attention on the documentation of AWS EC2. Next, we will learn the practical aspect. We will also see some common issues that we often face while dealing with AWS EC2. In the last section, we will do a deep dive on frequently asked queries on AWS EC2. Let’s start!

Target audience
1. AWS beginner
2. Student who wants to learn AWS
3. All who wants to see the commonly faced issues with AWS ec2

What is AWS EC2?

AWS EC2 or AWS Elastic Compute Cloud is the basic scalable computing unit. In a simple word, this is the virtual server of your choice. You can spin up as many virtual host or server as you want in a single physical hardware. It can be scaled up or scaled down these servers at any point of time. You don’t need to provision your hardware based on your expected traffic! You can configure it’s firewall (known as Security Group), virtual disks (termed as EBS or instance-store) by your own. We’ll also get the facility to design your own network as you used to configure on your on premises environment.

What is the feature of AWS EC2?

Amazon EC2 provides the following features:

  • Virtual computing environments, known as AWS instances
  • Pre-configured templates for your instances, known as Amazon Machine Images (AMIs), that package the bits you need for your server (including the operating system and additional software)
  • Various configurations of CPU, memory, storage, and networking capacity for your instances, known as instance types
  • Secure login information for your instances using key pairs (AWS stores the public key, and you store the private key in a secure place)
  • Storage volumes for temporary data that’s deleted when you stop or terminate your instance, known as instance store volumes
  • Persistent storage volumes for your data using Amazon Elastic Block Store (Amazon EBS), known as Amazon EBS volumes
  • Multiple physical locations for your resources, such as instances and Amazon EBS volumes, known as Regions and Availability Zones
  • A firewall that enables you to specify the protocols, ports, and source IP ranges that can reach your instances using security groups
  • Static IPv4 addresses for dynamic cloud computing, known as Elastic IP addresses
  • Metadata, known as tags, that you can create and assign to your Amazon EC2 resources
  • Virtual networks you can create that are logically isolated from the rest of the AWS cloud, and that you can optionally connect to your own network, known as virtual private clouds (VPCs)

How many instance type does AWS provide?

When you will create an AWS EC2 instance, you need to select instance type. An instance type determines the hardware of the host computer used for your instance. Each instance type offers different compute, memory, and storage capabilities and are grouped in instance families based on these capabilities. Amazon EC2 provides a wide selection of instance types optimized for different use cases. AWS EC2 provides 45 types of instances. As of today, I’ve list down those 45 instances below. However, I recommend you to rely on official AWS page as that will be updated whenever a new instance will be launched.

Use caseInstance TypeSizes
General purposeA1a1.medium | a1.large | a1.xlarge | a1.2xlarge | a1.4xlarge | a1.metal
General purposeM4m4.large | m4.xlarge | m4.2xlarge | m4.4xlarge | m4.10xlarge | m4.16xlarge
General purposeM5m5.large | m5.xlarge | m5.2xlarge | m5.4xlarge | m5.8xlarge | m5.12xlarge | m5.16xlarge | m5.24xlarge | m5.metal
General purposeM5am5a.large | m5a.xlarge | m5a.2xlarge | m5a.4xlarge | m5a.8xlarge | m5a.12xlarge | m5a.16xlarge | m5a.24xlarge
General purposeM5adm5ad.large | m5ad.xlarge | m5ad.2xlarge | m5ad.4xlarge | m5ad.8xlarge | m5ad.12xlarge | m5ad.16xlarge | m5ad.24xlarge
General purposeM5dm5d.large | m5d.xlarge | m5d.2xlarge | m5d.4xlarge | m5d.8xlarge | m5d.12xlarge | m5d.16xlarge | m5d.24xlarge | m5d.metal
General purposeM5dnm5dn.large | m5dn.xlarge | m5dn.2xlarge | m5dn.4xlarge | m5dn.8xlarge | m5dn.12xlarge | m5dn.16xlarge | m5dn.24xlarge
General purposeM5nm5n.large | m5n.xlarge | m5n.2xlarge | m5n.4xlarge | m5n.8xlarge | m5n.12xlarge | m5n.16xlarge | m5n.24xlarge
General purposeM6gm6g.medium | m6g.large | m6g.xlarge | m6g.2xlarge | m6g.4xlarge | m6g.8xlarge | m6g.12xlarge | m6g.16xlarge | m6g.metal
General purposeM6gdm6gd.medium | m6gd.large | m6gd.xlarge | m6gd.2xlarge | m6gd.4xlarge | m6gd.8xlarge | m6gd.12xlarge | m6gd.16xlarge | m6gd.metal
General purposeT2t2.nano | t2.micro | t2.small | t2.medium | t2.large | t2.xlarge | t2.2xlarge
General purposeT3t3.nano | t3.micro | t3.small | t3.medium | t3.large | t3.xlarge | t3.2xlarge
General purposeT3at3a.nano | t3a.micro | t3a.small | t3a.medium | t3a.large | t3a.xlarge | t3a.2xlarge
Compute optimizedC4c4.large | c4.xlarge | c4.2xlarge | c4.4xlarge | c4.8xlarge
Compute optimizedC5c5.large | c5.xlarge | c5.2xlarge | c5.4xlarge | c5.9xlarge | c5.12xlarge | c5.18xlarge | c5.24xlarge | c5.metal
Compute optimizedC5ac5a.large | c5a.xlarge | c5a.2xlarge | c5a.4xlarge | c5a.8xlarge | c5a.12xlarge | c5a.16xlarge | c5a.24xlarge
Compute optimizedC5adc5ad.large | c5ad.xlarge | c5ad.2xlarge | c5ad.4xlarge | c5ad.8xlarge | c5ad.12xlarge | c5ad.16xlarge | c5ad.24xlarge
Compute optimizedC5dc5d.large | c5d.xlarge | c5d.2xlarge | c5d.4xlarge | c5d.9xlarge | c5d.12xlarge | c5d.18xlarge | c5d.24xlarge | c5d.metal
Compute optimizedC5nc5n.large | c5n.xlarge | c5n.2xlarge | c5n.4xlarge | c5n.9xlarge | c5n.18xlarge | c5n.metal
Compute optimizedC6gc6g.medium | c6g.large | c6g.xlarge | c6g.2xlarge | c6g.4xlarge | c6g.8xlarge | c6g.12xlarge | c6g.16xlarge | c6g.metal
Compute optimizedC6gdc6gd.medium | c6gd.large | c6gd.xlarge | c6gd.2xlarge | c6gd.4xlarge | c6gd.8xlarge | c6gd.12xlarge | c6gd.16xlarge | c6gd.metal
Storage optimizedD2d2.xlarge | d2.2xlarge | d2.4xlarge | d2.8xlarge
Storage optimizedH1h1.2xlarge | h1.4xlarge | h1.8xlarge | h1.16xlarge
Storage optimizedI3i3.large | i3.xlarge | i3.2xlarge | i3.4xlarge | i3.8xlarge | i3.16xlarge | i3.metal
Storage optimizedI3eni3en.large | i3en.xlarge | i3en.2xlarge | i3en.3xlarge | i3en.6xlarge | i3en.12xlarge | i3en.24xlarge | i3en.metal
Accelerated computingInf1inf1.xlarge | inf1.2xlarge | inf1.6xlarge | inf1.24xlarge
Accelerated computingF1f1.2xlarge | f1.4xlarge | f1.16xlarge
Accelerated computingG3g3s.xlarge | g3.4xlarge | g3.8xlarge | g3.16xlarge
Accelerated computingG4g4dn.xlarge | g4dn.2xlarge | g4dn.4xlarge | g4dn.8xlarge | g4dn.12xlarge | g4dn.16xlarge | g4dn.metal
Accelerated computingP2p2.xlarge | p2.8xlarge | p2.16xlarge
Accelerated computingP3p3.2xlarge | p3.8xlarge | p3.16xlarge
Accelerated computingP3dnp3dn.24xlarge
Memory optimizedR4r4.large | r4.xlarge | r4.2xlarge | r4.4xlarge | r4.8xlarge | r4.16xlarge
Memory optimizedR5r5.large | r5.xlarge | r5.2xlarge | r5.4xlarge | r5.8xlarge | r5.12xlarge | r5.16xlarge | r5.24xlarge | r5.metal
Memory optimizedR5ar5a.large | r5a.xlarge | r5a.2xlarge | r5a.4xlarge | r5a.8xlarge | r5a.12xlarge | r5a.16xlarge | r5a.24xlarge
Memory optimizedR5adr5ad.large | r5ad.xlarge | r5ad.2xlarge | r5ad.4xlarge | r5ad.8xlarge | r5ad.12xlarge | r5ad.16xlarge | r5ad.24xlarge
Memory optimizedR5dr5d.large | r5d.xlarge | r5d.2xlarge | r5d.4xlarge | r5d.8xlarge | r5d.12xlarge | r5d.16xlarge | r5d.24xlarge | r5d.metal
Memory optimizedR5dnr5dn.large | r5dn.xlarge | r5dn.2xlarge | r5dn.4xlarge | r5dn.8xlarge | r5dn.12xlarge | r5dn.16xlarge | r5dn.24xlarge
Memory optimizedR5nr5n.large | r5n.xlarge | r5n.2xlarge | r5n.4xlarge | r5n.8xlarge | r5n.12xlarge | r5n.16xlarge | r5n.24xlarge
Memory optimizedR6gr6g.medium | r6g.large | r6g.xlarge | r6g.2xlarge | r6g.4xlarge | r6g.8xlarge | r6g.12xlarge | r6g.16xlarge | r6g.metal
Memory optimizedR6gdr6gd.medium | r6gd.large | r6gd.xlarge | r6gd.2xlarge | r6gd.4xlarge | r6gd.8xlarge | r6gd.12xlarge | r6gd.16xlarge | r6gd.metal
Memory optimizedu-xtb1u-6tb1.metal | u-9tb1.metal | u-12tb1.metal | u-18tb1.metal | u-24tb1.metal
Memory optimizedX1x1.16xlarge | x1.32xlarge
Memory optimizedX1ex1e.xlarge | x1e.2xlarge | x1e.4xlarge | x1e.8xlarge | x1e.16xlarge | x1e.32xlarge
Memory optimizedz1dz1d.large | z1d.xlarge | z1d.2xlarge | z1d.3xlarge | z1d.6xlarge | z1d.12xlarge | z1d.metal

General Purpose: General purpose instances provide a balance of compute, memory and networking resources, and can be used for a variety of diverse workloads. These instances are ideal for applications that use these resources in equal proportions such as web servers and code repositories.

Compute Optimized: Compute Optimized instances are ideal for compute bound applications that benefit from high performance processors. Instances belonging to this family are well suited for batch processing workloads, media trans-coding, high performance web servers, high performance computing (HPC), scientific modeling, dedicated gaming servers and ad server engines, machine learning inference and other compute intensive applications.

Memory Optimized: Memory optimized instances are designed to deliver fast performance for workloads that process large data sets in memory.

Accelerated Computing: Accelerated computing instances use hardware accelerators, or co-processors, to perform functions, such as floating point number calculations, graphics processing, or data pattern matching, more efficiently than is possible in software running on CPUs.

Storage Optimized: Storage optimized instances are designed for workloads that require high, sequential read and write access to very large data sets on local storage. They are optimized to deliver tens of thousands of low-latency, random I/O operations per second (IOPS) to applications.

What about AWS EC2 pricing?

AWS EC2 price varies with instance type and region. There are five ways to pay for Amazon EC2 instances: (i) On-Demand, (ii) Savings Plans, (iii) Reserved Instances, and (iv) Spot Instances. You can also pay for (v) Dedicated Hosts which provide you with EC2 instance capacity on physical servers dedicated for your use.

I suggest you to refer AWS official pricing page for your reference.

What is Amazon Machine Image (AMI)

An Amazon Machine Image (AMI) provides the information required to launch an instance. It is used to create virtual servers (Amazon EC2 instances) in the AWS environment. Different types of instances can be launched from a single AMI to support the hardware of the host computer used for the instance. We’ll create a separate article on AMI where we will dive deeper on it’s creation and functioning. We would request to stay tuned!

What is AWS tagging?

Tagging is an important aspect in AWS. Amazon Web Services allows customers to assign metadata to their AWS resources in the form of tags. It will help you to identify any AWS resource. AWS tag can be role based, application based or environment based.

AWS Key pair – What is it’s usefulness?

A key pair, consisting of a private key and a public key, is a set of security credentials that you use to prove your identity when connecting to an instance. Amazon EC2 stores the public key, and you store the private key. You use the private key, instead of a password, to securely access your instances. Anyone who possesses your private keys can connect to your instances, so it’s important that you store your private keys in a secure place.

What is AWS EBS?

Amazon Elastic Block Store (EBS) is an easy to use, high performance block storage service designed for use with Amazon Elastic Compute Cloud (AWS EC2) for both throughput and transaction intensive workloads at any scale. A broad range of workloads, such as relational and non-relational databases, enterprise applications, containerized applications, big data analytics engines, file systems, and media workflows are widely deployed on Amazon EBS.

What is AWS instance store?

An instance store provides temporary block-level storage for your instance. This storage is located on disks that are physically attached to the host computer. Instance store is ideal for temporary storage of information that changes frequently, such as buffers, caches, scratch data, and other temporary content, or for data that is replicated across a fleet of instances, such as a load-balanced pool of web servers.

An instance store consists of one or more instance store volumes exposed as block devices. The size of an instance store as well as the number of devices available varies by instance type.

What is the basic difference between EBS and instance store?

EBS volume is network attached drive which results in slow performance but data is persistent meaning even if you reboot the instance data will be there. Instance store instance store provides temporary block-level storage for your instance. The data on instance store will be lost with the stop-start of the AWS instance.

What does an EIP (Elastic IP Address) mean?

An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is associated with your AWS account. With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account.

What is the purpose of security group (SG)?

AWS Security Groups are a flexible tool to help you secure your Amazon EC2 instances. AWS Security Groups are just one of several tools AWS offers to help you secure your cloud environment, but that doesn’t mean AWS security is hands-off. You’re still responsible for securing your applications and data in the cloud, and that means you need to leverage additional tools, such as Threat Stack, to gain better visibility and take a proactive approach to security in the cloud.

Spin up your first AWS EC2 instance – Let’s dive deep!

You can spin up AWS EC2 instance in two different ways. You can spin it using AWS Management Console. Alternatively, you can spin an AWS ec2 instance using the AWS CLI. In this article, we will restrict our discussion on AWS Management Console only. We will dive deep on AWS CLI in a different article as this will require understanding on CLI setup and working principle.

Before you can launch and connect to an Amazon EC2 instance, you need to create a key pair, unless you already have one. You can create a key pair using the Amazon EC2 console, and then you can launch your EC2 instance.

To create a key pair

1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
2. In the navigation pane, choose Key Pairs.
3. Choose Create key pair.
4. For Name, enter a descriptive name for the key pair.
5. For File format, choose the format in which to save the private key.
6. Choose Create key pair.
7. The private key file is automatically downloaded by your browser.

To launch the EC2 instance

1: Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

2: Choose Launch Instance once you select your region and availability zone.

Availability Zone Selection
List of AWS AZ
Launch instance option – AWS EC2

3: Choose an Amazon Machine Image (AMI), find an Amazon Linux AMI at the top of the list and choose Select.

AWS-EC2- AMI Selection

4: Choose an Instance Type, choose Next: Configure Instance Details.

AWS EC2 – Instance Type

5: Configure Instance Details, provide the following information:

AWS EC2 – Instance Details
AWS EC2 – Instance Details#2

For Network, choose default VPC, for Subnet, choose a default subnet in any Availability Zone.

6: Choose Next: Add Storage.

AWS EC2 Storage

7: Choose Next: Add Tags.

AWS-EC2-Tagging

8: Name your instance and choose Next: Configure Security Group. You can create a new security group with default values.

AWS-EC2-Security-Group

9: Choose Review and Launch.

AWS-EC2-Review-And-Launch

10: Choose Launch.

AWS EC2 Launch

What are the common issues with AWS ec2 and their solution?

While launching AWS EC2 instance, mainly 3 types of issues are encountered.

AWS EC2: Instance limit exceeded

Description
You get the InstanceLimitExceeded error when you try to launch a new instance or restart a stopped instance.

Cause
If you get an InstanceLimitExceeded error when you try to launch a new instance or restart a stopped instance, you have reached the limit on the number of instances that you can launch in a Region. When you create your AWS account, we set default limits on the number of instances you can run on a per-Region basis.

Solution
You can request an instance limit increase on a per-region basis through AWS Support.

AWS EC2: Insufficient instance capacity

Description
You get the InsufficientInstanceCapacity error when you try to launch a new instance or restart a stopped instance.

Cause
If you get an InsufficientInstanceCapacity error when you try to launch an instance or restart a stopped instance, AWS does not currently have enough available On-Demand capacity to service your request.

Solution
To resolve the issue, AWS recommends the following:

  • Wait a few minutes and then submit your request again; capacity can shift frequently.
  • Submit a new request with a reduced number of instances. For example, if you’re making a single request to launch 15 instances, try making 3 requests for 5 instances, or 15 requests for 1 instance instead.
  • If you’re launching an instance, submit a new request without specifying an Availability Zone.
  • If you’re launching an instance, submit a new request using a different instance type (which you can resize at a later stage). For more information, see Changing the instance type.
  • If you are launching instances into a cluster placement group, you can get an insufficient capacity error. For more information, see Placement group rules and limitations.
  • Try creating an On-Demand Capacity Reservation, which enables you to reserve Amazon EC2 capacity for any duration. For more information, see On-Demand Capacity Reservations.
  • Try purchasing Reserved Instances, which are a long-term capacity reservation.

AWS EC2: Instance terminates immediately

Description
Your instance goes from the pending state to the terminated state immediately after restarting it.

Cause
The following are a few reasons why an instance might immediately terminate:

  • You’ve reached your EBS volume limit.
  • An EBS snapshot is corrupt.
  • The root EBS volume is encrypted and you do not have permissions to access the KMS key for decryption.
  • The instance store-backed AMI that you used to launch the instance is missing a required part (an image.part.xx file).

Solution

You can use the Amazon EC2 console or AWS Command Line Interface to get the termination reason.

To get the termination reason using the Amazon EC2 console

  • Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
  • In the navigation pane, choose Instances, and select the instance.
  • In the Description tab, note the reason next to the State transition reason label.

To address the issue

Take one of the following actions depending on the termination reason you noted:

  • If the reason is Client.VolumeLimitExceeded: Volume limit exceeded, you have reached your EBS volume limit. For more information, see Instance volume limits. To submit a request to increase your Amazon EBS volume limit, complete the AWS Support Center Create Case form.
  • If the reason is Client.InternalError: Client error on launch, that typically indicates that the root volume is encrypted and that you do not have permissions to access the KMS key for decryption. To get permissions to access the required KMS key, add the appropriate KMS permissions to your IAM user.

Frequently Asked Questions

How does AWS ec2 work?

EC2 enables on-demand, scalable computing capacity in the AWS cloud. Amazon EC2 instances eliminate the up-front investment for hardware, and there is no need to maintain any rented hardware. It enables you to build and run applications faster. You can use EC2 in AWS to launch as many virtual servers as you need.

Is Amazon EC2 really free?

Amazon EC2 is free to try. But, there is a charge for each instance type for a each region outside FREE tier. I suggest you to rely on AWS pricing page.

Is AWS EC2 a virtual machine?

An Elastic Compute Cloud (EC2) instance is a virtual server that you can use to run applications in Amazon Web Services (AWS).

How much does EC2 cost per month?

It depends on AWS instance type, the region you choose and the hours for which you keep your instance UP. In addition, you need to pay for the storage you use and for the network. We would recommend to rely on AWS pricing calculator in order to get an estimation of your AWS usage.

What is the cheapest AWS region?

Being that US East 1 (North Virginia) Region was one of the first Regions that was up and running, it is pretty much the cheapest Region in AWS. In fact, the cloud giant refers to it as US Standard. In general, it also has the most services available on the platform, as Amazon usually prefers initial rollout here.

AWS provides a very well documentation on AWS ec2. That documentation gets updated with time whenever an AWS service gets enhanced or launched! It is always a good idea to tune yourself with their documentation. Alternatively, you can also subscribe this blog that will notify you when a new article gets published.

If you like this article, please feel free to give a ‘Like’. Your feedback is our inspiration! Stay healthy & stay safe!


Tags: