-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate SSM parameter with different Case cause the whole SSM parameter fail to load #146
Comments
When running the sample with multiple parameters with same name but differing in case, the error <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Extensions.Configuration.SystemsManager" Version="5.0.2" />
</ItemGroup>
</Project> Program.cs using Microsoft.Extensions.Configuration;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Configuration.AddSystemsManager("/dotnet-aws-samples/systems-manager-sample");
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run(); Pages\Index.cshtml.cs using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace TestParameterStoreAspNet.Pages
{
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly IConfiguration Configuration;
public IndexModel(ILogger<IndexModel> logger, IConfiguration configuration)
{
_logger = logger;
Configuration = configuration;
}
public ContentResult OnGet()
{
var defaultConnectionString = Configuration["OracleConnectionString"];
return Content($"{defaultConnectionString}");
}
}
} @malah-code You mentioned expected behavior to throw an error. Are you not getting error in your case? Thanks, |
@ashishdhingra , Note that I use
Also note that I use optional=true because we need to take default values from other settings, but the SSM parameter (if exists) should overwrite at the end , so we use the code like that in program.cs
|
@malah-code The probable reason is that when optional is |
What we should be doing if we get this error is throw an exception even if |
I can't find clear documentation of the
|
@malah-code I debated the same thing about |
Just a proposed solution to provide Tolerant Implementation in case of duplicate parameters that may located in SSM with different CASE (like \Path1\Param1 and \path1\param1 , only first one will be taken).
|
Created PR #171 |
Amazon.Extensions.Configuration.SystemsManager 6.2.0 released containing the change. Kindly note that this is a breaking change and exception would be thrown if duplicate Systems Manager parameter keys (case insensitive) are detected irrespective of whether the parameter is optional or not. |
|
Describe the bug
If we have duplicate SSM parameters with different case like below, the whole SSM parameters not added to the config at all.
note: this is applicable, because AWS SSM parameter names are case sensitive.
this is because of the code in DefaultParameterProcessor, that doesn't take into consideration is edge case.
Expected Behavior
Just ignore the duplicate SSM parameter and continue, or load the latest duplicate SSM parameters , or even throw error, that will be acceptable too (when configureSource.Optional = true).
Current Behavior
silently ignores ALL the SSM parameters and not add any of them to the config.
Reproduction Steps
to reproduce, setup the sample project, and add below parameters to the AWS SSM , and use
configureSource.Optional = true
reload the project, you will not find any config value coming from AWS SSM at all.
Possible Solution
this pull request should have the fix #145
summary
we just add 2 lines of code in
DefaultParameterProcessor.cs
file, to prevent duplicated keys and take first one only instead of throw errorSo the final method will be like that
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
"AWSSDK.AppConfigData" Version="3.7.0.23"
"AWSSDK.Extensions.NETCore.Setup" Version="3.7.1"
"AWSSDK.SimpleSystemsManagement" Version="3.7.12.9"
"Microsoft.Extensions.Configuration" Version="2.0.*"
Targeted .NET Platform
net6.0
Operating System and version
AmazonLinux, and MacOs 13.3.1
The text was updated successfully, but these errors were encountered: