Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Enhancement: make Spring Boot configuration for AWS RDS instance more flexible #495

Closed
superdurszlak opened this issue Sep 30, 2019 · 2 comments
Labels
component: rds RDS integration related issue type: enhancement A general enhancement
Milestone

Comments

@superdurszlak
Copy link

superdurszlak commented Sep 30, 2019

In our case, we have separate RDS instances used for different purposes (f.e. separate deployments for development, performance tests etc) and we need a clean way to use different RDS instance names depending on deployment.

Currently, RDS instance can be configured in Spring Boot via

  • @EnableRdsInstance annotation attributes
  • application.properties or application.yml file
  • define jdbc:data-source bean in beans.xml

The first approach doesn't allow much flexibility as with current implementation it seems to boil down to hard-coding RDS instance name, credentials etc. I believe this is already addressed in #383 with regard to providing credentials via annotation attributes.

The second one allows to resolve f.e. credentials from environment variables, but since instance name is a part of configuration path, rather than actual property value it cannot be externalized as f.e. environment variable.

The last one seems to allow to resolve RDS instance name from variables yet I believe it shouldn't be necessary to fall back to XML in a Spring Boot project just to be able to make such a basic configuration property more flexible.

Currently, the only ways that I see to accomplish our goal are:

  • define beans.xml file and resolve RDS instance name there
  • provide separate configuration for each RDS instance we might use in application.properties / application.yml
  • generate proper configuration using external tools and either configuration template or placeholders within actual configuration

But none of those seem satisfactory.

What would likely solve our problems would be any of these:

@EnableRdsInstance(dbInstanceIdentifier = "${my.app.rds.instance-identifier}", ...)
  • change application.yml configuration structure so that RDS instance names are values rather than keys, for example to list-based one:
cloud:
  aws:
    rds:
      - instanceName: ${ENV_VARIABLE_FOR_INSTANCE_ONE}
        databaseName: database-name-one
        username: user-one
        password: secret-one
      - instanceName: instance-two
        databaseName: database-name-two
        username: user-two
        password: secret-two
@mkatircioglu
Copy link
Contributor

Hi @superdurszlak, as you can see in #383 , there is no more any problem on defining dbInstanceIdentifier and password as environment variable in @EnableRdsInstance. Under this circumstances, does it cover your issue or do you still need the your second recommendation?

@superdurszlak
Copy link
Author

@mkatircioglu thanks for following up. Annotation-based definition should be sufficient to cover our case. On the other hand, I believe re-shaping Spring Boot configuration for RDS to make it just as flexible (and on par with regular data sources) would simplify things.

maciejwalkowiak added a commit to maciejwalkowiak/spring-cloud-aws that referenced this issue Oct 15, 2020
Fixes spring-atticgh-495
Closes spring-atticgh-598

Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
maciejwalkowiak added a commit to maciejwalkowiak/spring-cloud-aws that referenced this issue Oct 15, 2020
Fixes spring-attic#495
Closes spring-attic#598

Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
juho9000 pushed a commit to juho9000/spring-cloud-aws that referenced this issue Apr 29, 2021
Fixes spring-attic/spring-cloud-aws#495
Closes spring-attic/spring-cloud-aws#598

Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
component: rds RDS integration related issue type: enhancement A general enhancement
Development

No branches or pull requests

4 participants