Select Page

EC2 Essentials

by | AWS

“Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can deploy and deploy applications faster. You can use amazon EC2 to launch as many or as few virtual servers as you need. configure security and networking, manage storage. Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic.”

Simplified: Think of EC2 as your basic desktop computer.


EC2 Instance Components

  • AMIs (Linux/Windows)
  • Instance Type (Processing Power)
  • EBS (Local Storage)
  • IP Addressing (Internet Access)
  • Security Groups (Security)
  • RAM

Common Purchasing Options


On-demand purchasing allows you to choose any instance type you like and provision/terminate it at any time (on-demand)

  • Is the most expensive purchasing option.
  • Is the most flexible purchasing option.
  • You are only charged when the instance is running (and billed by the hour).
  • You can provision/terminate an on-demand instance at anytime.


Reserved purchasing allows you to purchase an instance for a set time period of one (1) or three (3) years.

  • This allows for a significant price discount over using on-demand.
  • You can select to pay upfront, partial upfront, no upfront.
  • Once you buy a reserved instance, you own it for the selected time period and are responsible for the entire price – regardless of how often you use it.


Spot pricing is a way for you to “bid” on an instance type and only pay for and use that instance when the spot price is equal to or below your “bid” price.

  • This option allows amazon to sell the use of unused instances, for short amounts of time, at a substantial discount.
  • Spot prices fluctuate based on supply and demand in the spot marketplace.
  • You are charged by the minute.
  • When you have an active bid, an instance is provisioned for you when the spot price is equal to or less than you bid price.
  • A provisioned instances automatically terminate when the spot price is greater than your bid price.


Free Tier use is avaiable for EC2.

  1. Purchased Options: (most common – not an inclusive list)
    • On-Demand
    • Reserved
    • Spot
  2. Instance Type – the instance’s processing capacity (think CPU);
    • General Purpose
    • Compute optimized
    • GPU optimized
    • Memory optimized
    • Storage Optimized
  3. EBS Optimized: (an option for higher IOPS performance)
  4. AMI Type – (think operating system):
    • Linux (price varies based on distro/software packages)
    • windows (price varies based on version/software packages)
  5. Data Transfer – in/out of the instance.
  6. Region the instance is provisioned in.

Amazon Machine Image (AMI)

AMI Definition

“An Amazon Machine Image (AMI) provides the information required to launch an instance, which is a virtual server in the cloud. You specify an AMI when you launch an instance, and you can launch as many instances from the AMI as you need. You can also launch instances from as many different AMIs as you need.”

Simplified: A preconfigured package required to launch and EC2 instance; includes an operating system, software packages and other required settings.

AMI Categories

AMIs come in three main categories:

Note:When you lanuch an EC2 Instance, the first thing you do is select an AMI

  • Community AMIs:
    • Free to use
    • Generally, with these AMIs you are just selecting the OS you want
  • AWS Marketplace AMIs:
    • Pay to use
    • Generally comes packaged with additional, licensed software
  • My AMIs:
    • AMIs that you create yourself

Instance Types


“When you launch an instance, the instance type that you specify 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 those capabilities. select an instance type based on the requirements or software that you plan to run on your instance.”

Simplified: The Instance Type is the CPU (computer power) of your instance.

Instance Type Components

  1. Family:
    • A way of categorizing instance types based on the what they are optimized to do
  2. Type:
    • Subcategory for each family type
  3. vCPUs:
    • The number of virtual CPUs the instances type uses
  4. Memory (GiB):
    • The amount of RAM the instance type uses
  5. Instance Storage (GB):
    • The local instance storage volume (your hard drive)
  6. EBS-Optimized Available:
    • Indicates is EBS-Optimized is an option for the instance type
  7. Network Performance:
    • Network Performance rating based on its data transfer rate (bandwidth capability)

EBS Volumes


“Amazon Elastic Block Store (Amazon EBS) provides block level storage volumes for use with EC2 instances. EBS volumes are highly available and reliable storage volumes that can be attached to any running instance that is in the same Availability Zone. EBS volumes that are attached to an EC2 instance are exposed as storage volumes that persist independently from the life of the instance.”

Simplified: EBS is a storage volume for an EC2 instance. (Think of it as a hard drive)


IOPS are a unit of measure representing Input/Output Operations per Second. The operations are measured in KiB, and the underlying drive determines the maximum amount of data that a volume type counts as a single I/O. I/O size is capped at 256 KiB for SSD volumes and 1,024 KiB for HDD volumes because SSD volumes handle small or random I/O much more efficiently than HDD volumes.”

The amount of data that can be written to or retrieved from EBS per second.

More IOPS means better volume performance (faster read/write speeds)

The larger the storage size (in GiB), the more IOPS the volume has – EBS volume size.

“Root” vs. Additional EBS Volumes

  1. Every EC2 instance MUST have a “root” volume, which may or may not be EBS.
  2. By default, EBS “root” volumes are set to be deleted when the instance is terminated. However, you can choose to have EBS volumes persist after termination.
  3. During the creation of an EC2 instance (or anytime afterward) you can add additional EBS Volumes to the instance.
  4. any additional volume can be attached or detach from the instance at any time, and is NOT deleted (be default) when the instance is terminated.

Note:This means that you can “swap” EBS volumes between different EC2 instances, by “detaching” it from one and “attaching” it to another.


  • A snapshot is an “image” of an EBS volume that can be stored as a backup of the volume OR used to create a duplicate.
  • A snapshot is NOT an active EBS volume. You cannot attach or detach a snapshot to an EC2 instance.
  • To restore a snapshot, you need to create a new EBS volume using the snapshot as its template.

Security Groups


“A security group acts as a virtual firewall that controls the traffic for one or more instances. When you launch an instance one or more security groups with the instance. You add rules to each security group that allow traffic to or from its associated instances. You can modify the rules for a security group at any time; the new rules are automatically applied to all instances that are associated with the security group. When we decide whether to allow traffic to reach an instance, we evaluate all the rules from all the security groups that are associated with instance.”

Simplified: Securiy Groups are very similar to NACLs in that they allow/deny traffic. However, security groups are found on the instance level (as opposed to the subnet level). In addition, the way allow/deny “rules” work are different from NACLs.

Inbound and Outbound Rules

  • All traffic is DENIED unless there is an EXPLICIT ALLOW rule for it.
  • There are no DENY rules – only ALLOW rules.

IP Addressing


“Amazon EC2 and Amazon VPC support both the IPv4 and IPv6 addressing protocols. By default, Amazon EC2 and Amazon VPC use the IPv4 addressing protocol; you can’t disable this behavior. When you create a VPC, you must specify an IPv4 CIDR block (a range of private IPv4 addresses). You can optionally assign an IPv6 CIDR block to your VPC and subnets, and assign IPv6 addresses from that block to instances in your subnet. IPv6 addresses are reachable over the Internet.”


  • Providing an EC2 instance with public IP address.
  • An IP address is the instance’s “address” on the network.
  • IPv6 is not supported for the EC2-Classic platform. IPv6 is currently supported in the US East (Ohio) region only.

Public vs. Private IP Addresses

Private IP Address

  • By default, All EC2 instances have a private IP address.
  • Private IP addresses allow for instances to communicate with each other as long as they are located in the same VPC (or broader private network).

Public IP Address

  • EC2 Instances can be launched with our without a public IP address (by default), depending on VPC/subnet settings.
  • Public IP addresses are REQUIRED for the instance to communicate with the Internet.

Note:The “default” VPC and subnets are configured so that any new instance that is provisioned has a public IP address,

Provisioning EC2

Launching an EC2 Instance

Basic Steps:

  1. Select an AMI
  2. Select an Instance Type
  3. Configure Instance Details:
    • We are going to use this opportunity to run a Bash Script that installs Apache.
  4. Add Storage
  5. Add a Tag (give the instance a name)
  6. Configuration/assign a Security Group
  7. Review & Launch
  8. Create & download a Key Pair

Logging in to Instance (SSH)

Basic Steps:

  1. Select the instance
  2. Under “Action”, choose “Connect”
  3. Follow the instructions
    1. Open a terminal to access the command line
    2. Navigate to the directory that contains the key pair downloaded
    3. Run the chmod command on the key pair to change its permissions
    4. Run the “example” command

You should now be connected to the instance