###################################################################### Date: 27-July-2024 Session: 03 Topic: EC2 ###################################################################### => Elastic Compute Cloud => It is Most demanded service in AWS => It is Used to create Virtual Machines in AWS cloud => EC2 VM is called as EC2 instance EC2 Instance = Computer / Server / VM / Virtual Machine / V Box => EC2 instance is re-sizable (we can change configuration based on demand) => EC2 is a paid service (hourly billing) => EC2 VM Minimum billing period is 1 hour 9:00 AM to 9:15 AM => 15 mins => 1 hour billing 9:30 AM to 9:45 AM => 15 mins => 1 hour billing Note: To encourage beginners, AWS provided t2.micro/t3.micro for 1 year free (monthly 750 hours) => EC2 VM will have storage with EBS service Ec2 VM with Windows OS : 30 GB (default) EC2 VM with Linux OS : 8 GB (default) EBS max capacity : 16 TB (16000 GB) => For EC2 instances network will be provided by VPC service. => For EC2 vm creation we will use AMI (Amazon Machine Image) Note: AMI represents configuration required for machine - Windows AMI - Amazon Linux AMI - Ubuntu AMI - RedHAT AMI => To secure EC2 VM we will use Key-Pair (public key & private key) => To allow incoming and outgoing traffic for EC2 we will use Security Group Note-1 : One Key Pair we can use for multiple EC2 instances Note-2 : One Security Group (SG) we can use for multiple EC2 instances. =========================== Lab Practicals on EC2 VM =========================== 1) Create Key Pair (.pem file) - public key (aws will keep it) - private key (we will get it) 2) Create Security Group and update Inbound Rules to allow traffic Windows RDP : 3389 Linux SSH : 22 HTTP : 80 HTTPS : 443 MYSQL : 3306 3) Create EC2 Instance - Select AMI (Windows AMI) - Select Instance Type - Select Key Pair - Select Security Group - Select EBS Volume - Launch Instance 4) Connect to EC2 instance using RDP client. ============= Assignment ============= 👉 Linux VM Setup in AWS : https://www.youtube.com/watch?v=JMlQaTXvw5o 👉 Connect Linux VM with MobaXterm : https://youtu.be/uI2iDk8iTps?si=ZuZs0lQTxoRpbRMk 👉 Connect Linux VM with putty : https://youtu.be/GXc_bxmP0AA?si=HgSydrP89mPxv23s ###################################################################### Date: 29-July-2024 Session: 04 Topic: EC2 ###################################################################### => EC2 instances have below categories a) On Demand instances (no commitment) b) Reserved Instances (Booking for 1 or 3 years) c) Spot Request (bidding) d) Dedicated Host (Physical machine) =============================== Types of IP's in AWS Cloud =============================== => We have 3 types of IP's in AWS cloud 1) private ip 2) public ip 3) elastic ip => Private IP is a fixed IP in AWS. It is used for internal communication (With in VPC). => public ip is a dynamic IP in aws. It is used to connect with EC2 VM from outside. => When we restart our VM then public ip gets changed. private ip : 172.31.34.139 public ip : 13.127.100.70 (before re-start) public ip : 13.201.59.162 (after re-start) => If we want fixed public ip then we need to use Elastic IP. => Elastic IPs are commercial (bill will be generated). Elastic ip : 3.6.99.192 ============================== Lab Practicals on Elastic IP ============================= Step-1 : Allocate Elastic IP (Getting from AWS) Step-2 : Associate Elastic IP with EC2 VM Step-3 : Restart VM and check public ip (it will not change) Step-4 : De-Associate Elastic IP Step-5 : Release Elastic IP to AWS (to avoid billing) ###################################################################### Date: 30-July-2024 Session: 04 Topic: EBS ###################################################################### ============== What is EBS ============== => EBS stands for Elastic Block Store => It is block level storage device (Hard Disc / SSD) => When we create ec2 instance then ebs volume gets created automatically. Note: If we remove EBS volume from EC2 instance then we can't start/use that EC2 instance. => In EBS we have 2 types of volumes (storages) 1) Root Volume 2) Additional Volume Ntoe: When we launch EC2 instance by default we will get one Root volume. => Root volume is mandatory to launch EC2 instance. => If we remove root volume from EC2 then we can't start/use that instance. => Additional EBS volumes are optional devices (we can add/remove) => For windows VM, we will get 30 GB as default volume size. => For Linux VM, we will get 8 GB as default volume size. Note: EBS volume can have upto 16 TB for IOPS (io2) we have 65 TB. => One EC2 VM can have multiple EBS volumes. => One EBS volume can be attached to one EC2 VM at a time.. => EBS volumes are Availability Zone Specific Mumbai : ap-south-1 ap-south-1a ap-south-1b ap-south-1c ================= EBS Volume Types ================= => We have 5 types of EBS volumes 1) General Purpose Volume (Min: 1 GiB, Max: 16384 GiB) 2) Provisioned IOPS (io1) (Min: 4 GiB, Max: 16384 GiB) *(io2) => Min: 4 GiB, Max: 65536 GiB 3) Cold HDD (Min: 125 GiB, Max: 16384 GiB) 4) Throuput Optimized (Min: 125 GiB, Max: 16384 GiB) 5) Magnetic (standard) (Min: 1 GiB, Max: 1024 GiB) ==================================== Lab Task on EBS Additional Volumes ==================================== 1) Create EC2 VM (VM-1) (amazon linux ami) - we will get EBS root vol 8 GB 2) Create Additonal EBS Vol with 10 GB (check AZ) 3) Attach Additional Volume to EC2 VM-1 Note: Now EC2 Vm-1 will have 2 EBS volumes (root vol + additional vol) 4) Connect with VM-1 and check volumes attached $ lsblk 5) Store the data in additional volume using mounting with below commands $ sudo mkfs -t ext4 /dev/xvdb $ mkdir ashokit $ sudo mount /dev/xvdb ashokit $ cd ashokit $ sudo touch f1.txt f2.txt 6) Detach additional volume from EC2 VM-1 7) Create New EC2 VM (VM-2) and attach EBS additional volume to EC2 VM-2 8) Check the data is present or not. $ lsblk $ mkdir demo $ sudo mount /dev/xvdb demo $ ls -l demo Note: Once practice is completed, detach additional volume and delete it to avoid billing. ====================================================== Q-1) How to connect with EC2 when we lost pem file ? Q-2) How to recover EC2 vm when we lost pem file ? ====================================================== ========== Snapshots ========== => Snapshots are used for volumes backup - snapshots are region specific - volumes are AZ specific => From Volume we can create snapshot and from snapshot we can create volume volume ------> snapshot ---------> volume => Snapshot can't be attached to EC2 instance directley (volumes can be attached directley). ========================================================= Q) How to copy the data from 1a zone VM to 1b zone VM ? ========================================================= Step-1 : Create snapshot for 1a VM volume Step-2 : From snapshot create volume in 1b zone Step-3 : Attached newly created 1b volume to 1b VM. Note: We can automate snapshots creating using Life Cycle Manager. Frequency : Daily/Weekly/Monthly/Yearly ###################################################################### Date: 31-July-2024 Session: 04 Topic: Load Balancer ###################################################################### 1) what is userdata 2) hosting static website 3) load balancer 4) OSI model ================================= What is user-data in EC2 VM ? ================================= - It is used to execute script while launching ec2 machine. - User data will execute only once - Create EC2 VM (amazon linux) with below user data #! /bin/bash sudo su yum install httpd -y cd /var/www/html echo "