aws-rds-spring-boot-integration
giuseppe-trisciuoglio/developer-kit
Configure AWS RDS (Aurora, MySQL, PostgreSQL) with Spring Boot using HikariCP pooling, SSL, IAM auth, and Secrets Manager.
What is aws-rds-spring-boot-integration?
Provides patterns to configure AWS RDS databases with Spring Boot applications. Handles datasource configuration, connection pooling, read/write splitting, SSL encryption, and credential management. Use when setting up RDS connections, optimizing connection pools, or securing database authentication.
- Configure HikariCP connection pools for RDS workloads
- Implement read/write split routing with Aurora replicas
- Set up SSL/TLS encrypted connections to RDS
- Enable IAM database authentication
- Integrate AWS Secrets Manager for credential management
- Manage database migrations with Flyway
How to install aws-rds-spring-boot-integration
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill aws-rds-spring-boot-integration- Spring Boot application project
- Maven or Gradle build tool
- AWS RDS instance (Aurora, MySQL, or PostgreSQL)
- Database driver dependency (mysql-connector-j or postgresql)
How to use aws-rds-spring-boot-integration
- 1.Add Spring Data JPA, database driver, and Flyway dependencies to pom.xml or build.gradle
- 2.Configure datasource properties in application.yml with RDS endpoint, username, and password
- 3.Configure HikariCP pool settings (maximum-pool-size, minimum-idle, connection-timeout)
- 4.Enable SSL in datasource URL with appropriate sslmode parameter
- 5.Set up environment-specific profiles (dev/prod) in separate configuration files
- 6.Create Flyway migration scripts in src/main/resources/db/migration/
- 7.Run health check endpoint to validate database connectivity
- 8.Apply Flyway migrations after connectivity validation succeeds
Use cases
- Setting up Aurora MySQL or PostgreSQL datasources in Spring Boot applications
- Configuring connection pooling for production RDS workloads
- Implementing read replicas with write/read split routing
- Enabling SSL connections and IAM authentication for secure database access
- Managing database schema migrations with Flyway
- Spring Boot developers
- DevOps engineers managing RDS infrastructure
- Backend developers securing database connections
- Teams using AWS Aurora databases
aws-rds-spring-boot-integration FAQ
Aurora MySQL, Aurora PostgreSQL, and standard MySQL/PostgreSQL on RDS. Configuration differs slightly between engines; examples provided for both.
Implement a RoutingDataSource that routes write operations to the primary instance and read operations to read replicas, as shown in Example 3.
No. Use environment variables or AWS Secrets Manager instead. The examples show using ${DB_PASSWORD} for environment-based configuration.
Adjust maximum-pool-size based on RDS instance connection limits, set minimum-idle for connection warmth, and configure connection-timeout for failover scenarios.
Check security group rules allow traffic from your application, verify credentials and RDS accessibility, confirm SSL certificate configuration, and use the provided health check endpoint.
Full instructions (SKILL.md)
Source of truth, from giuseppe-trisciuoglio/developer-kit.
name: aws-rds-spring-boot-integration description: Provides patterns to configure AWS RDS (Aurora, MySQL, PostgreSQL) with Spring Boot applications. Configures HikariCP connection pools, implements read/write splitting, sets up IAM database authentication, enables SSL connections, and integrates with AWS Secrets Manager. Use when setting up RDS connections in Spring Boot, configuring connection pooling, or managing database credentials securely. allowed-tools: Read, Write, Edit, Bash, Glob, Grep
AWS RDS Spring Boot Integration
Overview
Configure AWS RDS databases (Aurora, MySQL, PostgreSQL) with Spring Boot applications. Provides patterns for datasource configuration, HikariCP connection pooling, SSL connections, environment-specific configurations, and AWS Secrets Manager integration.
When to Use
Use when configuring HikariCP connection pools for RDS workloads, implementing read/write split with Aurora replicas, setting up IAM database authentication, enabling SSL/TLS connections, managing database migrations with Flyway, or troubleshooting RDS connectivity issues.
Instructions
Follow these steps to configure AWS RDS with Spring Boot:
-
Add Dependencies — Include Spring Data JPA, database driver (MySQL/PostgreSQL), and Flyway
-
Configure Datasource — Set connection properties in application.yml
-
Configure HikariCP — Optimize pool settings for your RDS workload
-
Set Up SSL — Enable encrypted connections to RDS
-
Configure Profiles — Set environment-specific configurations (dev/prod)
-
Add Migrations — Create Flyway scripts for schema management
-
Validate Connectivity — Run health check to verify database connection
If validation fails: Check security group rules, verify credentials, ensure RDS is accessible from your network, and confirm SSL certificate configuration.
-
Run Migrations — Apply Flyway migrations only after connectivity validation passes
Quick Start
Step 1: Add Dependencies
Maven (pom.xml):
<dependencies>
<!-- Spring Data JPA -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Aurora MySQL Driver -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.2.0</version>
<scope>runtime</scope>
</dependency>
<!-- Aurora PostgreSQL Driver (alternative) -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<!-- Flyway for database migrations -->
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
<!-- Validation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
Gradle (build.gradle):
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
// Aurora MySQL
runtimeOnly 'com.mysql:mysql-connector-j:8.2.0'
// Aurora PostgreSQL (alternative)
runtimeOnly 'org.postgresql:postgresql'
// Flyway
implementation 'org.flywaydb:flyway-core'
}
Step 2: Basic Datasource Configuration
Use the configuration in the Examples section below. For PostgreSQL, change:
- Driver:
org.postgresql.Driver - URL:
jdbc:postgresql://...with?ssl=true&sslmode=require - Dialect:
org.hibernate.dialect.PostgreSQLDialect
Step 3: Set Up Environment Variables
# Production environment variables
export DB_PASSWORD=YourStrongPassword123!
export SPRING_PROFILES_ACTIVE=prod
# For development
export SPRING_PROFILES_ACTIVE=dev
Database Migration Setup
Create migration files for Flyway:
src/main/resources/db/migration/
├── V1__create_users_table.sql
├── V2__add_phone_column.sql
└── V3__create_orders_table.sql
V1__create_users_table.sql:
CREATE TABLE users (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_email (email)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Examples
Example 1: Aurora MySQL Configuration
spring:
datasource:
url: jdbc:mysql://myapp-aurora-cluster.cluster-abc123xyz.us-east-1.rds.amazonaws.com:3306/devops
username: admin
password: ${DB_PASSWORD}
driver-class-name: com.mysql.cj.jdbc.Driver
hikari:
maximum-pool-size: 20
minimum-idle: 5
connection-timeout: 20000
jpa:
hibernate:
ddl-auto: validate
open-in-view: false
Example 2: Aurora PostgreSQL with SSL
spring.datasource.url=jdbc:postgresql://myapp-aurora-pg-cluster.cluster-abc123xyz.us-east-1.rds.amazonaws.com:5432/devops?ssl=true&sslmode=require
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
spring.datasource.hikari.maximum-pool-size=30
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
Example 3: Read/Write Split Configuration
@Configuration
public class DataSourceConfiguration {
@Bean
@Primary
public DataSource dataSource(
@Qualifier("writerDataSource") DataSource writerDataSource,
@Qualifier("readerDataSource") DataSource readerDataSource) {
Map<Object, Object> targetDataSources = new HashMap<>();
targetDataSources.put("writer", writerDataSource);
targetDataSources.put("reader", readerDataSource);
RoutingDataSource routingDataSource = new RoutingDataSource();
routingDataSource.setTargetDataSources(targetDataSources);
routingDataSource.setDefaultTargetDataSource(writerDataSource);
return routingDataSource;
}
}
Constraints and Warnings
- HikariCP pool size must respect RDS instance connection limits
- Security groups must allow traffic from your application's IP range
- Use AWS Secrets Manager instead of hardcoding credentials
- Enable storage autoscaling to prevent storage exhaustion
Best Practices
- HikariCP: Enable leak detection and configure timeouts for failover scenarios
- Security: Enable SSL/TLS; use IAM Database Authentication when possible
- Performance: Disable open-in-view; use appropriate indexing and batch operations
- Monitoring: Enable Spring Boot Actuator with database health checks
Testing
Verify connectivity with this health check endpoint:
@RestController
@RequestMapping("/api/health")
public class DatabaseHealthController {
@Autowired
private DataSource dataSource;
@GetMapping("/db-connection")
public ResponseEntity<Map<String, Object>> testDatabaseConnection() {
Map<String, Object> response = new HashMap<>();
try (Connection connection = dataSource.getConnection()) {
response.put("status", "success");
response.put("database", connection.getCatalog());
response.put("connected", true);
return ResponseEntity.ok(response);
} catch (Exception e) {
response.put("status", "failed");
response.put("error", e.getMessage());
response.put("connected", false);
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).body(response);
}
}
}
curl http://localhost:8080/api/health/db-connection
Support
For detailed troubleshooting and advanced configuration, refer to:
Related skills
More from giuseppe-trisciuoglio/developer-kit and the wider catalog.

aws-sdk-java-v2-bedrock
Invoke Claude, Llama, and Titan models via AWS SDK for Java 2.x with streaming, embeddings, and Spring Boot integration.

aws-sdk-java-v2-core
AWS SDK for Java 2.x client setup with credential resolution, HTTP tuning, timeouts, retries, and testing patterns.

aws-sdk-java-v2-dynamodb
AWS SDK for Java 2.x patterns for DynamoDB CRUD, queries, batch operations, and transactions.

aws-sdk-java-v2-kms
AWS KMS encryption patterns for Java 2.x: key management, encryption, envelope encryption, and digital signatures.

aws-sdk-java-v2-lambda
Invoke, deploy, and manage AWS Lambda functions from Java applications using AWS SDK 2.x

aws-sdk-java-v2-messaging
AWS messaging patterns for SQS queues and SNS topics using Java SDK 2.x