Logo

dev-resources.site

for different kinds of informations.

Mastering AWS: Step-by-Step Guide to Deploying a Full-Stack React + Java Spring Boot App

Published at
11/20/2024
Categories
devops
aws
cloud
wittedtech
Author
wittedtech-by-harshit
Categories
4 categories in total
devops
open
aws
open
cloud
open
wittedtech
open
Author
21 person written this
wittedtech-by-harshit
open
Mastering AWS: Step-by-Step Guide to Deploying a Full-Stack React + Java Spring Boot App

AWS can feel like a labyrinth, but don’t worry—we’ll navigate it together. This guide takes you step-by-step through deploying a modern React + TailwindCSS + TypeScript frontend and a Java Spring Boot backend with SQL and NoSQL databases . By the end, your app will be running live, scalable, and secure in the AWS cloud.


1. Setting Up AWS: Preparing for Deployment 1.1. Creating Your AWS Account

  1. Head to AWS Signup .

  2. Create an account with billing enabled.

  3. Opt for Free Tier , but note some services may incur costs (we’ll mention where).
    1.2. IAM: Who Gets What Access

  4. Why: To secure your AWS environment by controlling access.

  • How:
    1. Open the IAM Management Console .
  1. Create a new IAM user:
    • Name: DevUser.
- Assign **AdministratorAccess**  policy (for now).
Enter fullscreen mode Exit fullscreen mode
  1. Set up Multi-Factor Authentication (MFA) for added security.

2. Building the Frontend: Static Hosting Done Right 2.1. Hosting React Static Files on S3

  1. What to Do: Build your React app using Vite:
npm run build
Enter fullscreen mode Exit fullscreen mode

This creates a dist/ directory containing your static files.

  1. S3 Setup:
    • Go to S3 Console → Create Bucket .
  • Bucket Name: my-react-app.

  • Enable public access for static hosting:

    • Under Permissions , uncheck "Block all public access."
    • Add a Bucket Policy :
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-react-app/*"
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode
  • Enable Static Website Hosting in Properties :

    • Index document: index.html.
    • Error document: 404.html. 2.2. Configuring CloudFront
    • Why: To cache and serve your app globally with HTTPS.
  1. How:
    • Open the CloudFront Console → Create Distribution .
  • Origin: Select your S3 bucket.

  • Enable SSL/TLS using AWS Certificate Manager .

  • Route traffic from https://www.myapp.com to this CloudFront distribution.


3. Backend Hosting: Spring Boot on AWS 3.1. EC2 Instance for Backend

  1. Launch EC2 Instance:
    • Go to EC2 Console → Launch Instance .
  • Select Amazon Linux 2 AMI (or Ubuntu).

  • Instance Type: t2.micro (Free Tier eligible).

  • Key Pair: Create or use an existing one for SSH access.

  • Configure Security Group:

    • Allow inbound traffic on port 8080 (for backend APIs).
  • Launch the instance.

  1. Install Java and Deploy Spring Boot:
    • SSH into your instance:
ssh -i my-key.pem ec2-user@<ec2-instance-public-ip>
Enter fullscreen mode Exit fullscreen mode
  • Install Java:
sudo yum update -y
sudo amazon-linux-extras enable corretto8
sudo yum install java-1.8.0-amazon-corretto -y
Enter fullscreen mode Exit fullscreen mode
  • Deploy your app:
java -jar your-springboot-app.jar
Enter fullscreen mode Exit fullscreen mode

3.2. Load Balancing with ALB

  1. Why: To ensure availability and distribute traffic across multiple EC2 instances.

  2. How:

    • Go to EC2 Console → Load Balancers → Create Application Load Balancer .
  • Configure:

    • Listener: HTTP (port 80).
    • Target Group: Add your EC2 instance(s).
  • Route traffic from the ALB DNS to your backend.


4. Database Configuration: RDS and DynamoDB 4.1. Relational Database with RDS

  1. Go to RDS Console → Create Database .

  2. Select:

  • Database Type: PostgreSQL (or MySQL/OracleDB).

  • Instance Class: db.t2.micro (Free Tier eligible).

  • Multi-AZ Deployment: Optional for production.

  1. Note the endpoint, username, and password.

  2. Connect Spring Boot:
    Update application.properties:

spring.datasource.url=jdbc:postgresql://<rds-endpoint>:5432/yourdb
spring.datasource.username=<username>
spring.datasource.password=<password>
Enter fullscreen mode Exit fullscreen mode

4.2. NoSQL with DynamoDB

  1. Go to DynamoDB Console → Create Table .
    • Table Name: UserDetails.
  • Partition Key: UserId.
  1. Use AWS SDK to interact with DynamoDB from your backend.

5. Logging and Monitoring 5.1. CloudWatch for Logs

  1. Install the CloudWatch Agent:
sudo yum install amazon-cloudwatch-agent
Enter fullscreen mode Exit fullscreen mode
  1. Configure CloudWatch in Spring Boot:
    • Add logback configuration :
<appender name="CLOUDWATCH" class="com.amazonaws.services.logs.logback.CloudWatchAppender">
  <logStreamName>SpringBootApp</logStreamName>
  <logGroup>BackendLogs</logGroup>
</appender>
Enter fullscreen mode Exit fullscreen mode

5.2. Alarms and Tracing

  • Set up CloudWatch Alarms for CPU usage, memory, etc.

  • Use X-Ray for distributed tracing across microservices.


6. Automating Deployments: CI/CD with AWS 6.1. CodePipeline + CodeBuild

  1. CodePipeline Setup:
    • Source: Connect to GitHub or CodeCommit.
  • Build: Add a CodeBuild project.

  • Deploy: Use S3 (frontend) and EC2 or Elastic Beanstalk (backend).

  1. CodeBuild Example Buildspec:
version: 0.2
phases:
  install:
    commands:
      - npm install
      - mvn clean install
  build:
    commands:
      - npm run build
      - mvn package
  post_build:
    commands:
      - aws s3 sync dist/ s3://my-react-app/
Enter fullscreen mode Exit fullscreen mode

7. DNS and Domain Management

  1. Route 53 for Custom Domain:
    • Register a domain (or use an existing one).
  • Create DNS records:

    • A Record: Point to CloudFront (frontend).
    • CNAME: Point to ALB (backend).

8. Testing and Scaling

  1. Use AWS Load Testing Tool for performance.

  2. Enable Auto Scaling Groups for EC2 instances.


AWS gives you superpowers , but with great power comes great responsibility. By following this guide, your project will be live, secure, and ready to scale at the speed of your users. Now, go forth and deploy like a cloud ninja!


Things To Keep In Mind: This Article is not a exact solution. You may face other difficulties along the way. What i tried to do is to create and enlighten the path of How AWS and its powers can be anchored to deploy your project over the clouds. Even after reading and gathering knowledge from this article, and still You Face any problem or you would like to discuss things further more DO WRITE A COMMENT or CONNECT WITH ME OVER OTHER SOCIAL PLATFORMS*. You can also **Email me*.

SOCIALS:

INSTAGRAM :: @___kunwar___ & @witted.tech
X || Twitter :: @harshitsinghHS

wittedtech Article's
30 articles in total
Favicon
Reflection API in Java: The Superpower You Didn’t Know You Had
Favicon
Decoding Java’s Unsafe Class: A Developer’s Secret Scroll
Favicon
Evolution of Spring Explained Like a Blockbuster Movie Marathon
Favicon
GraalVM: The Swiss Army Knife of the JVM World
Favicon
Custom Hooks in React: A Guide to Creation and Usage
Favicon
The Ultimate Guide to Sets in Java: Uncovering Every Secret of This Humble Data Structure
Favicon
Mastering AWS: Step-by-Step Guide to Deploying a Full-Stack React + Java Spring Boot App
Favicon
Comprehensive Guide to AWS Services and Their Applications
Favicon
Flex, Grid, and Positioning in CSS: The Ultimate Tailwind CSS Guide
Favicon
The Ultimate Guide to Arrays in Java: From Zero to Hero (With a Dash of Humor)
Favicon
The Ultimate Guide to Lists in Java: Everything You Need to Know
Favicon
The Complete Guide to Queue Data Structure in Java
Favicon
A Deep Dive into Java Maps: The Ultimate Guide for All Developers
Favicon
The Ultimate Guide to Trees in Java: From Roots to Branches (and Leaves, too!)
Favicon
The Ultimate Guide to Graphs in Java: A Deep Dive for Developers of All Levels
Favicon
JVM Tuning Explained: From Fresh Graduate to Seasoned Performance Jedi
Favicon
WhatsApp System Design: A Humorous Journey Through High-Level and Low-Level Architecture
Favicon
Unveiling the Backbone of YouTube Live Streaming: A Deep Dive into YouTube’s Architecture and Real-Time Video Processing
Favicon
🚀 Inside the Frontend Magic of YouTube: A Deep Dive into the Architecture Powering One of the World’s Largest Platforms
Favicon
Low-Level Design: The Blueprint to Winning Software Wars
Favicon
Load Balancers in Microservices: A Beginner's Guide with Code and Real-Life Examples
Favicon
🚀 Mastering Time and Space Complexity in DSA: Your Ultimate Guide 🚀
Favicon
Mastering DSA with Pen and Paper: Unplug and Think Like a Problem-Solver
Favicon
Ultimate Guide to the Best Resources, Books, and Problems for DSA Mastery: "Which I Personally Use."
Favicon
How to Start DSA (Data Structures & Algorithms) as a Beginner
Favicon
Mastering Constraints and Problem-Solving Strategies in DSA
Favicon
Java Streams: The Ultimate Guide for Complete Beginners
Favicon
Mastering Java 8 in One Go: A Fun Ride to Functional Paradise
Favicon
The Ultimate Guide to Designing a Database That Works (Seriously, We Mean It)
Favicon
Mastering Spring Security: A Comedy of Errors (and Authentication)

Featured ones: