An AWS Secrets Manager-backed configuration provider for .NET applications using Microsoft.Extensions.Configuration.
$ dotnet add package AWSSecretsManager.ProviderThis is a modern, community-maintained fork of Kralizek/AWSSecretsManagerConfigurationExtensions, originally developed by Renato Golia.
It provides a configuration provider for Microsoft.Extensions.Configuration that loads secrets from AWS Secrets Manager.
System.Text.JsonILogger integrationAWSSecretsManager.Providerpublic class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
config.AddSecretsManager(); // 👈 AWS Secrets Manager integration
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}static void Main(string[] args)
{
var builder = new ConfigurationBuilder();
builder.AddSecretsManager();
var config = builder.Build();
Console.WriteLine("Secret: " + config["MySecret"]);
}Your application must have AWS credentials available through the default AWS SDK mechanisms. Learn more here:
👉 AWS SDK Credential Config
The provider includes comprehensive logging support for better observability:
// Using ILoggerFactory (recommended)
using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
builder.Configuration.AddSecretsManager(
loggerFactory,
configurator: options => options.PollingInterval = TimeSpan.FromMinutes(5));
// Using explicit ILogger
var logger = loggerFactory.CreateLogger<SecretsManagerConfigurationProvider>();
builder.Configuration.AddSecretsManager(
logger,
configurator: options => options.PollingInterval = TimeSpan.FromMinutes(5));Log Levels:
Example Log Output:
[Information] Loading secrets from AWS Secrets Manager
[Debug] Fetching 15 secrets in 1 batches
[Information] Successfully loaded 47 configuration keys in 1,234ms
[Information] Starting secret polling with interval 00:05:00
This provider supports several customization options, including:
ILogger integration for observability.ServiceUrl for local testing.The repository includes comprehensive samples demonstrating different usage patterns:
| Sample | Description | Key Features |
|---|---|---|
| Sample1 | Basic Usage | Default credentials, default region, all secrets |
| Sample2 | Region Configuration | Custom AWS region specification |
| Sample3 | Credential Profiles | Using named AWS credential profiles |
| Sample4 | Secret Filtering | Loading specific secrets by ARN allowlist |
| Sample5 | Custom Key Generation | Transforming configuration key names (e.g., uppercase) |
| Sample6 | Custom Client Factory | Advanced AWS client configuration |
| Sample7 | Advanced Logging | Comprehensive logging, polling, and monitoring |
| SampleWeb | ASP.NET Core | Web application integration with endpoints |
Each sample includes a detailed README with usage examples, prerequisites, and explanations. See the complete samples overview for setup instructions and learning progression.
dotnet add package AWSSecretsManager.ProviderThis repo is built with the standard .NET SDK:
dotnet build
dotnet testThis project is based on the excellent work by Renato Golia and inspired by the broader .NET and AWS developer community.
This project is licensed under the MIT License.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!