This package adds configuration support for Scaleway Secret Manager
$ dotnet add package LodeKennes.Extensions.Scaleway.SecretManager
This NuGet package provides an extension for integrating Scaleway Secret Manager secrets into your .NET application's configuration system. It allows seamless fetching and management of secrets stored in Scaleway using the Scaleway CLI or via self-defined credentials.
IConfiguration system.UseCli.To install the package, use the following command in your terminal:
dotnet add package LodeKennes.Extensions.Scaleway.SecretManager
To use the extension, add it to your IConfigurationBuilder like so:
using LodeKennes.Extensions.Scaleway.SecretManager;
using Microsoft.Extensions.Configuration;
var configurationBuilder = new ConfigurationBuilder()
.AddScalewayCliSecrets(options =>
{
options.ProjectId = Guid.Parse("your-project-id-here");
options.Region = "your-region-here"; // Optional: specify the region if needed
options.EnableCaching(TimeSpan.FromMinutes(1)); // Optional: enable caching to reduce the number of calls to the Scaleway API
// Define the authentication strategy
options.UseCli(); // use the Scaleway CLI to fetch credentials
options.UseCredentials("<secretKey>", "<region>", "<organizationId>"); // use self-defined credentials
})
.Build();
var configuration = configurationBuilder.Build();
An example unit test illustrates how to use the AddScalewayCliSecrets extension method:
[Fact]
public void ZoneVariableShouldLoad()
{
var configurationBuilder = new ConfigurationBuilder()
.AddScalewayCliSecrets(options =>
{
options.ProjectId = Guid.Parse("7C85EC8F-CAA2-4579-A6B9-FB6581A23E08");
options.UseCli();
options.FilterByTags("zone");
})
.Build();
Assert.NotNull(configurationBuilder);
var zone = configurationBuilder["zone"];
Assert.NotNull(zone);
Assert.True("intellua.com" == zone);
}
ScalewayCliException: Thrown when Scaleway CLI is not installed.
Feel free to open an issue or submit a pull request if you have any improvements or additional features you'd like to contribute.
This project is licensed under the MIT License. See the LICENSE file for more details.