Lesson 03 Amazon Elastic Compute Cloud
Lesson 03 Amazon Elastic Compute Cloud
Source: https://docs.aws.amazon.com/
Amazon Elastic Compute Cloud(EC2)
Learning Objectives
Amazon EC2 is one of the most significant AWS offerings that provides the cloud with
stable and resizable computing power. Amazon EC2 removes the need to invest in
hardware upfront, so that software can be built and implemented quickly.
Features of Amazon EC2
● Virtual networks known as Virtual Private Cloud(VPC) that can be created which
are logically isolated from the rest of the AWS cloud. You can also connect your
own network
Benefits of Amazon EC2
Complete Compute
Complete Access
Solution
Elastic Web-Scale
Flexible
Computing
Benefits of Amazon EC2
● Amazon EC2 works with Amazon VPCs that offer security and
robust networking capabilities for your resources.
Benefits of Amazon EC2
Complete Access
One can have complete access over an instance. One can anytime
start/stop instances as per the requirement. One can also interact with
an instance just like any other machine.
Benefits of Amazon EC2
Flexible
Cost Effective
AWS offers you pay as you go approach. The expense here is lower than
your on premises as you pay here only for the individual service you
need
Benefits of Amazon EC2
Complete Compute
Solution
Elastic Web-Scale
Computing
The following are the purchasing options offered by Amazon EC2 that helps you optimize
your cost based on your requirements:
● On-Demand
● Spot
● Reserved
● Dedicated Host
Purchasing Options: On-Demand
On-demand Instances only charges you for the compute capacity you use per
second. However, you can increase or decrease your compute capacity as per the
demand of your application.
Spot instance is the most cost efficient option you have with up to 90% discount. It
allows you to access the spare EC2 instances.
Amazon EC2 provides you an option to reserve your instance for a term of 1-3
years. You get upto 75% discount compared to on demand instance pricing.
An Amazon EC2 dedicated host is a physical host that is fully dedicated to run your
instances. When using dedicated host, you have visibility of the underlying socket,
the core of the hardware.
From the moment you launch an Amazon EC2 to its termination, an Amazon EC2
instance transitions through multiple states.
Reboot
Stop
Rebooting Running Stopping Stopped
Stop -
Terminating Hibernate
Shutting
Down
Terminate
Terminated
SSH Overview
SSH is a function used to control your remote machine or server using command
line. In AWS, an inbound rule is available for you to connect to your instance over
SSH (Port 22).
SSH
User
Shared Responsibility Model for EC2
Compliance validation
AWS
Amazon Machine Image
Amazon Machine Image (AMI)
source: https://docs.aws.amazon.com/
AWS Marketplace
The AWS Marketplace is an online store where customers can search, buy, deploy,
and manage software, data, and services that run on AWS from third-party
vendors, to help customers manage and maintain solutions
You can create a Custom AMI that contains the configuration as per your requirement.
To create a custom AMI, you must launch an instance first, customize the instance, and
then save this updated configuration as a custom AMI.
● Private
Specific AWS
Accounts
Public
AMI
Deregistering an AMI
A user can deregister an AMI after using it. Once deregistered, you can
not launch an instance using that AMI.
EBS EBS
snapshot snapshot
Delete
Deregister the
the AMI snapshot
AMI
When a user launch an instance, AWS allocates a private and a public IPv4 address
for that instance. By default, Amazon EC2 uses the IPv4 addressing protocol. A
user can not disable this behavior.
Private IPs are not reachable over internet. Although, it can be used to
communicate between instances on the same virtual private network.
To access the internet, you can use a public IP address. Public IP addresses are
used for communication between your instances and the Internet.
Elastic IP Address
You can disassociate and elastic IP from a resource and then reassociate it with a
different resource.
A user can allocate an elastic IP address using any of the below methods:
Using Powershell
Note
There is a default limit of 5 Elastic IP addresses per region for all the AWS
accounts.
Elastic IP Address Characteristics
● Elastic IPs are static in nature and do not change over time
● Elastic IP address limit does not count when you allocate an Elastic IP
from the custom pool you have purchased
● Elastic IP addresses are region specific which means you can not move it
to a different region
EC2 Instance: Metadata
EC2 Instance: Metadata
● Instance metadata is the data that you use to configure your instance while
launching
● Metadata can be divided in different categories such as host name, events and
security group
● You can also use instance metadata to access user data that you specified while
launching your instance
Note
● You can specify EC2 user data at the time of launching an instance
❖ Installing updates
❖ Installing software
❖ Downloading files from the internet
● Only if the root volume is an EBS volume, user data can be changed
for an instance that is stopped
Assisted Practice
Create a Linux-based EC2 Instance
Duration: 30 Min.
Problem Statement:
Duration: 20 Min.
Problem Statement:
Duration: 25 Min.
Problem Statement:
You are given a project to launch an EC2 Linux Instance including user data.
Assisted Practice: Guidelines
Duration: 25 Min.
Problem Statement:
You are given a project to SSH a Linux EC2 Instance using EC2 Instance connect.
Assisted Practice: Guidelines
Steps to perform to SSH a Linux EC2 instance using EC2 instance connect:
Duration: 25 Min.
Problem Statement:
Duration: 25 Min.
Problem Statement:
When you launch an instance, the root device volume contains the image used to boot the
instance.
Instance Store
Elastic Storage
(EBS)
Amazon
S3
Elastic Block Storage
Amazon Elastic Block Store (Amazon EBS) provides persistent block-level storage volumes
to use with Amazon EC2 instances in the AWS cloud.
Data encryption
Data
Snapshots
persistence
Data Flexibility
availability
Instance
A
Instance
C
Instance
B
● Copy a snapshot from one AWS region to another or within the same region
● When Deleting a Snapshot, only the data exclusive to that snapshot is removed
● Active snapshots contain all the information required to restore your data (from
the time the snapshot was taken) to a new EBS volume
Duration: 25 Min.
Problem Statement:
You are given a project to create and attach an EBS volume to a Linux instance.
Assisted Practice: Guidelines
Duration: 10 Min.
Problem Statement:
Amazon Elastic File System (Amazon EFS) is a cloud-based file storage service that
provides a simple, scalable, and fully manageable elastic Network file system.
Amazon EFS
Elastic File System (EFS) Overview
With Amazon EFS storage, With EFS, the data is stored and
you pay only for what you accessed from all the Availability
use Zones in an AWS regions
Benefits of Elastic File System (EFS)
Scalable performance
Fully manageable
Cost effective
Dynamic elasticity
How Amazon EFS Works with Amazon EC2
The following illustration shows an example of a VPC accessing an Amazon EFS file
system:
Source: https://docs.aws.amazon.com/efs/latest/ug/how-it-works.html
Difference Between EFS and EBS
EFS vs. EBS
Availability Zone (AZ) Failure Can survive one AZ failure Cannot withstand AZ failure
without snapshots
Auto Scaling
Auto Scaling
Amazon EC2 Auto Scaling helps a user maintaining application availability by ensuring the
correct number of EC2 instance available to handle the load. Amazon EC2 scaling can launch
or terminate instance as per the demand of the application and the policies specified by the
user.
Auto Scaling Groups
A collection of EC2 Instances is called an Auto Scaling Group. A user can specify the
minimum and maximum number of Instance in each Auto Scaling group and
Amazon EC2 Auto Scaling ensures that your group never goes below or above the
specified size.
Desired capacity
Maximum size
Auto Scaling Benefits
Load balancing refers to the efficient distribution of incoming traffic across a group of
servers, available at backend.
Load
Internet Balancer
User
Server
What Is Amazon Elastic Load Balancer?
Amazon Elastic Load Balancer (ELB) is a load balancing service offered by AWS that
automatically distributes incoming traffic across multiple targets such as Amazon E2
Instances, containers and lambda functions in one or more availability zones.
Highly available
Scalable
Secure
Flexible
Types of Amazon Load Balancers
Types of Amazon Load Balancers
1 2 3
Duration: 20 Min.
Problem Statement:
Problem Statement:
You are asked to host a static website on EC2 instance by installing Apache
web server and uploading static pages to it via SSH
Tools required:
AWS EC2, Putty, Visual Studio Code/Notepad++
Expected Deliverables:
Screenshots for every steps