This project consists of a webpage hosting solution on AWS using Infrastructure as Code (Terraform).
This solution implements a cloud architecture for hosting a simple webpage with the following features:
- High Availability: Multi-AZ deployment
- Global Low Latency: CloudFront distribution for edge caching
- Autoscaling: Dynamic adjustment of resources based on demand
- Security: IAM roles, security groups, and restricted access
- Infrastructure as Code: Complete implementation with Terraform
The architecture consists of three main layers:
- CloudFront: Content delivery network with global edge location caching
- S3: Object storage for static website content
- VPC: Network isolation with subnets across multiple AZs
- Internet Gateway: Direct connection between VPC and internet
- ALB: Application Load Balancer to distribute traffic
- Auto Scaling Group: Dynamic EC2 instance management
- EC2: Create instances running web servers
- Security Groups: Instance traffic control
- IAM: Identity and access management for permissions
- AWS Account (Free Tier eligible)
- Terraform
- AWS CLI
- Git (if cloning from repo)
web-host/
|––main.tf # Main Terraform configuration file
|––variables.tf # Variable definitions
|––outputs.tf # Output definitions
|––providers.tf # Provider configuration
|––user-data.sh # EC2 instance bootstrap script
|––index.html # Sample webpage content
|––README.md # Project documentation
-
Clone the repository (if using Git)
git clone https://github.com/mardlpz/web-host.git cd web-host -
Configure AWS credentials
The provider configuration for this program uses variables for AWS credentials, which allows for any of the following configuration options:
- Terraform prompt: when running
terraform plan/apply/destroy, you will receive a prompt to enter AWS access key and secret key - AWS CLI: run
aws configureto be prompted to set up credentials for Terraform to use terraform.tfvarsfile: create the file with content such as the following:aws_access_key = "YOUR_ACCESS_KEY" aws_secret_key = "YOUR_SECRET_KEY" region = "us-east-1"
- Terraform prompt: when running
-
Initialize Terraform
terraform init -
Plan deployment
terraform plan -
Apply the configuration
terraform apply -
Access webpage
Once
applyis complete, the ALB DNS and CloudFront domain name will be displayed as outputs in the terminal. Access to the S3 hosted website can be granted through either of these URLS.- Example:
alb_dns = "web-alb-1443665287.us-east-1.elb.amazonaws.com" cloudfront_url = "dniwj1yvqn1nf.cloudfront.net" s3_bucket = "web-bucket-dlbsepcp01-e"
To avoid unnecessary charges, destroy all resources when done testing or making use:
terraform destroy
- Webpage Content: replace web content in
index.htmlwith your own. - Region: modify
regionvariable invariables.tfor override it interraform.tfvarsaccording to needs. - Instance Type: change
instance_typevariable for different compute resources if desired. - Scaling Parameters: adjust Auto Scaling Group settings in
main.tffor different scaling configuration.
Possible future features to implement in this solution include:
- CloudWatch implementation to monitor, log, and trigger scaling events based on performance metrics
- Expansion to multiple regions for true global experience
- Route 53 with geolocation routing policy and health checks
- AWS CI/CD pipeline for auto-deployment
- Private subnets for further privacy
Mariana Del Pozo Patrón - 42308963
IU International University of Applied Sciences
Cloud Programming (DLBSEPCP01_E)