0% found this document useful (0 votes)
15 views86 pages

Lesson 03 Amazon Elastic Compute Cloud

Uploaded by

Gaurav Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views86 pages

Lesson 03 Amazon Elastic Compute Cloud

Uploaded by

Gaurav Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

AWS Developer Associate

Source: https://docs.aws.amazon.com/
Amazon Elastic Compute Cloud(EC2)
Learning Objectives

By the end of the lesson, you will be able to:

Launch an EC2 Instance and connect to it

Create an Amazon Machine Image(AMI)

Attach an Elastic Block Store(EBS) volume to an EC2


Instance

Back up Elastic Block Store volumes by creating Snapshots

Distribute workload across multiple resources using Elastic


Load Balancer(ELB)
Monitor your application using auto scaling

Work with different types of IP addresses for your instance


Amazon Elastic Cloud Computing
What is an EC2?

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

● Provides a virtual computing environment, known as Instance

● Availability of pre-configured template to launch your instance, known as AMI

● Various configurations of CPU, memory, storage, and networking capacity for


your instances, known as instance types

● Availability of different types of storage volume to store your data

● Firewall-enabled environment that enables you to specify the protocols, ports,


and source IP ranges to reach your instances using security groups

● 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

Reliable and Secure Cost Effective

Complete Compute
Complete Access
Solution

Elastic Web-Scale
Flexible
Computing
Benefits of Amazon EC2

Reliable and Secure

● For each Amazon EC2 Region, it provides 99.9% availability. The


instances are extremely efficient and can also be easily replaced
whenever required.

● 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

A user have numerous options to choose such as instance types,


software packages, operating system, etc. This means one have
multiple options to configure an instance as per one's need.
Benefits of Amazon EC2

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

Amazon EC2 can be easily integrated with other services such as


Amazon RDS, Amazon S3, and Amazon Simple Queue Service(SQS) that
results in a complete compute solution across a wide range of
applications
Benefits of Amazon EC2

Elastic Web-Scale
Computing

● With Amazon EC2, you can launch thousands of servers globally


within minutes.
● YOu can also simultaneously increase or decrease your storage
capacity
Amazon EC2: Purchasing Options

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.

On-Demand Instances are well suited for:

Users who prefer lower cost and


flexibility

Short-term, spiky, or volatile workload


applications

Applications built or tested for the first


time on Amazon EC2
Purchasing Options: Spot

Spot instance is the most cost efficient option you have with up to 90% discount. It
allows you to access the spare EC2 instances.

Spot Instances are well suited for:

Applications that have flexible start and


end times

Applications that are feasible at very low


compute prices

For large amount of additional load and


users with urgent computing
requirement
Purchasing Options: Reserved

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.

Reserved instances are well suited for:

Applications that are in steady state


and predictable usage

Applications that require reserved


capacity for a long term usage

Applications for which users are willing


to make upfront payment to reduce
their total computing cost, even further
Purchasing Options: Dedicated Host

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.

Dedicated hosts are well suited for:

Useful for the Software that have


complicated licensing model (BOYL)

This works best for the companies that


have strong compliance needs
Amazon EC2 Instance: Life Cycle

From the moment you launch an Amazon EC2 to its termination, an Amazon EC2
instance transitions through multiple states.

EBS - Backed Instances Only


Launch
Start
Pending

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

Firewall set up while launching an


instance

Operating system patches and


updates

IAM user access management

User Data security on your instance

Security of the infrastructure and


isolation of the physical host

Compliance validation

Hardware related issues

AWS
Amazon Machine Image
Amazon Machine Image (AMI)

An AMI provides the information required to launch an


EC2 instance. It is a template containing software
configuration and other parts required to set up an EC2
instance.
Amazon Machine Image

An AMI includes the following:

• A template for the root volume of the EC2 instance

• Launch permissions to control AMI launches by


different AWS accounts

• A block device mapping for the volume to be


attached when an instance is launched
Instances and AMIs

An Instance is a copy of an AMI


running as a virtual server in the
cloud. You can always launch multiple
instances using a single AMI
whenever you require multiple
instances having same configuration

You can launch any type of instance


using an AMI. An Instance type
determines the hardware of the host
computer. Each instance type offers
different memory and compute
capabilities

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

It also provides numerous software listings in common categories like security,


networking, storage, machine learning, business intelligence, databases, and also
in related professional categories
Creating Custom AMIs

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.

AMI #1 EC2 instance #1 AMI #2 EC2 instance #2

EBS root EBS root


EBS root EBS root
volume Launch Create volume Launch
volume volume
snapshot image snapshot instance
#1 #2
#1 instance #2

Step 1 Step 2 Step 3 Step 4 Step 5 Step 6 Step 7


AMI Distribution

An AMI can be:

● Private

● Shared with specific AWS accounts

● made public 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

EC2 EC2 EC2


Instance Instance Instance

Your AMI, its When you are


snapshot, and finished with
an instance is the instance,
launched from you can
the AMI. terminate it.
Amazon EC2 Instance: IP Addressing
IP Address Overview

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

An elastic IP address is a static IPv4 address designed for dynamic cloud


computing, it does not change over time. To use an elastic IP, you must allocate
one to your account and then associate it with your instance.

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:

AWS Management Console

Using AWS CLI

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

● When you associate an Elastic IP address to an instance, the public IP of


that instance will be released

● The disassociated Elastic IP from any resource will remain allocated to


the AWS account until that will be explicitly released

● An Elastic IP either comes from Amazon’s IPv4 address pool or a custom


IP pool brought by you to your AWS account

● 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

• Metadata is the information about the EC2 instance.


• The user data is the launch script of the EC2 instance.
Amazon EC2: User Data

● You can specify EC2 user data at the time of launching an instance

● The script only runs once when the instance starts

● EC2 User data is used to automate boot tasks such as:

❖ 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:

You are given a project to create a Linux-based EC2 instance.


Assisted Practice: Guidelines

Steps to perform to Create a Linux-based EC2 Instance:

1. Open the Amazon EC2 console.


2. Create an EC2 Instance and launch the instance.
3. Convert your private key to PuTTY using PuTTYgen.
4. Connect to your Linux Instance.
Assisted Practice
Create a Windows-based EC2 Instance

Duration: 20 Min.

Problem Statement:

You are given a project to create a Windows-based EC2 instance.


Assisted Practice: Guidelines

Steps to perform to create a Windows-Based EC2 Instance:

1. Open the Amazon EC2 console.


2. Create an EC2 Instance, and launch the instance.
3. Click on download remote desktop file and save it.
4. Connect to your Windows Instance.
Assisted Practice
Launch an EC2 Linux Instance including User Data

Duration: 25 Min.

Problem Statement:

You are given a project to launch an EC2 Linux Instance including user data.
Assisted Practice: Guidelines

Steps to perform to launch an EC2 Linux instance including user data:

1. Open the Amazon EC2 console


2. Configure an EC2 Instance including user data and launch the instance
3. Use the public IP to access the web server installed using User data in a new tab of your
browser
Assisted Practice
EC2 Instance Connect

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:

1. Open the Amazon EC2 console


2. Create an EC2 instance, and launch the instance
3. Click the Connect tab on the EC2 Dashboard to connect to your instance
Assisted Practice
Create a Custom AMI

Duration: 25 Min.

Problem Statement:

You are given a project to create a custom AMI.


Assisted Practice: Guidelines

Steps to perform to create a Custom AMI:

1. Create image commands from the Actions dropdown menu


2. Enter the information of the image, and create it
3. Verify the custom image that you have created
Assisted Practice
Launch an Instance Using a Custom AMI

Duration: 25 Min.

Problem Statement:

You are given a project to launch an instance using a custom AMI.


Assisted Practice: Guidelines

Steps to perform to launch an Instance using a Custom AMI:

1. Open the Amazon EC2 console


2. Choose AMIs from the navigation bar
3. Launch the instance using a custom AMI
Amazon EBS
Root Device Volume

When you launch an instance, the root device volume contains the image used to boot the
instance.

You can launch an instance from:


AM
I
● Instance store backed AMI
● Amazon EBS backed AMI

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

Here are some benefits of


using Amazon EBS
Instance Store

An instance store provides temporary block-level storage for your instance.

Instance
A
Instance
C
Instance
B

ephemeral ephemeral ephemeral ephemeral ephemeral ephemeral ephemeral ephemeral


0 1 2 3 0 1 2 3

Instance store Instance store

Host Computer 1 Host Computer 2


Amazon EBS vs Instance Store

Characteristics Amazon EBS Instance Store


Boot time Usually less than 1 minute Usually less than 5 minutes
Root device Amazon EBS volume Instance store volume
volume
Upgrading EBS-backed instances can be Instance store-backed instances cannot be
upgraded for instance type, upgraded
Kernel, RAM, and user data
AMI creation AMI can be easily created using AMI creation requires AMI tools and must
a single command to be executed from the running instance
Volume EBS volume can be attached as Instance store volume can be attached as
attachment additional volumes when the additional volumes only when the instance
instance is launched and even is launched and not when the instance is
when the instance is up and up and running
running
EBS Snapshot
EBS Snapshots

● A user can back up the data on their Amazon EBS volumes to


Amazon S3 by taking point-in-time snapshots

● A user can create a EBS volume based on a snapshot and the


new volume begins as an exact replica of the original volume

● Snapshots can be used to create a backup for critical


workloads

● Charges for snapshots are based on the data stored in it

● The status of an EBS snapshot can be tracked using EBS Snapshot


Cloudwatch Events
Features of EBS Snapshots

● Copy a snapshot from one AWS region to another or within the same region

● Encrypt your data with Amazon S3 server-side encryption (256-bit Advanced


Encryption Standard)

● 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

● If the EBS volume is encrypted, then the snapshot is also encrypted


Assisted Practice
Create and Attach an EBS Volume to a Linux Instance

Duration: 25 Min.

Problem Statement:

You are given a project to create and attach an EBS volume to a Linux instance.
Assisted Practice: Guidelines

Steps to perform to create and attach an EBS volume to a Linux instance:

1. Open the Amazon EC2 console


2. Choose Elastic Block Store, and then Volumes from the navigation pane
3. Create an EBS Volume
4. Attach an EBS Volume to a Linux Instance
5. Convert your private key to PuTTY using PuTTYgen
6. Connect to your Linux Instance
Assisted Practice
Create a Snapshot of an Existing EBS Instance

Duration: 10 Min.

Problem Statement:

You are given a project to create a snapshot of an existing EBS Instance.


Assisted Practice: Guidelines

Steps to perform to create a snapshot of an existing EBS instance:

1. Open the Amazon EC2 console


2. Choose Snapshots under Elastic Block Store in the navigation pane
3. Create Snapshot
Elastic File System
Elastic File System (EFS)

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

EFS supports Network


File System Version 4.0
and 4.1 protocol (NFSv4)

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

Benefits of Amazon EFS POSIX-compliant shared file storage

Security and compliance

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

Feature EFS EBS


Storage Size No limitation Maximum 16 TiB

Storage Type Object storage Block storage

Performance Scalable Hardly scalable

File Size Limitation Maximum file size of 47.9 TiB No limitation

Data Throughput Default throughput of 3 GB SSD- and HDD-backed storage types

Data Access Can be accessed concurrently Limited to single EC2 instance

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.

Auto Scaling group

Minimum size Scale out as needed

Desired capacity

Maximum size
Auto Scaling Benefits

Better fault tolerance

Amazon EC2 Auto Scaling can determine the


Increased application health of an instance. When found unhealthy, It
availability can terminate the instance and replace it with a
new one.

Better cost management


Auto Scaling Benefits

Better fault tolerance

Amazon EC2 Auto Scaling ensures that an


Increased application Application has the right amount of capacity to
availability handle unpredictable traffic.

Better cost management


Auto Scaling Benefits

Better fault tolerance

Amazon EC2 Auto Scaling adds or terminates


Increased application instances as needed. This helps in cost
availability optimization because you only pay for the EC2
instance you use.

Better cost management


Amazon Elastic Load Balancer
What Is Load Balancing?

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.

Amazon Elastic Load Balancer


Benefits of Amazon ELB

Below are the benefits offered by Amazon ELB:

Highly available

Scalable

Secure

Flexible
Types of Amazon Load Balancers
Types of Amazon Load Balancers

Amazon ELB offers the following types of load balancers:

Application load balancer Network load balancer

1 2 3

Classic load balancer


Application Load Balancer

Application load balancer is used for load balancing of HTTP


01
and HTTPS traffic.

Application load balancer routes traffic to targets within


02
Amazon Virtual Private Cloud (Amazon VPC) based on the
content of the request.

03 Application load balancer operates on layer 7.


Network Load Balancer

Network load balancer is used for load balancing of TCP, UDP,


01
and TLS traffic.

Network load balancer routes traffic to targets within Amazon


02
Virtual Private Cloud (Amazon VPC) regardless of the content
of the request.

03 Network load balancer operates on Layer 4.


Classic Load Balancer

Classic load balancer provides basic load balancing across


01
multiple Amazon EC2 instances.

02 Classic load balancer is best suited for applications built on


the EC2-Classic network.

03 Classic load balancer operates on both layer 4 and 7.


Assisted Practice
Set Up an Autoscaled Environment

Duration: 20 Min.

Problem Statement:

You are given a project to set up a autoscaled environment.


Assisted Practice: Guidelines

Steps to perform to set up an autoscaled environment:

1. Go to your Amazon Console


2. Open the EC2 dashboard
3. Create a launch template
4. Create a launch configuration
5. Create an autoscaling group
6. Enable load balancing
Key Takeaways

Amazon EC2 is a cloud service that provides scalable computing


capacity in the Amazon Web Services (AWS) cloud.

An AMI provides the information specified by a user while


launching an instance.

There are two types of root volumes. EBS and EC2


Instances store.

You can back up your EBS volumes by creating snapshots

Amazon EC2 Auto Scaling helps a user maintain


application availability and allows automatic addition and
removal of EC2 instance according to the conditions
defined
Host your Website Inside your EC2 Instance

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

You might also like