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.
- 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).
- Navigate to RDS in the AWS Management Console and create a new database.
- Select PostgreSQL and the Free Tier template (if applicable).
- Set your Master Username (e.g.,
postgres) and Master Password. Make sure to remember these! - Under Connectivity, ensure "Public access" is set according to your instructor's recommendation (usually Yes for simple beginner setups, with a strict Security Group).
- Once available, copy the Endpoint URL.
- 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.
- Navigate to S3 and create a new bucket (e.g.,
awsocial-media-bucket-xyz). - Uncheck "Block all public access" if you want images to be publicly viewable directly via URL, and acknowledge the warning.
- 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>/*" } ] } - 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.
- Launch an EC2 Instance (Amazon Linux 2 or Ubuntu).
- SSH into your instance.
- Install Node.js via NVM.
- Clone this repository (or copy the files) into the instance.
- Navigate to the
backendfolder:cd backend - Install dependencies:
npm install - Create a
.envfile in thebackendfolder: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
- Run the backend:
npm start(or usenode server.js). - Ensure your EC2 Security Group allows inbound traffic on port
8080.
- You can use the same EC2 instance or launch a separate one.
- Navigate to the
frontendfolder:cd frontend - Install dependencies:
npm install - Create a
.envfile in thefrontendfolder:VITE_API_URL=http://<YOUR_BACKEND_EC2_PUBLIC_IP>:8080/api
- Run the development server:
npm run dev -- --host - Ensure your EC2 Security Group allows inbound traffic on port
5173(Vite's default port). - Visit
http://<YOUR_FRONTEND_EC2_PUBLIC_IP>:5173in your browser!
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.