8.1.5 AWS Parameter Store Support

Micronaut supports configuration sharing via AWS System Manager Parameter Store. You will need the following dependencies configured:

Example build.gradle for AWS System Manager Parameter Store

  1. compile "io.micronaut:micronaut-discovery-client"
  2. compile "io.micronaut.configuration:micronaut-aws-common"
  3. compile group: 'com.amazonaws', name: 'aws-java-sdk-ssm', version: '1.11.308'

To enable distributed configuration a src/main/resources/bootstrap.yml configuration file must be created and configured to use Parameter Store:

bootstrap.yml

  1. micronaut:
  2. application:
  3. name: hello-world
  4. config-client:
  5. enabled: true

🔗

Table 1. Configuration Properties for AWSParameterStoreConfiguration
PropertyTypeDescription

aws.client.system-manager.parameterstore.use-secure-parameters

boolean

Use auto-decryption via MKS for SecureString parameters. Default value ({@value DEFAULT_SECURE}). If set to false, you will not get unencrypted values.

aws.client.system-manager.parameterstore.root-hierarchy-path

java.lang.String

The the root hierarchy on the parameter store. Default value (“/“ + PREFIX + “/“).

aws.client.system-manager.parameterstore.enabled

boolean

Enable or disable distributed configuration with AWS Parameter Store. Default value (false).

You can configure shared properties by going into the AWS Console → System Manager → Parameter Store

Micronaut will use a hierarchy to read the configuration values, and supports String, StringList, and SecureString types.

You can make environment specific configurations as well by including the environment name after an underscore _. For example if your micronaut.application.name setting is set to helloworld then providing configuration values under helloworld_test will be applied only to the test environment.

Table 2. Configuration Resolution Precedence
FolderDescription

/config/application

Configuration shared by all applications

/config/[APPLICATION_NAME]

Application specific configuration, example /config/hello-world

/config/application_prod

Configuration shared by all applications for the prod Environment

/config/[APPLICATION_NAME]_prod

Application specific configuration for an active Environment

For example, if the configuration name /config/application_test/server.url is configured in AWS Parameter Store, then any application connecting to that parameter store can retrieve the value using server.url. If the application has micronaut.application.name configured to be myapp, then a value with the name /config/myapp_test/server.url will override the value just for that application.

Each level of the tree can be composed of key=value pairs. If you want multiple key value pairs, set the type to ‘StringList’.

For special secure information, like keys or passwords, use the type “SecureString”. KMS will be automatically invoked when you add and retrieve values and decrypt them with the default key store for your account. If you set the configuration to not use secure strings, they will be returned to you encrypted and you must manually decrypt them.

The https://github.com/micronaut-projects/micronaut-examples/aws repository showcases a sample application using this feature.