AcademyCloudFoundations Module 06
AcademyCloudFoundations Module 06
Module 6: Compute
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module overview
Topics Activities
• Compute services overview • Amazon EC2 versus Managed Service
• Amazon EC2 • Hands-on with AWS Lambda
• Amazon EC2 cost optimization • Hands-on with AWS Elastic Beanstalk
• Container services
• Introduction to AWS Lambda Demo
• Introduction to AWS Elastic Beanstalk • Recorded demonstration of Amazon EC2
Lab
• Introduction to Amazon EC2
Knowledge check
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2
Module objectives
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 3
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS compute services
Amazon Web Services (AWS) offers many compute services. This module will discuss the highlighted services.
Amazon EC2 Amazon EC2 Amazon Elastic Amazon Elastic VMware Cloud
Auto Scaling Container Registry Container Service on AWS
(Amazon ECR) (Amazon ECS)
AWS Elastic AWS Lambda Amazon Elastic Amazon Lightsail AWS Batch
Beanstalk Kubernetes Service
(Amazon EKS)
• AWS Elastic • Platform as a service (PaaS) • Focus on your code (building your Fast and easy to get started.
Beanstalk • For web applications application)
• Can easily tie into other services—
databases, Domain Name System
(DNS), etc.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 6
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
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 7
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
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 server Amazon EC2 instances
Photo by Taylor Vick on Unsplash File server
Computing server
On-premises servers
Proxy server
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 11
1. Select an AMI
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 12
Creating a new AMI: Example
AWS Cloud
AMI details
Region A
Connect to the instance
and manually modify it or
run a script that modifies
Quick Start
the instance (for example,
or other
Launch an upgrade installed Capture as
existing AMI
Starter instance software) a new AMI
AMI
1 2 3
Unmodified Modified New
Instance Instance AMI
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 13
2. Select an instance type
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 14
EC2 instance type naming and sizes
t3.large 2 8 EBS-Only
t3.xlarge 4 16 EBS-Only
t3.2xlarge 8 32 EBS-Only
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 15
Select instance type: Based on use case
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 16
Instance types: Networking features
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 17
3. Specify network settings
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 18
4. Attach IAM role (optional)
Choices made by using the • Will software on the EC2 instance need to interact with other AWS
Launch Instance Wizard: services?
• If yes, attach an appropriate IAM Role.
1. AMI
• An AWS Identity and Access Management (IAM) role that is attached
2. Instance Type
to an EC2 instance is kept in an instance profile.
3. Network settings
4. IAM role • You are not restricted to attaching a role only at instance launch.
5. User data • You can also attach a role to an instance that already exists.
6. Storage options
7. Tags
8. Security group Example: Application on
9. Key pair attached to instance can
access
Role that grants Amazon
S3 bucket
Simple Storage Service Instance
with objects
(Amazon S3) bucket access
permissions
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 19
5. User data script (optional)
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 20
6. Specify storage
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 21
Amazon EC2 storage options
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 22
Example storage options
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 23
7. Add tags
Choices made by using the • A tag is a label that you can assign to an AWS
Launch Instance Wizard: resource.
• Consists of a key and an optional value.
1. AMI
2. Instance Type • Tagging is how you can attach metadata to an EC2
3. Network settings instance.
4. IAM role
5. User data • Potential benefits of tagging—Filtering,
6. Storage options automation, cost allocation, and access control.
7. Tags
8. Security group
Example:
9. Key pair
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 24
8. Security group settings
Choices made by using the • A security group is a set of firewall rules that control
Launch Instance Wizard: traffic to the instance.
• It exists outside of the instance's guest OS.
1. AMI
2. Instance Type • Create rules that specify the source and which ports
3. Network settings that network communications can use.
4. IAM role • Specify the port number and the protocol, such as
5. User data Transmission Control Protocol (TCP), User Datagram
6. Storage options Protocol (UDP), or Internet Control Message Protocol
7. Tags (ICMP).
8. Security group • Specify the source (for example, an IP address or another
9. Key pair security group) that is allowed to use the rule.
Example rule:
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 25
9. Identify or create the key pair
Choices made by using the • At instance launch, you specify an existing key
Launch Instance Wizard: pair or create a new key pair.
1. AMI • A key pair consists of – mykey.pem
2. Instance Type • A public key that AWS stores.
3. Network settings • A private key file that you store.
4. IAM role
5. User data
• It enables secure connections to the instance.
6. Storage options • For Windows AMIs –
7. Tags • Use the private key to obtain the administrator
8. Security group password that you need to log in to your instance.
9. Key pair
• For Linux AMIs –
• Use the private key to use SSH to securely connect to
your instance.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 26
Amazon EC2 console view of a running EC2
instance
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 27
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)
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 28
Amazon EC2 instance lifecycle
Launch Start
pending
AMI
Reboot Stop
rebooting running stopping stopped
Stop-
Hibernate
Terminate
shutting-
down
Terminate
terminated
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 29
Consider using an Elastic IP address
Elastic IP
Address
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 31
EC2 instance metadata
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 32
Amazon CloudWatch for monitoring
• Basic monitoring
• Default, no additional cost
• Metric data sent to CloudWatch every 5 minutes
• Detailed monitoring
• Fixed monthly rate for seven pre-selected metrics
• Metric data delivered every 1 minute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 33
• Amazon EC2 enables you to run Windows and
Section 2 key Linux virtual machines in the cloud.
35 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lab 3:
Introduction to
Amazon EC2
36 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lab 3 scenario
In this lab, you will launch and configure your first virtual machine that runs
on Amazon EC2.
AWS Cloud
Region
Availability Zone 1
Lab VPC
Public subnet
Web server
instance
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 37
Lab 3: Tasks
• Task 3 – Update Your Security Group and Access the Web Server
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 38
Lab 3: Final product
Amazon EC2
By the end of the lab, you will have:
1. Launched an instance that is configured as a
web server VPC
AMI
2. Viewed the instance system log
Security
3. Reconfigured a security group group
4. Modified the instance type and root volume t2.micro t2.small
size instance instance
Amazon Elastic
Block Store
(Amazon EBS)
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 39
Begin Lab 1: Introduction to AWS IAM
~ 35 minutes
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 40
Lab debrief:
Key takeaways
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 41
Activity: Amazon EC2
42 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity: Gather information
Amazon EC2 Amazon RDS
AWS Cloud
Availability Zone 1 Availability Zone 2
MS SQL Server MS SQL Server secondary
primary DB instance DB instance
Always-on
mirroring
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 43
Activity: Check your understanding
1. Between Amazon EC2 or Amazon RDS, which provides a managed service? What does managed service
mean?
• ANSWER: Amazon RDS provides a managed service. Amazon RDS handles provisioning, installation and
patching, automated backups, restoring snapshots from points in time, high availability, and monitoring.
2. Name at least one advantage of deploying Microsoft SQL Server on Amazon EC2 instead of Amazon
RDS.
• ANSWER: Amazon EC2 offers complete control over every configuration, the OS, and the software stack.
3. What advantage does the Quick Start provide over a manual installation on Amazon EC2?
• ANSWER: The Quick Start is a reference architecture with proven best practices built into the design.
4. Which deployment option offers the best approach for all use cases?
• ANSWER: Neither. The correct deployment option depends on your specific needs.
5. Which approach costs more: using Amazon EC2 or using Amazon RDS?
• ANSWER: It depends. Managing the database deployment on Amazon EC2 requires more customer oversight
and time. If time is your priority, then Amazon RDS might be less expensive. If you have in-house expertise,
Amazon EC2 might be more cost-effective.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 44
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon EC2 pricing models
Per second billing available for On-Demand Instances, Reserved Instances, and
Spot Instances that run Amazon Linux or Ubuntu.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 46
Amazon EC2 pricing models: Benefits
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 47
Amazon EC2 pricing models: Use cases
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 48
The four pillars of cost optimization
Cost Optimization
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 49
Pillar 1: Right size
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 50
Pillar 2: Increase elasticity
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 51
Pillar 3: Optimal pricing model
Pillars: Leverage the right pricing model for your use case
1. Right-Size • Consider your usage patterns
2. Increase Elasticity
Optimize and combine purchase types
3. Optimal pricing model
4. Optimize storage choices
Examples:
• Use On-Demand Instance and Spot Instances for variable
workloads
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 52
Pillar 4: Optimize storage choices
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 53
Measure, monitor, and improve
• Recommendations –
• Define and enforce cost allocation tagging.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 54
• Amazon EC2 pricing models include On-Demand
Section 3 key Instances, Reserved Instances, Spot Instances,
Dedicated Instances, and Dedicated Hosts.
takeaways
• Spot Instances can be interrupted with a 2-minute
notification. However, they can offer significant
cost savings over On-Demand Instances.
55 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Container basics
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 57
What is Docker?
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 58
Containers versus virtual machines
Three virtual machines on three EC2 instances
Example
VM 1 VM 2 VM 3
Three containers on one EC2 instance Container
App 1 App 2 App 3
Container Container Container
instance 1 Bins/Libs Bins/Libs Bins/Libs
instance 2 instance 3
Hypervisor
Part of
Host operating system AWS Global
Infrastructure
Physical server
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 59
Amazon Elastic Container Service (Amazon
ECS)
• Amazon Elastic Container Service (Amazon ECS) –
• A highly scalable, fast, container management service
• Integrated with features that are familiar to Amazon EC2 service users –
• Elastic Load Balancing
• Amazon EC2 security groups
• Amazon EBS volumes
• IAM roles
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 60
Amazon ECS orchestrates containers
EC2 instance
Requests to run containers
x3 x2
Container A
EC2 instance
Container B
Amazon Elastic Container
Service (Amazon ECS)
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. ECS cluster 61
Amazon ECS cluster options
• Key question: Do you want to manage the Amazon ECS cluster that runs the containers?
• If yes, create an Amazon ECS cluster backed by Amazon EC2 (provides more granular control over
infrastructure)
• If no, create an Amazon ECS cluster backed by AWS Fargate (easier to maintain, focus on your
applications)
Containers
Amazon ECS Container instance Container instance Container instance Amazon ECS cluster
cluster backed by 1 2 3 backed by Fargate
Amazon EC2 App 1 App 2 App 3
You manage
Bins/Libs Bins/Libs Bins/Libs
You manage
Docker engines (one per OS in the cluster)
AWS manages
VM guest operating systems in the Amazon ECS cluster
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 62
What is Kubernetes?
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 64
Amazon Elastic Container Registry (Amazon
ECR)
Amazon ECR is a fully managed Docker container registry
that makes it easy for developers to store, manage, and deploy
Docker container images. Amazon ECS integration
Docker support
Team collaboration
Amazon Elastic
Container Registry Access control
Third-party integrations
Image Registry
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 65
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Containers can hold everything that an application
Section 4 key needs to run.
66 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 67
AWS Lambda: Run code without servers
AWS Lambda is a serverless compute service.
AWS HTTP
services endpoints Your code Pay only for the
Mobile apps
runs only when it is compute time that
Run your code on a schedule
triggered you use
or in response to events
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 68
Benefits of Lambda
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 69
AWS Lambda event sources
Event sources Configure other AWS services as event sources to invoke
your function as shown here.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 70
AWS Lambda function configuration
Lambda function configuration
Function code
Amazon
Execution role CloudWatch
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 71
Schedule-based Lambda function example:
Start and stop EC2 instances
Stop instances example
Stop
IAM role
Time-based
1 CloudWatch 2 Lambda function 3 EC2 instances
event triggered stopped
Start
IAM role
Time-based
4 5 Lambda function 6 EC2 instances
CloudWatch
triggered started
event
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 72
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Event-based Lambda function example:
Create thumbnail images
AWS Cloud
1
2 3
User
Source Lambda 4
bucket
Execution
5
role
Access
policy
Target
bucket Lambda
function
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 73
AWS Lambda limits
Additional limits also exist. Details are in the AWS Lambda Limits documentation.
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 74
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Serverless computing enables you to build and run
Section 5 key applications and services without provisioning or
takeaways managing servers.
76 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity debrief:
key takeaways
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 77
Module 6: Compute
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Elastic Beanstalk
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 80
Benefits of Elastic Beanstalk
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 81
To complete this activity:
Activity: AWS
Elastic Beanstalk • Go to the hands-on lab environment and
launch the AWS Elastic Beanstalk activity.
82 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Activity debrief:
Key takeaways
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 83
• AWS Elastic Beanstalk enhances
Section 6 key developer productivity.
takeaways • Simplifies the process of deploying your
application.
• Reduces management complexity.
84 © 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module 6: Compute
Module wrap-up
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Module summary
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 86
Complete the knowledge check
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 87
Sample exam question
Which AWS service helps developers quickly deploy resources which can
make use of different programming languages, such as .NET and Java?
A. AWS CloudFormation
B. AWS SQS
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 88
Additional resources
© 2019 Amazon Web Services, Inc. or its Affiliates. All rights reserved. 89
Thank you
© 2019 Amazon Web Services, Inc. or its affiliates. All rights reserved. This work may not be reproduced or redistributed, in whole or in part, without prior written permission from Amazon
Web Services, Inc. Commercial copying, lending, or selling is prohibited. Corrections or feedback on the course, please email us at: [email protected]. For all other
questions, contact us at: https://aws.amazon.com/contact-us/aws-training/. All trademarks are the property of their owners.