In my spring boot
application I have some externalized configuration properties read from AWS Parameter Store
. I do not use AWS SSM Client
directly and extract the properties. I am using the spring-cloud-starter-aws-parameter-store-config
and with few bootstrap.yml
changes I am able to configure it. When the application starts, I am able to automatically detect the environment property source and extract configuration values with the help of @ConfigurationProperties
annotation.
Sample bootstrap.yml is shown below:
aws:
paramstore:
enabled: true
name: my-app
prefix: /config
profileSeparator: /
Sample code is shown below:
@Getter
@Setter
@Configuration
@ConfigurationProperties("app.property")
public class TestObject {
private Map<String, InnerObject> valueMap = new HashMap<>();
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public static class InnerObject {
private int property_one = 20;
private int property_two = 10;
}
}
Sample AWS Parameter Store configuration name:
/config/my-app/dev/app.property.valueMap
All other properties (String
& StringList
) works fine except with map. I was unable to figure out the way to define this map as a value within the AWS Parameter Store
such that it resolves into my Java
HashMap
. Your insights are highly appreciated, thank you!
I was not able to figure out a way to define a whole Java HashMap
as a value of the AWS Paramstore
value. However, I was able to define each property of the map separately as shown below.
First entry of the map:
/config/my-app/dev/app.property.valueMap.key_one.property_one
/config/my-app/dev/app.property.valueMap.key_one.property_two
Second entry of the map:
/config/my-app/dev/app.property.valueMap.key_two.property_one
/config/my-app/dev/app.property.valueMap.key_two.property_two
This maybe not the most optimum or the best solution. However, it did the job done even though I had to define each value individually. Hope this would help someone, Thanks!