AWS Secrets Manager
Integrate AWS Secrets Manager with POB.
Last updated
Integrate AWS Secrets Manager with POB.
Last updated
Last Updated: 26 May 2022 • Page Author: Jillur Quddus
AWS Secrets Manager is the native managed secrets management engine of the AWS cloud computing platform, enabling applications, services and IT resources to secure manage sensitive credentials, API keys and other secrets throughout their lifecycle. This page provides instructions on how to integrate AWS Secrets Manager with POB.
For further information regarding AWS Secrets Manager, please visit https://aws.amazon.com/secrets-manager.
There are no explicit setup processes to follow in order to provision AWS Secrets Manager. As long as you have an AWS account, you can access AWS Secrets Manager via the AWS Management Console.
As described in Bootstrap Configuration, the POB Spring bootstrap context is responsible for loading and decrypting configuration properties from external sources, such as HashiCorp Vault, Azure Key Vault or AWS Secrets Manager. This enables developers and platform engineers to avoid writing secrets (such as usernames, passwords, API keys, access tokens and database connectivity strings) directly in properties files. Instead they can define and provide placeholder variables and the Spring bootstrap context will load the relevant secrets from the relevant secrets engine.
In order to integrate the Spring bootstrap context with AWS Secrets Manager, AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
environment variables must be set in the relevant AWS deployment environments associated with an IAM user that has the SecretsManagerReadWrite
AWS managed policy attached to it (or equivalent custom policy), as illustrated in the following screenshot:
To configure an IAM user provisioned with the SecretsManagerReadWrite AWS managed policy, please visit the IAM Management Console via the AWS Management Console.
As described in Bootstrap Configuration, the configuration for the POB bootstrap context may be found in the pob-configuration
Maven module, at src/main/resources/bootstrap.yml
.
To integrate the POB Spring bootstrap context with AWS Secrets Manager, explicitly disable integration with HashiCorp Vault and Azure Key Vault before enabling integration with AWS Secrets Manager as follows:
The aws.secretsmanager configuration namespace includes the following properties that must be completed:
In the example configuration above, we inform the POB Spring bootstrap context that externalised configuration can be found in our AWS Secrets Manager instance in a secret named /secret/pob
. Thus all placeholder variables defined in the application configuration MUST be defined as key-value pairs in the /secret/pob
secret managed by AWS Secrets Manager.
If you define placeholder variables in the application context which are not also defined in the /secret/pob
secret managed by AWS Secrets Manager, then an exception will be thrown when attempting to start the relevant Spring Boot application.
For further information and properties related to loading externalised configuration from AWS Secrets Manager, please refer to https://docs.spring.io/spring-cloud-aws/docs/2.2.4.RELEASE/reference/html/appendix.html.
As described in Application Configuration, the configuration for the POB application context may be found in the pob-configuration
Maven module, at src/main/resources/application.yml
.
As described above, assuming that the POB Spring bootstrap context has been integrated with AWS Secrets Manager, then all placeholder variables defined in the POB Spring application configuration MUST be defined as key-value pairs in the relevant secret managed by AWS Secrets Manager (for example /secret/pob
). For example the following POB application configuration YAML file has been configured with placeholder variables (for example rdbms-jdbcUrl
) that will be loaded from AWS Secrets Manager:
All the placeholder variables defined in the example application configuration file above, for example ${slack-channel}
, ${slack-webhook}
, ${microsoft-teams-webhook}
, ${google-chat-webhook}
and ${rdbms-jdbcUrl}
(to highlight just a few), must also be defined as key-value pairs in the relevant secret managed by AWS Secrets Manager (for example /secret/pob
). This can be achieved via the AWS management console as illustrated in the following screenshot:
Property | Description | Example Value |
---|---|---|
enabled
Whether to enable externalised configuration from AWS Secrets Manager.
true
name
The name of the secret to lookup containing the externalised configuration as key-value pairs.
pob
prefix
The name of the prefix indicating the first level for every property.
/secret
defaultContext
The context name used by all applications.
application
failFast
Whether to throw exceptions during configuration lookup, otherwise log warnings.
true
region
The AWS region of the AWS Secrets Manager.
eu-west-2