Have a spring boot app (with starter parent at 2.4.8).
The app is connecting to multiple data sources, and the automated Jenkins job being used to create secrets across company does it such a way that although secrets names are different(per app/source) but they all have same value underneath - 'username' and 'password' text.
For example:
first secret would be '/secret/rds/dev/foo/foo_app_user' with value:
username : user1
password: pass1
second secret would be '/secret/snowflake/dev/hoo/hoo_app_user' with value:
username : user2
password: pass2
Trying to figure out how can they both be imported using spring config import, while still being able to be used distinctively in properties/yaml file
spring:
config:
import: aws secretsmanager:/secret/rds/dev/foo/foo_app_user,/secret/snowflake/dev/hoo/hoo_app_user
...
system:
cache:
username: ${username}
password: ${password}
....
snowflake:
datasource:
username: ${username}
password: ${password}
3 days ago 13th Jan, 2023 this issue has been fixed. Commit ref
With spring cloud 3.0.x (dependent on spring boot 3.0.x) you can add prefix
spring:
config:
import:
- aws-secretsmanager:/secret/rds/dev/foo/foo_app_user?prefix=foo_app.
- aws-secretsmanager:/secret/snowflake/dev/hoo/hoo_app_user?prefix=hoo_app.
Now as a workaround for spring cloud version 2.4.x we have
AwsSecretsManagerPropertySource into our codebase in package io.awspring.cloud.secretsmanager. Code Ref3.0.x. Code RefPS: Don't change the class signature. Method name, constructor param should be same as version 2.4.x
Edit: 5th Feb, 2023
With new 2.4.3 version you can pass the same prefix. No need to do workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With