1

I tried to get secret manager value use this answer How to integrate AWS Secret Manager with Spring Boot Application But my application get secrets 2 times, first as I want with local profile, but second without any profile. Why application go to secret second time and how can I off this?

2021-08-19 11:40:01.214  INFO 9141 --- [  restartedMain] s.AwsSecretsManagerPropertySourceLocator : Loading secrets from AWS Secret Manager secret with name: secret/test_local, optional: false
2021-08-19 11:40:02.702  INFO 9141 --- [  restartedMain] s.AwsSecretsManagerPropertySourceLocator : Loading secrets from AWS Secret Manager secret with name: secret/test, optional: false
2021-08-19 11:40:02.956 ERROR 9141 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

my config in bootstrap.yaml

aws:
  secretsmanager:
    prefix: secret
    defaultContext: application
    profileSeparator: _
    name: test

start application with -Dspring.profiles.active=local

upd. If I create secret for secret/test I have the next one

s.AwsSecretsManagerPropertySourceLocator : Loading secrets from AWS Secret Manager secret with name: secret/application_local, optional: false
Hayami Pysh
  • 285
  • 1
  • 5
  • 14

1 Answers1

1

Currently there is no way to disable prefix/defaultContext look up. If you take a look here you will see that prefix/ + defaultcontext of loading is always added and used.

You can check docs as well, to have more clear way what is being loaded and in what order.

My recommendation is to switch to spring.config.import since that will be the way we are going to take Secrets Manager importing. Big difference is that, it gives users a lot more control of which secrets they want to import since you can specify each key individually. spring.config.import can be found explained in docs or you can check the project sample .