🏗ī¸Configuration Lab Architectures

Configuration AWS

Configure Security Group

Create new SG for AWS EC2

Name    : SG-WebServerASG
Inbound Rules :
    - SSH      : Anywhere (IPv4)
    - HTTP     : Anywhere (IPv4)
    - HTTPS    : Anywhere (IPv4)
Outbound Rules :
    - All Trafic : Anywhere (IPv4)

Create new SG for AWS EFS

Name    : SG-EFS-LabASG
Inbound Rules :
    - NFS    : Custom (SG-WebServerASG)
Outbound Rules :
    - All Trafic : Anywhere (IPv4)

Create and Configure AWS EFS

Search and Create EFS Service

Name    : EFS-LabASG
"Customize"

##On the 1st slide, immediately click "Next"##

##Delete sg-default then change it to SG-EFSLabASG do it in all AZ##
Security Groups : SG-EFSLabASG

Get EFS mount script

Attach

Copy & paste attach script to notepad

##Using the EFS mount helper:##
sudo mount -t efs -o tls fs-012f18432a9d388f8:/ efs

##Using the NFS client:##
sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport fs-012f18432a9d388f8.efs.us-east-1.amazonaws.com:/ efs

Create a New EC2

Name    : EC2-For-ASG(Ubuntu)
OS      : Ubuntu22.04 (t2.small)
Keypair : vockey
Security Group : Select exiting security group "SG-WebServerASG"
Storage : 10GB

Configuration EC2

ssh to "EC2-For-ASG(Ubuntu)"

Install Software & Depedency

sudo apt install -y lsb-release apt-transport-https ca-certificates wget
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update && apt install -y software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update && sudo apt install -y php8.1

sudo apt-get install make 
wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz 
tar -xzvf openssl-1.0.2l.tar.gz 
cd openssl-1.0.2l 
sudo ./config
sudo make install 
sudo ln -sf /usr/local/ssl/bin/openssl `which openssl` 

sudo apt install python3
sudo apt install python3-pip
pip3 install requests

apt install curl -y
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"

sudo apt-get -y install apache2 php libapache2-mod-php8.1 php-fpm
sudo apt-get -y install git binutils cargo
sudo git clone https://github.com/aws/efs-utils
cd efs-utils
sudo ./build-deb.sh
sudo apt-get -y install ./build/amazon-efs-utils-2.0.1-1_all.deb

Configuration AWS

Create Own Custom AMI

Instance> Action> Image and Templates> Create Image

Image Name        : AMI-For-WebServer-ASG
Image Description : Ready installed apache2, PHP, efs-utils, git, and python3
"Create"

Create Launch Template

Launch Template Name         : LT-WebServerASG
Template version description : A template for running ASG aplication
My AMI  :
    #Owned by me : AMI-For-WebServer-ASG
Keypair : vockey
Security Group :
    #Selecting exiting security group : SG-WebServerASG

#Advance Detail#
#**Script for User Data**#

#!/bin/bash
sudo mount -t efs -o <efs-address>:/ /var/www/html
sudo git clone https://github.com/abdullahalfz18/default-apache2-on-ubuntu.git /var/www/html
sudo systemctl restart apache2

<efs-address> = fs-012f18432a9d388f8

Create new Target Group

Target group name : TG-For-ELBLabASG

#Advanced Healt Setting#
Healt check point : Traffic port
Healty threshold   : 2
Unhealty threshold : 2
Timeout            : 2
Interval           : 5

Create new Elastic Load Balancer (ELB)

Load Balancer Type : Aplication Load Balancer

Load Balancer name   : ELB-LabASG
Mappings             : Checklist for all availability zone
Security Group       : SG-WebServerASG
Listener and Routing : TG-For-ELBLabASG

Copy and save DNS ELB : ELB-LabASG-699876940.us-east-1.elb.amazonaws.com

Create new Autoscalling Group (ASG)

Auto Scalling Group Name   : ASG-WebServerLab
Launch Template            : LT-WebServerASG
Availability Zone & Subnet : Checklist for all availability zone

Load Balancing                      : Attach to an exiting load balancer
Attach to an exiting load balancer  : Choose from your load balancer target groups
Exiting load balancer target groups : TG-For-ELBLabASG

✅ Turn on elastic load balancing health check

Desired Capacity : 2
Minimun Capacity : 2
Maximum Capacity : 4

Add Tags:
Key   : Name
Value : EC2-WebServerASG

Last updated