AWS Cloud Developer Associate


SSH into EC2

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html

Follow this link to create key pair in .pem file.

For Linux/Mac
  • Copy Public IPv4 of the EC2 instance.
  • Create a directory with name like "aws-course" and CD into it.
  • Run explorer.exe . in WSL to open folder.
  • Run chmod 0400 <NameOfKeyPair.pem>
    • Example: chmod 0400 EC2Tutorial.pem
  • SSH into the EC2: ssh -i <NameOfKeyPair.pem> <InstanceUserame>@<PublicIPv4>
    • Example: ssh i EC2Tutorial.pem ec2-user@52.40.154.239
    • Note: -i means identity file
  • To quit: Ctrl C
  • To logout: Ctrl D
  • (Alternative) Connecting to SSH via AWS Console: Select the instance and click on "Connect"

Starting Linux 2 instance

#!/bin/bash

#########################################
# Use this for launching Amazon Linux 2 #
#########################################

# get admin privileges
sudo su

# install httpd (Linus 2 version)
yum update -y
yum install -y httpd.x86_64
systemctl start httpd.service
systemctl enable httpd.service
echo "Hello World from $(hostname -f)" > /var/www/html/index.html

Load Balancer

3 Types of load balancers:

  • Classic Load Balancer: HTTP, HTTPS, TCP
  • Application Load Balancer: HTTP, HTTPS, WebSocket
    • 7th layer
    • uses Target Groups (e.g. instances)
    • Can add rules, e.g. redirect different URL paths
  • Network Load Balancer: TCP, TLS, UDP
    • 4th layer

Cross-Zone Load Balancing: balance load across multiple AZs

Connection Draining: stop sending new requests to the instance which is deregistering (removing from ELB)

Auto Scaling Group (ASG):

  • able to increase/decrease EC2 instances on demand
  • Scaling Policy: rules for auto scaling