This project demonstrates how to host a static HTML website on AWS using various services as well as a secure and scalable architecture. The project includes a reference diagram, deployment scripts, and a detailed description of the AWS resources utilized.
In this project, a static website is deployed on AWS using an EC2 instance within a well-architected VPC. The deployment leverages multiple AWS services to ensure scalability, reliability, and security. The primary components used are EC2 instances, an Application Load Balancer, an Auto Scaling Group, a NAT Gateway, and Route 53.
The architecture consists of:
- Virtual Private Cloud (VPC):
Configured with public and private subnets across two availability zones. An Internet Gateway is deployed to facilitate connectivity between VPC instances and the Internet.
- Security Groups:
Implemented as network firewalls to control inbound and outbound traffic to EC2 instances.
- Subnets and Availability Zones:
Public subnets host infrastructure components like the NAT Gateway and Application Load Balancer. Private subnets house the web servers (EC2 instances) for enhanced security. Leveraged two Availability Zones to ensure system reliability and fault tolerance.
- EC2 Instances:
Hosted in private subnets and managed using an Auto Scaling Group to ensure high availability and scalability. An Application Load Balancer distributes traffic to EC2 instances across multiple Availability Zones.
- NAT Gateway:
Allows instances in private subnets to access the Internet.
- Application Load Balancer (ALB):
Distributes incoming traffic across multiple EC2 instances.
- Certificate Manager:
Used for securing application communications.
- Simple Notification Service (SNS):
Configured to alert about activities within the Auto Scaling Group.
- Route 53:
Used for DNS management and domain name registration.
The following script sets up an Apache HTTP server on an EC2 instance and deploys the static website from a GitHub repository.
#!/bin/bash
# Switch to the root user to gain full administrative privileges
sudo su
# Update all installed packages to their latest versions
yum update -y
# Install Apache HTTP Server
yum install -y httpd
# Change the current working directory to the Apache web root
cd /var/www/html
# Install Git
yum install git -y
# Clone the project GitHub repository to the current directory
git clone [email protected]:Shilyjunior/deploy-a-static-website-on-aws.git
# Copy all files, including hidden ones, from the cloned repository to the Apache web root
cp -R deploy-a-static-website-on-aws/. /var/www/html/
# Remove the cloned repository directory to clean up unnecessary files
rm -rf deploy-a-static-website-on-aws
# Enable the Apache HTTP Server to start automatically at system boot
systemctl enable httpd
# Start the Apache HTTP Server to serve web content
systemctl start httpd- Launch an EC2 instance in a private subnet within your VPC.
- SSH into the EC2 instance.
- Run the script above to install and configure the Apache HTTP server and deploy your static website.
- Repository URL: deploy-a-static-website-on-aws
This project showcases a comprehensive solution for hosting a static website on AWS, utilizing a variety of AWS services to deliver high availability, scalability, and robust security. For step-by-step guidance, configuration details, and visual representations, please explore the files and diagrams available in the GitHub repository.