SecretsManagerFacadeLib 1.0.2
See the version list below for details.
dotnet add package SecretsManagerFacadeLib --version 1.0.2
NuGet\Install-Package SecretsManagerFacadeLib -Version 1.0.2
<PackageReference Include="SecretsManagerFacadeLib" Version="1.0.2" />
paket add SecretsManagerFacadeLib --version 1.0.2
#r "nuget: SecretsManagerFacadeLib, 1.0.2"
// Install SecretsManagerFacadeLib as a Cake Addin
#addin nuget:?package=SecretsManagerFacadeLib&version=1.0.2
// Install SecretsManagerFacadeLib as a Cake Tool
#tool nuget:?package=SecretsManagerFacadeLib&version=1.0.2
SecretsManagerFacadeLib
Convenience lib that offers support to retrieve Aws Credentials and Aws Secrets Manager stored properties.
It uses client side caching (supported by official Aws cache lib) to prevent further http calls.
Usage
**1. Declare components in Startup.cs 😗*
services.AddSingleton(RegionEndpoint.SAEast1); // inject the desired aws region
services.AddSingleton<ISecretsManagerClient, SecretsManagerClient>();
services.AddSingleton<ISecretsManagerFacade, SecretsManagerFacade>();
services.AddSingleton<ICredentialsFacade<AwsCredentials>, AWSCredentialsFacade>();
**2. Inject the Facade client in your class 😗*
public SqsClient(ICredentialsFacade<AwsCredentials> credentialsFacade)
{
_credentialsFacade = credentialsFacade;
}
3. Retrieve the desired credentials
For AwsCredentials
var awsCredentials = _credentialsFacade.GetCredentials();
Of course: you have to store the credentials in Aws Secrets Manager using a Json format, for example:
{
"accountid": "YOUR-ACCOUNT-ID",
"accesskey": "YOUR-ACCESS-KEY",
"secretkey": "YOUR-SECRET-KEY",
"region": "YOUR-REGION-ID"
}
For general string-based properties
Example: to retrieve a hypothetical ApiKey value (stored in plain string in Secrets Manager), you'll want your appsettings.json like this:
"MySection": {
"SecretsManager": "YOUR-SECRET-ID"
}
Then call it in your code:
var MySection = _configuration.GetSection("MySection");
var SecretId = MySection["SecretsManager"];
var ApiKey = _credentialsFacade.GetStringProperty(SecretId);
For general object-based properties
Example: to retrieve a hypothetical object with username and password properties, you'll want your appsettings.json like this:
"Credentials": {
"SecretsManager": "YOUR-SECRET-ID"
}
Then call it in your code:
var MyCredentialsSection = _configuration.GetSection("Credentials");
var SecretId = MySection["SecretsManager"];
var mySecretValue = _credentialsFacade.GetObjectProperty<T>(SecretId);
Again, you have to store the object in Aws Secrets Manager using a Json format. In this case:
{
"username": "YOUR-USERNAME",
"password": "YOUR-PASSWORD"
}
IMPORTANT
For Aws credentials, the section must be declared in appsettings.json like this:
"Aws": {
"SecretsManager": "YOUR-SECRET-ID"
}
It works parsing hardcoded values too:
"Aws": {
"AccountId": "YOUR-ACCOUNT-ID",
"AccessKey": "YOUR-ACCESS-KEY",
"SecretKey": "YOUR-SECRET-KEY",
"Region": "YOUR-REGION-ID"
}
although, for security reasons, is strongly suggested that you use Secrets Manager stored property values.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- AWSSDK.SecretsManager (>= 3.3.102.57)
- AWSSDK.SecretsManager.Caching (>= 1.0.3)
- Microsoft.Extensions.Configuration.Abstractions (>= 3.1.5)
- Microsoft.Extensions.Logging.Abstractions (>= 3.1.5)
- Newtonsoft.Json (>= 12.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.