Deployed a Highly Available Corporate Website

In today’s digital age, having a highly available corporate website is essential for businesses to reach their employees and customers alike. However, deploying such a website can be challenging, especially when it comes to scaling, maintenance, and automation. AWS CodeCommit, CodeDeploy, and CodePipeline can make this process much easier by automating the deployment and scaling of a website, making it highly available, and reducing maintenance time.

I received a client request to deploy a highly available corporate website on AWS to be automated with continual updates. This was first done by pushing the website’s code to an AWS CodeCommit repository from my local computer. CodeCommit is a fully managed source control service that makes it easy for any user to collaborate with a team and manage all code changes securely.

Next, I used CodeDeploy to deploy the website code to an autoscaling group of EC2 instances, which will ensure high availability and scalability. The EC2 instances will be launched from a custom AWS launch template with EC2 userdata that includes the CodeDeploy agent. The launch template will specify the minimum, desired, and maximum number of EC2 instances in the autoscaling group, with a policy that will trigger the average CPU utilization when it goes over 70% and a warmup time of 250 seconds.

Furthermore, I used an internet-facing application load balancer to distribute incoming traffic evenly among the EC2 instances in the autoscaling group, providing high availability and scalability. The load balancer will also automatically route traffic to healthy instances, reducing downtime and improving the website’s availability.

In addition, I automated the process of updating this website by using CodePipeline, which will automatically update the website when revisions are pushed to CodeCommit. This will save him time and reduce the risk of errors in updating the website manually.

During maintenance or when new features are being made to the website, I can deploy a maintenance banner to the website, notifying users of the temporary unavailability of the website. This can be done using CodeDeploy, which can automate the process of deploying the maintenance banner.

In conclusion, by using AWS CodeCommit, CodeDeploy, CodePipeline, and an EC2 autoscaling group, I can deploy a highly available corporate website with ease, ensuring high availability, scalability, and reducing maintenance time. The use of an internet-facing application load balancer will also improve the website’s availability and reduce downtime.

code

#!/bin/bash
# update linux then install apache server, git, ruby for code deploy and clone website files from codecommit
yum update -y
yum install -y git
yum install -y ruby
yum install -y wget
yum install -y httpd
systemctl start httpd
systemctl enable httpd

# download and install code deploy agent from specific bucket in assigned region
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
sudo ./install auto
cd /var/www/

# authorize codecommit credentials then clone repo
git config --global user.email "user_email" # Corrected the syntax for setting user email
git config --global user.name "username" # Corrected the syntax for setting username
git config --global credential.helper '!aws codecommit credential-helper $@'
git config --global credential.UseHttpPath true
git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/[repo_directory]

# Copy website files from the cloned repo directory to the Apache document root
cp -r /var/www/[repo_directory]/* /var/www/html/

# Output the path to the index.html file
echo "/var/www/html/index.html"

Appspec.yml File for CI/CD Automation in AWS CodeDeploy

 

code

version: 1.0
os: linux
files:
  - source: /
    destination: /var/www/procoreplusproduct
hooks:
  BeforeInstall:
    - location: scripts/install_dependencies.sh
      timeout: 300
      runas: root
  ApplicationStart:
    - location: scripts/start_server.sh
      timeout: 300
      runas: root
  ApplicationStop:
    - location: scripts/stop_server.sh
      timeout: 300
      runas: root

Appspec.yml File for CI/CD Automation in AWS

 

Ralph Quick Cloud Engineer

Ralph Quick is a professional Cloud Engineer specializing in the management, maintenance, and deployment of web service applications and infrastructure for operations. His experience ensures services are running efficiently and securely meeting the needs of your organization or clients.

Ready to Chat?

Let’s Socialize!

+1 (754) 214-7728

    3 + 15 =

    Share This