AWS Secrets Manager configuration provider implementation for Microsoft.Extensions.Configuration.
$ dotnet add package PrincipleStudios.Extensions.Configuration.SecretsManagerAdd this package.
Add to your application's configuration builder.
For example, this will add a root Secrets:secret containing the value stored in the secret string within AWS SecretsManager at test/secret:
.AddSecretsManager()
Ensure your application receives AWS standard environment variables to set your credentials. Alternatively, customize via the options object.
Add environment variables to create the mapping.
For example, this will add a root Secrets:secret containing the value stored in the secret string within AWS SecretsManager at test/secret:
AWSSM_ID_Secrets__secret=test/secret
Use configuration as normal, including IOptionsMonitor<> to receive notifications when configuration is refreshed from AWS.
Environment variables are used to keep your configuration flexible at run-time.
AWS_PROFILE environment variable is provided, the credentials and region are loaded from the AWS Credential Profile Store Chain.AWS_SSO_PROFILE environment variable is provided, the credentials and region are loaded from the AWS Credential Profile Store Chain from an AWS SSO login.AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are provided, they are used.AWS_DEFAULT_REGION environment variable is provided, the region specified overrides other environment variables.By default, the following environment variables are used to create configuration entries. (This is configurable via EnvironmentVariableLoadConfiguration.) After a prefix, environment variable naming corresponds to that for Microsoft.Extensions.Configuration.EnvironmentVariables.
AWSSM_ID_ - the name of the secret within Secrets Manager.AWSSM_FORMAT_ - the Format Transform to use when loading the secret into the configuration.AWSSM_ARG_ - the argument passed to the format transform.While .AddSecretsManager() makes it easy to use the default settings via environment variables, there are some situations where you may wish to customize your secrets further. You may add the secrets manager configuration provider through this additional call:
.AddSecretsManager(options =>
{
// configure options here
}, optional: false)
Specifing optional: true means that if credentials are not supplied or any secrets are not accessible when the application launches, the secrets manager configuration will not be processed.
If no secrets are configured in the Map (either through advanced configuration or environment variables), credentials are not checked.
AmazonSecretsManagerConfig before the client is created.null to disable environment variable configuration mapping.
AWSSM_ID_.)AWSSM_FORMAT_.)FormatTransforms.IFormatTransform. Preregistered transforms include: