Why is the fixed resource name AWSEBRDSDatabase not available to my Elastic Beanstalk/Spring Cloud AWS application?

434 views Asked by At

I have a Spring Boot application using Spring Cloud AWS. I'm deploying the application on Elastic Beanstalk with an Amazon RDS database.

According to the documentation, Elastic Beanstalk provides fixed resource names for the AWS resources that it creates for you when you deploy your application.

This means that rather than referring to the RDS database by its actual instance ID (something like axxt7bi97gbjy4), I should be able to use the Elastic Beanstalk resource name AWSEBRDSDatabase. The reason I would want to do this is so that cloning an Elastic Beanstalk environment will actually work without manual intervention to configure the correct database.

The Problem:

When I configure my Spring Boot/Spring Cloud application's data source using the Elastic Beanstalk fixed resource name AWSEBRDSDatabase...

cloud.aws.stack.auto=false
cloud.aws.region.auto=true
cloud.aws.credentials.instanceProfile=true

cloud.aws.rds.AWSEBRDSDatabase.username=user
cloud.aws.rds.AWSEBRDSDatabase.password=password
cloud.aws.rds.AWSEBRDSDatabase.databaseName=ebdb

...I get the following exception...

Caused by: java.lang.IllegalStateException: No database instance with id:'AWSEBRDSDatabase' found. Please specify a valid db instance
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.getDbInstance(AmazonRdsDataSourceFactoryBean.java:170) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE]
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createDataSourceInstance(AmazonRdsDataSourceFactoryBean.java:151) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE]
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:129) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE]
        at org.springframework.cloud.aws.jdbc.rds.AmazonRdsDataSourceFactoryBean.createInstance(AmazonRdsDataSourceFactoryBean.java:45) ~[spring-cloud-aws-jdbc-1.0.4.RELEASE.jar!/:1.0.4.RELEASE]
        at org.springframework.beans.factory.config.AbstractFactoryBean.afterPropertiesSet(AbstractFactoryBean.java:134) ~[spring-beans-4.3.4.RELEASE.jar!/:4.3.4.RELEASE]
      ...

When I configure the datasource with a reference to a specific RDS instance:

cloud.aws.stack.auto=false
cloud.aws.region.auto=true
cloud.aws.credentials.instanceProfile=true

cloud.aws.rds.axxt7bi97gbjy4.username=user
cloud.aws.rds.axxt7bi97gbjy4.password=password
cloud.aws.rds.axxt7bi97gbjy4.databaseName=ebdb

...everything is fine.

How can I modify my environment to get the Elastic Beanstalk fixed resource name AWSEBRDSDatabase to be present?

Update

I added the following to my .ebextensions and created a new environment using the EB CLI. No change, same error. The AWSEBRDSDatabase resource is not available.

Resources:
  AWSEBRDSDatabase:
    Type: AWS::RDS::DBInstance
    Properties:
      AllocatedStorage: 5
      DBInstanceClass: db.t2.small
      DBName: test
      Engine: postgres
      EngineVersion: 9.3
      MasterUsername: test
      MasterUserPassword: testtesttest
0

There are 0 answers