Skip to content

Its-Lord-Stark/AwsS3FilesLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Amazon S3 Files Image Gallery

AWS infrastructure demonstrating Amazon S3 Files, Regional NAT Gateway, Terraform, Docker, Amazon ECR, Application Load Balancer and Auto Scaling Group.

Table of Contents

  • Project Overview
  • Architecture
  • Features
  • Tech Stack
  • Project Structure
  • Infrastructure Components
  • Deployment Workflow
  • Deployment Steps
  • Docker Workflow
  • Security
  • Validation
  • Troubleshooting
  • Future Improvements
  • Cleanup

Project Overview

This project demonstrates how we can use AWS S3 bucket as shared storage for an application on AWS using Infrastructure as Code.

The application serves images stored in Amazon S3 Files. Every EC2 instance launched by the Auto Scaling Group mounts the same shared storage, ensuring consistent content across all instances behind the Application Load Balancer.

Infrastructure is fully provisioned using Terraform.

Architecture

Arch

Request Flow:

Users → Internet → Application Load Balancer → Target Group → Auto Scaling Group → EC2 → Docker → Amazon S3 Files → Amazon S3

Features

  • Terraform Infrastructure as Code
  • Highly Available Architecture
  • Application Load Balancer
  • Auto Scaling Group
  • EC2 in Private Subnets
  • Dockerized Flask Application
  • Amazon ECR
  • Amazon S3 Files Shared Storage
  • Regional NAT Gateway

Tech Stack

Category Technology
IaC Terraform
Compute EC2
Container Docker
Registry Amazon ECR
Storage Amazon S3 Files
Networking VPC, ALB, NAT Gateway
Language Python Flask

Project Structure

app/
terraform/
Dockerfile
README.md

Infrastructure Components

VPC

Public and private subnets across two Availability Zones.

Application Load Balancer

Internet-facing load balancer deployed in public subnets.

Auto Scaling Group

Maintains EC2 instances across Availability Zones.

EC2

Runs Amazon Linux 2023 and Docker.

Amazon S3 Files

Mounted at /mnt/s3files and bind-mounted into the container as /app/dataset.

Regional NAT Gateway

Provides outbound internet connectivity for private EC2 instances.

Deployment Workflow

Terraform Apply → Create Networking → Create IAM → Create ALB → Create Launch Template → Create ASG → Launch EC2 → User Data → Install Docker → Mount Amazon S3 Files → Pull Image from ECR → Start Container → ALB Health Check

Deployment Steps

  1. Clone the repository.
  2. Build the Docker image.
  3. Push the image to Amazon ECR.
  4. Run terraform init.
  5. Run terraform plan.
  6. Run terraform apply.
  7. Wait for Auto Scaling to launch EC2 instances.
  8. Access the application using the ALB DNS name.

Validation

docker ps
df -h
curl localhost:5000/health

Cleanup

terraform destroy

About

Lab of Amazon S3 Files that provides option by exposing S3-backed storage through a filesystem interface. Existing applications can continue reading and writing files from a mounted directory without being rewritten to interact directly with S3, making it easier to use S3-backed storage with applications that expect a traditional filesystem.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages