Introduction To Cloud Computing - V
Introduction To Cloud Computing - V
Amazon Web Services (AWS) offers many compute services. This module will
discuss the highlighted services.
• Amazon ECS • Container-based • Spin up and run jobs more AWS Fargate reduces
• Amazon EKS computing quickly administrative
• AWS Fargate • Instance-based overhead, but you can
• Amazon ECR use options that give
you more control.
• AWS Elastic • Platform as a • Focus on your code (building Fast and easy to get
Beanstalk service (PaaS) your application) started.
• For web • Can easily tie into other
applications services—databases, Domain
Name System (DNS), etc.
How to decide?
– What is your application design?
– What are your usage patterns?
– Which configuration settings will you want to
manage?
Choosing the optimal compute
• service
The optimal compute service or services that you
use will depend on your use case
• Some aspects to consider –
– What is your application design?
– What are your usage patterns?
– Which configuration settings will you want to manage?
• Selecting the wrong compute solution for an
architecture can lead to lower performance
efficiency
– A good starting place—Understand the available
compute options
Amazon Elastic Compute Cloud (Amazon EC2)
Example uses of
Amazon EC2
instances
Application
server
Web server
Database
server
Game server
Mail server
Media server
Catalog Amazon EC2 instance
server
Photo by Taylor Vick on Unsplash
File server
Computing
On-premises servers server
Proxy server
Amazon EC2 overview
• Amazon Elastic Compute Cloud (Amazon
EC2)
– Provides virtual machines—referred to as
EC2 instances—in the cloud.
– Gives you full control over the guest
operating system (Windows or Linux) on
each instance.
• You can launch instances of any size into
an Availability Zone anywhere in the
world.
– Launch instances from Amazon Machine
Amazo Images (AMIs).
n EC2 – Launch instances with a few clicks or a line
of code, and they are ready in minutes.
• You can control traffic to and from
instances.
Launching an Amazon EC2 instance
This section of the
module walks through
nine key decisions to
make when you create
an EC2 instance by
using the AWS
Management Console
Launch Instance
Wizard.
t3.xlarge 4 16 EBS-Only
t3.2xlarg 8 32 EBS-Only
e
Select instance type: Based on use
case
1. AMI
AWS Cloud
2. Instance Type
Region
3. Network settings
Availability Zone Availability
4. IAM role 1 Zone 2
5. User data VPC
Public
6. Storage options Example: subnet
7. Tags specify to
8. Security group deploy the Instance
instance
9. Key pair Private
here subnet
4. Attach IAM role (optional)
• Will software on the EC2 instance need to interact
Choices made by with other AWS services?
using the – If yes, attach an appropriate IAM Role.
Launch Instance • An AWS Identity and Access Management (IAM)
Wizard:
role that is attached to an EC2 instance is kept in
an instance profile.
1. AMI
2. Instance Type
• You are not restricted to attaching a role only at
3. Network settings instance launch.
4. IAM role – You can also attach a role to an instance that
5. User data already exists.
6. Storage options
Example: Application
7. Tags attached on instance
8. Security group to can access
Role that grants
9. Key pair S3 bucket
Amazon Simple Instance
with
Storage Service
objects
(Amazon S3) bucket
access permissions
5. User data script (optional)
Choices made by User
using the data
Launch Instance #!/bin/bash
Wizard: yum update –y
yum install -y
1. AMI AMI Running
2. Instance Type
wget EC2
3. Network settings instance
• Optionally specify a user data script at instance
4. IAM role launch
5. User data
• Use user data scripts to customize the runtime
6. Storage options
environment of your instance
7. Tags
– Script runs the first time the instance starts
8. Security group
9. Key pair • Can be used strategically
– For example, reduce the number of custom AMIs that
you build and maintain
6. Specify storage
• Configure the root volume
Choices made by – Where the guest operating system is
using the
Launch Instance installed
Wizard: • Attach additional storage volumes
(optional)
1. AMI
– AMI might already include more than
2. Instance Type
one volume
3. Network settings
4. IAM role • For each volume, specify:
5. User data – The size of the disk (in GB)
6. Storage options
– The volume type
7. Tags
• Different types of solid state drives
8. Security group
(SSDs) and hard disk drives (HDDs) are
9. Key pair
available
– If the volume will be deleted when the
instance is terminated
– If encryption should be used
Amazon EC2 storage options
• Amazon Elastic Block Store (Amazon EBS) –
– Durable, block-level storage volumes.
– You can stop the instance and start it again, and the data will still be there.
• Amazon EC2 Instance Store –
– Ephemeral storage is provided on disks that are attached to the host
computer where the EC2 instance is running.
– If the instance stops, data stored here is deleted.
• Other options for storage (not for the root volume) –
– Mount an Amazon Elastic File System (Amazon EFS) file system.
– Connect to Amazon Simple Storage Service (Amazon S3).
Example storage options
• Instance 1
Host computer
characteristics – Amazon
Elastic Block
– It has an Amazon EBS
Store Instance
root volume type for (Amazon Store
the operating system. EBS) Attached as Attached as
– What will happen if the Root volume Storage volume
instance is stopped and 20-GB Instance Ephemera
then started again? volume 1 l
Attached as volume 1
Storage volume
Attached as
• Instance 2 500-GB Root volume
characteristics – volume
Instance Ephemera
– It has an Instance Store 2 l volume 2
root volume type for
the operating system.
– What will happen if the
instance stops (because
of user error or a
system malfunction)?
7. Add tags
• A tag is a label that you can assign to an AWS
Choices made by resource.
using the
– Consists of a key and an optional value.
Launch Instance
Wizard: • Tagging is how you can attach metadata to
1. AMI an EC2 instance.
2. Instance Type • Potential benefits of tagging—Filtering,
3. Network settings
automation, cost allocation, and access
4. IAM role
5. User data control.
6. Storage options
7. Tags Example:
8. Security group
9. Key pair
8. Security group settings
• A security group is a set of firewall rules
Choices made by that control traffic to the instance.
using the – It exists outside of the instance's guest OS.
Launch Instance
Wizard: • Create rules that specify the source and
which ports that network communications
1. AMI can use.
2. Instance Type
– Specify the port number and the protocol, such
3. Network settings
as Transmission Control Protocol (TCP), User
4. IAM role
Datagram Protocol (UDP), or Internet Control
5. User data
Message Protocol (ICMP).
6. Storage options
7. Tags – Specify the source (for example, an IP address or
8. Security group another security group) that is allowed to use
9. Key pair the rule.
Example rule:
9. Identify or create the key pair
• At instance launch, you specify an
Choices made by existing key pair or create a new key
using the
Launch Instance pair.
Wizard: • A key pair consists of – mykey.pem
– A public key that AWS stores.
1. AMI
– A private key file that you store.
2. Instance Type
3. Network settings • It enables secure connections to the
4. IAM role instance.
5. User data
6. Storage options
• For Windows AMIs –
7. Tags – Use the private key to obtain the
8. Security group administrator password that you need to
9. Key pair log in to your instance.
• For Linux AMIs –
– Use the private key to use SSH to
securely connect to your instance.
Amazon EC2 console view of a running EC2
instance
Another option: Launch an EC2 instance with the
AWS Command Line Interface
• EC2 instances can also be
created programmatically.
AWS Command
Line Interface
(AWS CLI)
• This example shows how
simple the command can be. Example command:
– This command assumes that the aws ec2 run-instances \
key pair and security group already --image-id ami-1a2b3c4d \
exist. --count 1 \
--instance-type c3.large \
--key-name MyKeyPair \
– More options could be specified. --security-groups MySecurityGroup \
--region us-east-1
See the AWS CLI Command Refere
nce for details.
Amazon EC2 instance lifecycle
Only instances backed by Amazon
EBS
Launch Start
pending
AMI
Reboot Stop
rebooting running stopping stopped
Stop-
Hibernate
Termina
te
shutting-
down
terminat Terminate
ed
Consider using an Elastic IP address
• Rebooting an instance will • If you require a persistent
not change any IP addresses public IP address –
or DNS hostnames. – Associate an Elastic IP address
with the instance.
• Recommendations –
– Define and enforce cost allocation
tagging.
– Define metrics, set targets, and review
regularly.
– Encourage teams to architect for cost.
AWS CloudFormation
• An extension of the simple deployment model that
characterizes EC2 instances
• Introduces the concept of templates, which are
JSON formatted text files describing resources
needed to run an application
• Templates provide a simple way to build complex
systems and integrate EC2instances with other
AWS services such as S3, Simple DB, SQS, SNS,
Route53, Elastic Beanstalk, and others
How does it work?
AWS Lambda: Run code without
servers
AWS Lambda is a serverless compute service.
AWS HTTP
services endpo Your code Pay only for the
ints
Mobile apps
runs only when it iscompute time that
Run your code on a schedule
triggered you use
or in response to events
Benefits of Lambda
Function
code
Running of your
AWS code (only when it is
Lambda triggered)
Dependencies AWS Lambda
function
(code libraries,
etc.) Logging,
m onitoring,
and m e trics
Amazon
Execution CloudWatch
role
AWS Elastic Beanstalk
• An easy way to get web applications up and
running