Skip to content

networknuts/awsproject

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AWSocial - S3, RDS, & EC2 Demonstration App

Welcome to the AWSocial demo! This application is designed specifically for AWS beginner students to understand how core AWS services interact with each other in a classic 3-tier web architecture.

Architecture Map

  • Frontend (EC2): A React application running on an EC2 instance, served via Vite.
  • Backend API (EC2): A Node.js/Express application running on an EC2 instance to interface securely with the database and S3.
  • Database (RDS): A PostgreSQL RDS instance to store relational data (Users, Posts).
  • Storage (S3): An AWS S3 Bucket used to store unstructured media (Images and Videos).

Step-by-step AWS Deployment Guide

Phase 1: Set up the Database (Amazon RDS)

  1. Navigate to RDS in the AWS Management Console and create a new database.
  2. Select PostgreSQL and the Free Tier template (if applicable).
  3. Set your Master Username (e.g., postgres) and Master Password. Make sure to remember these!
  4. Under Connectivity, ensure "Public access" is set according to your instructor's recommendation (usually Yes for simple beginner setups, with a strict Security Group).
  5. Once available, copy the Endpoint URL.
  6. Connect to the database using an SQL client (like pgAdmin or DBeaver) or the CLI, and run the SQL code found in db/schema.sql.

Phase 2: Set up Storage (Amazon S3)

  1. Navigate to S3 and create a new bucket (e.g., awsocial-media-bucket-xyz).
  2. Uncheck "Block all public access" if you want images to be publicly viewable directly via URL, and acknowledge the warning.
  3. Update the S3 Bucket Policy to allow public read access for the objects, so the frontend can load the images:
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "PublicReadGetObject",
                "Effect": "Allow",
                "Principal": "*",
                "Action": "s3:GetObject",
                "Resource": "arn:aws:s3:::<YOUR_BUCKET_NAME>/*"
            }
        ]
    }
  4. Record your Bucket Name and ensure that you have configured IAM credentials (Access Key ID and Secret Access Key) for a user with S3 upload permissions.

Phase 3: Set up Backend API (Amazon EC2)

  1. Launch an EC2 Instance (Amazon Linux 2 or Ubuntu).
  2. SSH into your instance.
  3. Install Node.js via NVM.
  4. Clone this repository (or copy the files) into the instance.
  5. Navigate to the backend folder: cd backend
  6. Install dependencies: npm install
  7. Create a .env file in the backend folder:
    PORT=8080
    
    # RDS Credentials
    DB_HOST=your-rds-endpoint.amazonaws.com
    DB_PORT=5432
    DB_USER=postgres
    DB_PASSWORD=your_password
    DB_NAME=postgres
    
    # S3 Credentials
    S3_BUCKET_NAME=your_bucket_name
    AWS_REGION=us-east-1
    AWS_ACCESS_KEY_ID=your_access_key
    AWS_SECRET_ACCESS_KEY=your_secret_key
  8. Run the backend: npm start (or use node server.js).
  9. Ensure your EC2 Security Group allows inbound traffic on port 8080.

Phase 4: Set up Frontend Web App (Amazon EC2)

  1. You can use the same EC2 instance or launch a separate one.
  2. Navigate to the frontend folder: cd frontend
  3. Install dependencies: npm install
  4. Create a .env file in the frontend folder:
    VITE_API_URL=http://<YOUR_BACKEND_EC2_PUBLIC_IP>:8080/api
  5. Run the development server: npm run dev -- --host
  6. Ensure your EC2 Security Group allows inbound traffic on port 5173 (Vite's default port).
  7. Visit http://<YOUR_FRONTEND_EC2_PUBLIC_IP>:5173 in your browser!

Testing the setup

Once everything is running, try making a post through the frontend GUI.

  • The text content is saved as a new row in your RDS Database.
  • The attached image or video is uploaded securely via your Backend EC2 to your S3 Bucket, and the resulting public S3 URL is saved in RDS to link them together.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 71.6%
  • CSS 26.4%
  • HTML 2.0%