Introduction and Architectural Overview

Architectural Overview

In this workshop, we will deploy a complete Copia (Amazon Clone) application to the AWS environment. The architecture is designed to ensure High Availability, Scalability, and Security by using core AWS services.

Below is the overall architectural diagram of the project we will build:

Copia Project Architecture on AWS

AWS Services Used

Here is a list of the main services and their roles in this project:

Networking & Security

  • Amazon VPC (Virtual Private Cloud): This is the networking foundation for the entire project. We will create a VPC named copia-vpc to establish an isolated network environment, allowing complete control over the IP range, subnets, and route tables.

  • Public & Private Subnets:

    • Public Subnets: Used for resources that need to be accessed from the internet, such as the Application Load Balancer and the bastion/initial server.
    • Private Subnets: Used to house sensitive resources like the RDS database, preventing direct access from the internet to enhance security.
  • Security Groups: Act as a virtual firewall to control inbound and outbound traffic.

    • copia-sg: For the Web Server, allowing traffic from the internet on ports 80 (HTTP), 443 (HTTPS), and 8000 (FastAPI Backend), as well as port 22 (SSH) from your IP for administration.
    • copia-db-sg: For the Database, only allowing connections from servers within the copia-sg Security Group (or your admin IP) on port 5432 (PostgreSQL), ensuring the database is completely protected.

Database

  • Amazon RDS (Relational Database Service): Provides a fully managed PostgreSQL database. We will create an instance named copia-db in a Private Subnet, which simplifies operations, backups, and ensures security.

Compute & Scalability

  • Amazon EC2 (Elastic Compute Cloud): Provides virtual servers to run the FastAPI backend application. These servers will be placed in a Public Subnet (in this setup to assign public IPs and route simply).

  • AMI (Amazon Machine Image) & Launch Template:

    • We will configure a complete EC2 instance (installing Python, Git, etc.) and then create an AMI named copia-ami.
    • This AMI is then used in a Launch Template named copia-launch-template to serve as a “blueprint” for creating new servers automatically and consistently.
  • Application Load Balancer (ALB): Automatically distributes incoming traffic from users to multiple backend EC2 servers via a Target Group (copia-target-group on port 8000). The ALB also performs health checks to ensure requests are only sent to healthy instances.

  • Auto Scaling Group (ASG): Automatically adjusts the number of backend EC2 servers based on the actual load (e.g., ALB request count per target). When traffic increases, the ASG will automatically add new servers and will remove them when traffic decreases, helping to optimize costs and ensure performance.

Storage & Content Delivery

  • Amazon S3 (Simple Storage Service): Used to store the entire frontend source code (React build files: HTML, CSS, JavaScript, images) in a bucket named copia-fe. This bucket will be configured to function as a static website.

  • Amazon CloudFront: A Content Delivery Network (CDN) service that helps speed up and secure the frontend.

    • Frontend Distribution: Distributes static content from S3 website endpoint. We will configure custom error responses (403/404 path to /index.html with 200 OK) to support React Router.