Package Description
License
—
Deps
10
Install Size
—
Vulns
✓ 0
Published
Dec 2, 2025
$ dotnet add package Opc.AwsSettingsA .NET library that simplifies loading configuration from AWS services including Parameter Store, Secrets Manager, and AppConfig into your application's configuration system.
IConfiguration systemInstall the NuGet package:
dotnet add package Opc.AwsSettings
using Microsoft.Extensions.Hosting;
var host = Host.CreateDefaultBuilder(args)
.AddAwsSettings() // Add AWS configuration sources
.ConfigureServices(services =>
{
// Your service configuration
})
.Build();
await host.RunAsync();
using Microsoft.Extensions.Configuration;
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddAwsSettings() // Add AWS configuration sources
.Build();
Configure the library using the AwsSettings section in your appsettings.json:
{
"AwsSettings": {
"ReloadAfter": "00:05:00",
"ParameterStore": {
"Paths": ["/myapp/prod"],
"Keys": []
},
"SecretsManager": {
"LoadAll": false,
"AcceptedSecretArns": [],
"Prefix": null,
"Optional": false
},
"AppConfig": {
"ApplicationIdentifier": "my-app",
"UseLambdaCacheLayer": false,
"ConfigurationProfiles": []
}
}
}
Load all parameters under a specific path prefix:
{
"AwsSettings": {
"ParameterStore": {
"Paths": ["/myservice"]
}
}
}
If your Parameter Store contains:
/myservice/Database/ConnectionString = "Server=..."/myservice/Database/MaxPoolSize = "100"/myservice/Api/Endpoint = "https://api.example.com"They will be mapped to:
{
"Database": {
"ConnectionString": "Server=...",
"MaxPoolSize": "100"
},
"Api": {
"Endpoint": "https://api.example.com"
}
}
Use custom aliases to map Parameter Store keys to cleaner configuration names:
{
"AwsSettings": {
"ParameterStore": {
"Keys": [
{
"Path": "/aws/reference/secretsmanager/prod-db-credentials",
"Alias": "Database:ConnectionString"
},
{
"Path": "/myservice/config/api-key",
"Alias": "ApiSettings:Key",
"Optional": true
}
]
}
}
}
Reference Secrets Manager values through Parameter Store:
{
"AwsSettings": {
"ParameterStore": {
"Keys": [
{
"Path": "/aws/reference/secretsmanager/my-secret",
"Alias": "MySecret"
}
]
}
}
}
Load all secrets from Secrets Manager:
{
"AwsSettings": {
"SecretsManager": {
"LoadAll": true,
"Optional": false
}
}
}
{
"AwsSettings": {
"SecretsManager": {
"LoadAll": false,
"AcceptedSecretArns": [
"arn:aws:secretsmanager:us-east-1:123456789012:secret:prod/database",
"arn:aws:secretsmanager:us-east-1:123456789012:secret:prod/api-keys"
]
}
}
}
Filter secrets by name prefix:
{
"AwsSettings": {
"SecretsManager": {
"LoadAll": true,
"Prefix": "prod/myapp/"
}
}
}
{
"AwsSettings": {
"AppConfig": {
"ApplicationIdentifier": "my-application",
"ConfigurationProfiles": [
{
"Identifier": "my-config-profile",
"Optional": false
},
{
"Identifier": "feature-flags",
"Optional": true
}
]
}
}
}
For AWS Lambda functions, enable the cache layer for improved performance:
{
"AwsSettings": {
"AppConfig": {
"ApplicationIdentifier": "my-application",
"UseLambdaCacheLayer": true,
"ConfigurationProfiles": [
{
"Identifier": "my-config-profile"
}
]
}
}
}
Enable automatic reloading of configuration at specified intervals:
{
"AwsSettings": {
"ReloadAfter": "00:05:00", // Reload every 5 minutes
"ParameterStore": {
"Paths": ["/myapp"]
}
}
}
The library respects the ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT variables:
var host = Host.CreateDefaultBuilder(args)
.AddAwsSettings() // Automatically uses current environment
.Build();
Or specify the environment explicitly:
var configuration = new ConfigurationBuilder()
.AddAwsSettings(environmentName: "Production")
.Build();
public class DatabaseSettings
{
public string ConnectionString { get; set; }
public int MaxPoolSize { get; set; }
}
// In Program.cs
services.Configure<DatabaseSettings>(
configuration.GetSection("Database")
);
// In your service
public class MyService
{
private readonly DatabaseSettings _settings;
public MyService(IOptions<DatabaseSettings> options)
{
_settings = options.Value;
}
}
var connectionString = configuration["Database:ConnectionString"];
var apiEndpoint = configuration["Api:Endpoint"];
var awsSettings = configuration.GetSettings<AwsSettings>();
Enable logging to see what configuration is being loaded:
using Microsoft.Extensions.Logging;
var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole();
});
var logger = loggerFactory.CreateLogger("AwsSettings");
var host = Host.CreateDefaultBuilder(args)
.AddAwsSettings(logger)
.Build();
Here's a complete example combining multiple AWS configuration sources:
{
"AwsSettings": {
"ReloadAfter": "00:10:00",
"ParameterStore": {
"Paths": ["/myapp/prod"],
"Keys": [
{
"Path": "/aws/reference/secretsmanager/db-connection",
"Alias": "Database:ConnectionString"
}
]
},
"SecretsManager": {
"LoadAll": false,
"AcceptedSecretArns": [
"arn:aws:secretsmanager:us-east-1:123456789012:secret:api-keys"
]
},
"AppConfig": {
"ApplicationIdentifier": "myapp",
"ConfigurationProfiles": [
{
"Identifier": "application-config"
},
{
"Identifier": "feature-flags"
}
]
}
}
}
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
var host = Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
config.AddJsonFile("appsettings.json");
config.AddAwsSettings(context.HostingEnvironment.EnvironmentName);
})
.ConfigureServices((context, services) =>
{
// Configure your services using the loaded configuration
services.Configure<DatabaseSettings>(
context.Configuration.GetSection("Database")
);
services.Configure<ApiSettings>(
context.Configuration.GetSection("Api")
);
})
.Build();
await host.RunAsync();
Ensure your application has the necessary AWS IAM permissions:
{
"Effect": "Allow",
"Action": [
"ssm:GetParameter",
"ssm:GetParameters",
"ssm:GetParametersByPath"
],
"Resource": "arn:aws:ssm:*:*:parameter/myapp/*"
}
{
"Effect": "Allow",
"Action": [
"secretsmanager:GetSecretValue",
"secretsmanager:ListSecrets"
],
"Resource": "arn:aws:secretsmanager:*:*:secret:*"
}
{
"Effect": "Allow",
"Action": [
"appconfig:GetConfiguration",
"appconfig:StartConfigurationSession"
],
"Resource": "*"
}
ReloadAfter intervals for configuration that changes/myapp/prod/... and /myapp/dev/...Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source. Please check the repository for license details.
An opinionated .NET Standard 2.0 library that provides support for all AWS settings options including Parameter Store, Secrets Manager, AppConfig Freeform and AppConfig Feature Flags.