Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hardeepnarang10/466ac109e72e8ace5fed43bd8765210c to your computer and use it in GitHub Desktop.
Save hardeepnarang10/466ac109e72e8ace5fed43bd8765210c to your computer and use it in GitHub Desktop.
Guide for deploying an auto-scalable back-end solution for a high-availability website on AWS platform

Domain Notes:

  • Names are arbitrary values. Specified for our use case because CA performs component checks using name as identifiers.
  • Component creation is sequenced in a logical order based on dependency.
  • Launch Template (LTs) are templates and Launch Configuration (LCs) & Auto-Scaling Group (ASGs) are implementation of the said template.

Target Group:

  • Type: Instances.
  • Name: website-tg.
  • Protocol: TCP (Load balancer can only attach with TCP or UDP. HTTP and HTTPS are sub-protocol implementation of TCP).

Load Balancer:

  • Type: Network Load Balancer.
  • Name: website-lb.
  • Zones: Select all.
  • Target Group: website-tg.
  • After LB is created, goto LB dashboard and in the actions menu edit it's attributes to enable Cross-Zone Load Balancing.

Security Group:

  • Name: webserver-cluster-sg
  • Description: Webserver cluster security group.
  • Inbound Rules: Add SSH and HTTP rules with source originating from anywhere.
  • Outbound Rule: Change destination type of pre-existing rule to anywhere (just to be sure that our instances are able to access the internet).

Launch Template:

  • Name: webserver-cluster-lt
  • Description: Webserver cluster launch template
  • Checkbox: Provide guidance for use with EC2 Auto Scaling (Some of the LT fields are required by ASG which are otherwise considered optional. This option marks those fields as required).
  • AMI: Amazon Linux 2 x86
  • Instance Type: t3.micro
  • Network Settings: VPC.
  • Security Groups: webserver-cluster-sg.
  • User data/script:
#!/bin/bash
sudo yum update -y
sudo yum install -y httpd git
sudo git clone https://github.com/hardeepnarang10/ec2-mp-website.git /var/www/html/
sudo service httpd start

Auto-Scaling Group:

  • Name: webserver-cluster-asg
  • Launch template: webserver-cluster-lt
  • VPC: Available preconfigured option (Configuration here is he same as the one we did in the other VPC lab.
  • Subnets: Select all.
  • Load balancing: Attach to an existing load balancer.
  • Choose load balancer: webserver-lb.
  • Max Capacity: 4. Desired Capacity: 2.
  • Scaling policies: Target tracking scaling policy.
  • Metric type: Average CPU utilization (Scales based on what percentage of the CPU is being used).
  • Target value: 50 percent (Threshold value for scaling IN/OUT - configured with a relaxation time limit, the default value of 300 secs should be sufficient in our use case).

Copy the LBs' public DNS hostname and paste it in your browser followed by ':80'. The website should be up within 5 minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment