java – No database instance with id: found. Please specify a valid db instance

java – No database instance with id: found. Please specify a valid db instance

I had the same problem.

spring-cloud-aws probably cant resolve the proper aws region on its own. If youre only on one region, insert this into your properties file with the region where your RDS instance is placed.

cloud.aws.region.static=us-east-1

This solved the problem for me.

You could also try with:

cloud.aws.region.auto=true

to see if the EC2 meta data service can resolve the correct region.

It is also possible to connect via. normal spring-boot settings, where you simply specify the RDS instance endpoint in the url of the datasource like so: (for a postgresql instance)

spring.datasource.url=jdbc:postgresql://endpoint.of.rds.instance.amazonaws.com:5432/dbname

and of course supply the datasource.platform, datasource.username, datasource.password, spring.database.driverClassName and spring.jpa.database in your application.properties aswell.

The accepted answer did not work for me.

After some debugging I found the application.properties as given in the question is not correct:

#RDS
cloud.aws.rds.mainrds #this line has to be deleted
cloud.aws.rds.mainrds.username=dbadmin
cloud.aws.rds.mainrds.password=password
cloud.aws.rds.mainrds.readReplicaSupport=false
cloud.aws.rds.mainrds.databasename=maindata

After deleting the line cloud.aws.rds.mainrds everything worked just fine.

Using spring.datasource.* is not an option because we are using IAM authentication for RDS and therefore the password has to be regenerated every 15 minutes.

java – No database instance with id: found. Please specify a valid db instance

Leave a Reply

Your email address will not be published. Required fields are marked *