0

I'm currently working on a project in which our app needs to connect to an Amazon RDS instance. So far, I have been utilizing the following documentation for setup: https://cloud.spring.io/spring-cloud-aws/spring-cloud-aws.html#_sdk_credentials_configuration.

According to the documentation, section 7.3, I should set my application.properties file as so:

cloud.aws.credentials.accessKey=XXXXXXXXXXXXXXX
cloud.aws.credentials.secretKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
cloud.aws.credentials.instanceProfile=true

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

cloud.aws.rds.instanceNameTest
cloud.aws.rds.instanceNameTest.password=chownTestPW
cloud.aws.rds.instanceNameTest.username=dataTest1
cloud.aws.rds.instanceNameTest.databaseName=testDB

However, when I run the application, I receive the following error:

Caused by: java.lang.IllegalArgumentException: Password must not be null
at org.springframework.util.Assert.notNull(Assert.java:193) ~[spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.cloud.aws.jdbc.datasource.DataSourceInformation.<init>(DataSourceInformation.java:65) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.fromRdsInstance(AmazonRdsDataSourceFactoryBean.java:187) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createDataSourceInstance(AmazonRdsDataSourceFactoryBean.java:153) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:130) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:45) ~[spring-cloud-aws-jdbc-2.0.0.RELEASE.jar:2.0.0.RELEASE]
at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:141) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 30 common frames omitted

I'm not sure why it's telling me that the password is null when the setup appears to be fine above.

Any suggestions would be helpful. Let me know if I need to provide anything else.

Thanks.

Brandon
  • 933
  • 1
  • 10
  • 19
  • I don't think that's an error from RDS, as your question title seems to imply. That looks like a local assertion failure ("at org.springframework.util.Assert.notNull..."). – Michael - sqlbot Jul 04 '18 at 00:49
  • @Michael-sqlbot Im glad you mentioned that. Yes, the title implies that it is an Amazon error, but it might be that I am incorrectly setting up the instance within my Spring Boot app. The Password must not be null appears to be thrown within the org.springframework.cloud.aws.jdbc.datasource.DataSourceInformation class. It's not a local assertion within the app, that assertion lies within the cloud.aws.jdbc dependency. Thanks for looking. – Brandon Jul 04 '18 at 05:41
  • Hi. How did you solved this? I am getting the same error. My RDS has a password set and I have the password property (cloud.aws.rds.instanceName.password) set in my application.properties file also. Any ideas? – Cristian Ebbens Sep 07 '18 at 18:52
  • @cebbens Unfortunately, I was not able to get this to work. I instead had to utilize a different way that didnt involve using spring-cloud-aws which I really wanted to use. I saw that you too commented on the bug/error I wrote on the repository in Github. Please let me know if you get it to work and I'll do that same. Thanks. – Brandon Sep 11 '18 at 01:54
  • @BrandonR Thanks for your reply! Too bad that there isn't a solution so far, and that there isn't too much when googling around. I will let you know ;) – Cristian Ebbens Sep 12 '18 at 14:33

1 Answers1

6

I ran into the same problem. I had a similar config to what you had:

cloud.aws.rds.springdemo
cloud.aws.rds.springdemo.databaseName=springdemo
cloud.aws.rds.springdemo.username=springdemo
cloud.aws.rds.springdemo.password=Everyday123

I fixed the problem by removing the property cloud.aws.rds.springdemo, so that only

cloud.aws.rds.springdemo.databaseName=springdemo
cloud.aws.rds.springdemo.username=springdemo
cloud.aws.rds.springdemo.password=Everyday123

remained. After that, I didn't get any assertion errors and my spring boot app was able to start.

bortdc
  • 931
  • 9
  • 11
  • 1
    Thanks for sharing your solution. That's so strange because https://cloud.spring.io/spring-cloud-aws/spring-cloud-aws.html#_sdk_credentials_configuration clearly stated to setup the way I had issues with. Thanks again. – Brandon Jan 15 '19 at 19:54