EC2 - Basics Flashcards
What is Amazon EC2?
- EC2 is one of the most popular AWS products
- EC2 =
Elastic Compute Cloud
= Infrastructure as a Service - It mainly consists in the capability of:
- Renting virtual machines (
EC2
) - Storing data on virtual drives (
EBS
) - Distributing load across machines (
ELB
) - Scaling the services using an auto-scaling group (
ASG
)
- Renting virtual machines (
-
Cost and Capacity Optimization
-Pay for What You Use
- Knowing EC2 is fundamental to understand how the Cloud works
What are EC2 sizing & configuration options?
Configuration how you want your EC2 Virtual instances to be:
* Operating System (OS
): Linux, Windows or Mac OS
* How much compute power & cores (CPU
)
* How much random-access memory (RAM
)
* How much storage
space:
* Network-attached (EBS & EFS
)
* hardware (EC2 Instance Store
- block-level storage physically attached to the host computer)
* Network card
: speed of the card, Public IP address
* Firewall rules
security group
* Bootstrap script (configure at first launch): EC2 User Data
What is EC2 User Data?
- It is possible to bootstrap our instances using an EC2 User Data script
-
Bootstrapping
means launching commands when a machine starts - That
script is only run once when the instance starts
- EC2 User Data is used to automate boot tasks such as:
Install updates
Installing software
Downloading common files from the internet
Anything you can think of
The EC2 User Data Script runs with the root user
How do you launch a EC2 Instance?
- Go to
EC2 Dashboard
- Click on
Launch Instance
- Enter
instance name
- Select the
OS Image
- Amazon Linux
- macOS
- Ubuntu
- Windows
- Red Hat
- SUSE Linux
- Debian
- Select the
OS machine image type
- Select the machine architecture
64-bit (x86)
or64-bit(ARM)
- Select
instance type
- t2.macro - Create SSH Key Pair to login to your EC2 Instance
- Network section will
create a VPC
with anauto assign public IP
- A default
Security Group
(firewall) will be automatically created calledlaunch-wizard-1
with the following rules:Allow SSH traffic from Anywhere 0.0.0.0/0
Allow HTTPs traffic from the internet
Allow HTTP traffic from the internet
- Configure
Storage
- free tier can get up to30 GB of EBS storage
- Advanced option:
Delete on termination is default to Yes
meaning if we terminate our EC2 instance the storage volume will be deleted
- Advanced option:
-
Advnace Details
:- Domain Active Directory (AD) creation
- IAM instance profile
- Hostname and DNS
- Instance behavior settings
- Metadata
- User Data
Launch instance
What are the methods to connect to your EC2 instance?
-
SSH
(OpenSSH - Mac, Linux, Windows > 10) -
Putty
(Windows < 10) -
EC2 Instance Connect
(web browser)
What are the available AWS SSH Keys and formats?
Two type of SSH Keys:
1. RSA
encryption
2. ED25519
encryption (not supported for Windows instances)
Two types of key file format:
1. .pem
- use with OpenSSH
(macOS, Linux, Windows 10+
)
2. .ppk
- use with PuTTY
(Windows < 10
)
How do you create and connect to EC2 with SSH?
- Go to EC2 Dashboard > Key Pairs
- Click
Create key pair
to create a new key pair - Download the
.pem
(OpenSSH) or.ppk
(PuTTy) - Open SSH client with command prompt
- Enter
ssh -i "./EC2_Instance_SSH_Keys.pem" ec2-34-228-11-197.compute-1.amazonaws.com
Note: If you’re getting WARNING: UNPROTECTED PRIVATE KEY FILE!
- remove all other user’s access to your SSH file
What is the EC2 Instance Type naming convention?
AWS has the following naming convention:
- m5.2xlarge
- m: instance class
- 5: generation (AWS improves them over time)
- 2xlarge: size within the instance class
What are the EC2 Instance types?
Instance vCPU Mem (GiB) Storage Network Perf EBS Bandwidth (Mbps)
1. t2.micro
1 1 EBS-Only Low to Moderate
2. t2.xlarge
4 16 EBS-Only Moderate
3. c5d.4xlarge
16 32 1 x 400 NVMe SSD Up to 10 Gbps 4,750
4. m5.8xlarge
32 128 EBS-Only 10 Gbps 6,800
5. r5.16xlarge
64 512 EBS-Only 20 Gbps 13,600
t2.micro is part of the AWS free tier (up to 750 hours per month)
How are EC2 optimized for different use case?
- Different types of EC2 instances optimized for different use cases:
- General Purpose
- Compute Optimized
- Memory Optimized
- Accellerated Computing
- Storage Optimized
- HPC Optimized
- Instance Features
- Measuring Instance Performance