8.1.5 AWS Parameter Store Support

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

  1. implementation("io.micronaut.aws:micronaut-aws-parameter-store")
  1. <dependency>
  2. <groupId>io.micronaut.aws</groupId>
  3. <artifactId>micronaut-aws-parameter-store</artifactId>
  4. </dependency>

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
  6. aws:
  7. client:
  8. system-manager:
  9. parameterstore:
  10. enabled: true

See the configuration reference for all configuration options.

You can configure shared properties from the AWS Console → System Manager → Parameter Store.

Micronaut uses a hierarchy to read configuration values, and supports String, StringList, and SecureString types.

You can create environment-specific configurations as well by including the environment name after an underscore _. For example if micronaut.application.name is set to helloworld, specifying configuration values under helloworld_test will be applied only to the test environment.

Table 1. Configuration Resolution Precedence
DirectoryDescription

/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, 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, a value with the name /config/myapp_test/server.url overrides the value just for that application.

Each level of the tree can be composed of key=value pairs. For multiple key/value pairs, set the type to StringList.

For special secure information, such as keys or passwords, use the type SecureString. KMS will be automatically invoked when you add and retrieve values, and will 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.