A Spring Boot application demonstrating AWS deployment using Elastic Beanstalk, RDS (PostgreSQL), and automated CI/CD via CodePipeline and CodeBuild.
| Component | Service |
|---|---|
| App Hosting | AWS Elastic Beanstalk (EC2 + Load Balancer + Autoscaling) |
| Database | AWS RDS (PostgreSQL) |
| CI/CD | AWS CodePipeline + CodeBuild |
| Source | GitHub (master branch) |
- AWS Console → RDS → Create database
- Engine: PostgreSQL
- Template: Free tier
- DB instance identifier:
postgres-springboot - Master username & password set
- Connectivity: Public access → Yes
- Create database
- AWS Console → Elastic Beanstalk → Create application
- Application name:
springboot-service - Platform: Corretto 21 (Java)
- Environment type: Load balanced
- Configure environment variables:
SPRING_PROFILES_ACTIVE=prodDB_URL= RDS endpointDB_USERNAME= RDS usernameDB_PASSWORD= RDS password
- Create environment
- AWS Console → CodeBuild → Create build project
- Source: GitHub → repository connect
- Buildspec: Use buildspec.yml from repo
- Artifacts: Amazon S3
- Configure environment variables:
DOCKER_USERNAME= Docker Hub usernameDOCKER_PASSWORD= Docker Hub password
- Create build project
- AWS Console → CodePipeline → Create pipeline
- Source stage: GitHub → master branch
- Build stage: CodeBuild project select
- Deploy stage: Elastic Beanstalk → environment select
- Create pipeline
- CodePipeline → Settings → Connections
- Create connection → GitHub
- Authorize AWS to access GitHub repo
Push to master → CodePipeline triggers → Docker Hub login → Maven build & test → JAR artifact → Elastic Beanstalk deploys
version: 0.2
phases:
install:
runtime-versions:
java: corretto21
commands:
- echo Installing Maven...
pre_build:
commands:
- echo Logging in to Docker Hub...
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
build:
commands:
- echo Building, Testing, and Packaging the application...
- mvn package
post_build:
commands:
- echo Build, Testing, and Packaging completed.
artifacts:
files:
- target/*.jar
discard-paths: yes
cache:
paths:
- '/root/.m2/**/*'- JUnit + Testcontainers — Integration tests real PostgreSQL Docker container spin up
- Tests cover Controllers, Repositories, and Services layer
- Docker Hub credentials configured in CodeBuild to pull PostgreSQL image for Testcontainers
| Profile | Usage |
|---|---|
dev |
Local development with RDS config |
local |
Local development with local DB config |
prod |
AWS production environment |
# Run with dev profile
mvn spring-boot:run -Dspring-boot.run.profiles=dev
# Run with local profile
mvn spring-boot:run -Dspring-boot.run.profiles=local
# Run with prod profile
mvn spring-boot:run -Dspring-boot.run.profiles=prodaws-deploy-application/
├── src/
│ ├── main/
│ │ ├── java/com/springboot/applicationtesting/
│ │ │ ├── controllers/ # REST Controllers
│ │ │ ├── repositories/ # JPA Repositories
│ │ │ └── services/ # Service Layer
│ │ └── resources/
│ │ ├── application.properties # Base config
│ │ ├── application-dev.properties # Dev profile (RDS)
│ │ ├── application-dev-example.properties # Dev config template
│ │ ├── application-local.properties # Local DB config
│ │ └── application-prod.properties # Prod profile config
│ └── test/
│ └── java/com/springboot/applicationtesting/
│ ├── controllers/ # Controller integration tests
│ ├── repositories/ # Repository tests
│ └── services/ # Service tests
├── buildspec.yml # CodeBuild configuration
├── pom.xml # Maven dependencies
└── README.md
Prerequisites: Java 21+, Maven, PostgreSQL, Docker
git clone https://github.com/MansiArora-dev/aws-deploy-application.git
cd aws-deploy-application
# Copy example config and fill in your values
cp src/main/resources/application-dev-example.properties \
src/main/resources/application-dev.properties
# Run with dev profile
mvn spring-boot:run -Dspring-boot.run.profiles=dev- Java 21 | Spring Boot | Maven
- AWS — Elastic Beanstalk, RDS, CodePipeline, CodeBuild
- PostgreSQL | Docker | Testcontainers | JUnit
Mansi Arora — Software Engineer