spring-cloud/spring-cloud-function

Error when running a SpringBoot application in AWS Lambda

utibeng opened this issue · 1 comments

Versions: spring-cloud-function-adapter-aws 4.1.0. Java 19.

When I run a Spring Boot application in AWS lambda connecting to a postgress AWS RDS database, I get the error below:

{
"errorMessage": "Error creating bean with name 'batchDataSourceInitializer' defined in class path resource [org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration$DataSourceInitializerConfiguration.class]: Failed to instantiate [org.springframework.boot.autoconfigure.batch.BatchDataSourceScriptDatabaseInitializer]: Factory method 'batchDataSourceInitializer' threw exception with message: Unable to detect database type",
"errorType": "org.springframework.beans.factory.BeanCreationException"
} .

I have applications.properties with the following:
spring.datasource.url=jdbc:postgresql://XXX.rds.amazonaws.com:5432/postgres
spring.datasource.jdbcUrl=${spring.datasource.url}
spring.datasource.username=XXX
spring.datasource.password=XXX
spring.datasource.driver-class-name=org.postgresql.Driver

I have followed AWS guidance to set up the Lambda RDS connection including the RDS proxy, roles, etc

The application runs seamlessly on-prem, we are attempting to convert to serverless with AWS Lambda
I have successfully ran Spring Boot applications in lambda, without database connections. In fact, this error occurs when Hikari database connection pool is being initialised

Is there an example of using Spring Boot, AWS Lambda and a database connection? There isn't any currently in the examples

Given it is a first request related to connecting to AWS RDS database, can you please include the working version running locally with some in-memory DB and commented properties related to AWS RDS so we can work on it.
For the record we have not tested it with AWS RDS