How does Spring Boot get properties from AWS Parameter Store (SSM)?

Tram Ho

AWS Systems Manager Parameter Store is a service of AWS, which helps to manage configuration for applications safely and securely. You can store data types such as passwords, database information, license codes, … centrally for all environments (dev, testing, staging, production).

A Spring application always needs config and usually will put the values ​​that need configuring in the properties file, using environment variables to put values ​​in from outside (using .env file)

But, if an application runs on production (typically running on aws services) and the config values ​​change, then having to transform the environment from the .env file, properties is a pain. At this point, you will see how powerful the AWS SSM Parameter Store is. (len3)

Setup AWS parameter store in Spring Boot

Here is sample pom.xml file. Using spring boot 2.3.4 , spring cloud Hoxton.SR8

The key is this paragraph:

and this:

(AWS Parameter store works on Spring Cloud)

Config credentials for the app to access the AWS Parameter Store

There are many ways to configure credentials to ensure that a Spring Boot application can access the AWS Parameter Store.

  • Java System Properties (aws.accessKeyId and aws.secretKey)
  • Credentials profile (Default configuration is stored in the ~ / .aws / credentials file)
  • Credentials through the Amazon EC2 container service
  • Via Amazon EC2 metadata service

Config values ​​at properties file

Change the default AWS Parameter Store settings in Spring Boot


Above I just introduce the main settings so that Spring Boot can get data from the AWS Parameter Store as well as how to name the aws parameter so that the map with the Spring Boot properties file.

Some definitions as well as mustache, you can refer to:

Share the news now

Source : Viblo