1

I am trying to move all sensitive data like secrets and passwords from local application property files to AWS Secrets Manager. The application is based on Spring Boot. The plan is to retrieve all the secrets from AWS before the application starts, then override the current values. The problem is, the properties inside the application.properties just won't get overridden. I tried to put the values in the system.configuration or add a new properties, it all worked. However, when you try to get value like this :

        String b = environment.getProperty("test.key");

or this:

        <property name="userName" value="${test.username}"/>

It is still getting the values directly from the application files.

Tried all methods mentioned in this post, still no luck. All of them are just adding the values to a new properties source instead of overriding the environment values loaded from application.properties files. Any thoughts? This is really hard.

Drake .C
  • 332
  • 4
  • 16

1 Answers1

0

Found the answer in this post. Credits to @Lukas Hinsch. Just add a new property source to the application environment via a ApplicationEnvironmentPreparedEvent will do. The reason why it didn't work for me in the first time is that the ApplicationEnvironmentPreparedEvent was not executed due to the way I added it application.addListeners(); instead, you should add it as new SpringApplicationBuilder(Application.class).listeners(new Applicationpdater()).run(args);

Drake .C
  • 332
  • 4
  • 16