aws-dotnet-extensions-configuration icon indicating copy to clipboard operation
aws-dotnet-extensions-configuration copied to clipboard

Fetching a single parameter with full path does not work

Open tompanchee opened this issue 6 years ago • 10 comments

We are working on multiple projects in AWS and have multiple parameters. Some projects need only one parameter from a hierarchy. When adding a full path to the source's path property no parameters are fetched.

I tried with the SimpleSystemsManagement client and noticed that the method used (GetParametersByPathAsync) does not return any parameters with a full parameter path. There should be a method for getting single parameter(s) and optionally it could have the configuration key(s) as an parameter.

tompanchee avatar Aug 09 '19 08:08 tompanchee

Hi @tompanchee , could you please clarify what you are hoping to do? Maybe providing a short sample of code would help. The client has another method called GetParameterAsync that allows you search by a single parameter. Is this what you are looking for?

klaytaybai avatar Aug 12 '19 23:08 klaytaybai

Hi @klaytaybai, I was thinking of using GetParametesAsync to reduce roundtrips to the API when there are multiple fully qualified paths.

I thought it could work like this

config.AddSystemsManager(source => {
    source.Parameters = new Dictionary<string, string> {
        {"/foo/bar/param1", "aws:app:param1"},
        {"/bar/foo/param2", null }    
    };
    source.ReloadAfter = TimeSpan.FromMinutes(15);
});

The dictionary contains the parameters to be fetched and their parameter names in .net configuration. If the .net configuration name is not given the parameter will be named according to the source (/bar/foo/param2 => bar:foo:param2.

If this sounds sensible I could catch this one and start working on a PR.

tompanchee avatar Aug 13 '19 05:08 tompanchee

Could someone please comment on my suggestion. This will start closing in a few days.

tompanchee avatar Sep 19 '19 10:09 tompanchee

I think you're going to find that you will be limited by the service's API. The new method could possibly be setup to do GetParametersAsync requests as few times as necessary to get all the parameters based on their shared path prefixes. Is that essentially what you are thinking? I've asked some of the other AWS .NET SDK teams members to take a look at this and give you their opinion too.

klaytaybai avatar Sep 19 '19 21:09 klaytaybai

I wrote a simple test app to test the GetParametersAsyncMethod and it seemed to work. We are using the same method in node.js projects.

tompanchee avatar Sep 20 '19 07:09 tompanchee

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

github-actions[bot] avatar Feb 19 '22 00:02 github-actions[bot]

This is a feature greatly desired by our team. We have multiple use cases where the ability to retrieve a single SSM parameter (or a few parameters in different path sections) into IConfiguration would be very helpful. Please don't close this issue.

cfbao avatar Feb 19 '22 05:02 cfbao

draft PR to support this: https://github.com/aws/aws-dotnet-extensions-configuration/pull/107

cfbao avatar Feb 23 '22 19:02 cfbao

@tompanchee Good afternoon. Could you please check if of Amazon.Extensions.Configuration.SystemsManager version 4.0.0 fixes your scenario and if this issue could be closed?

Thanks, Ashish

ashishdhingra avatar Dec 27 '22 23:12 ashishdhingra

Not the issue author, but I've looked at the code change for v4, and pretty sure this requested use case is not covered by it.

cfbao avatar Dec 28 '22 04:12 cfbao