Home > Blockchain >  Reading the values from parameter store using AmazonSimpleSystemsManagementClient
Reading the values from parameter store using AmazonSimpleSystemsManagementClient

Time:10-26

I am trying to retrieve the value from amazon parameterstore using AmazonSimpleSystemsManagementClient. I installed AWSSDK.SimpleSystemsManagement in my asp.net application. I wrote this code in my class:

    using Amazon.SimpleSystemsManagement;
    using Amazon.SimpleSystemsManagement.Model;

    var request = new GetParameterRequest()
                {
                    Name = "/CleanArchitectureAppWebApi/postgresconnection"
                };
    
                using (var client = new AmazonSimpleSystemsManagementClient(RegionEndpoint.GetBySystemName("us-west-2")))
                {
                    var response = client.GetParameterAsync(request).GetAwaiter().GetResult();
                    // connectionString = response.Parameter.Value;
                }

I keep getting an error on this line saying "the type AmazonSimpleSystemsManagementClient exists in both AWSSDK.simplesystemsManagement". I am not sure why this error is coming. I tried to prefix this line:

 using (var client = new AmazonSimpleSystemsManagementClient(RegionEndpoint.GetBySystemName("us-west-2")))

like this:

using (var client = new Amazon.SimpleSystemsManagement.AmazonSimpleSystemsManagementClient(RegionEndpoint.GetBySystemName("us-west-2")))

the error is still not going away. Below is the screenshot:

enter image description here

CodePudding user response:

Did you add the proper package using NuGET? I executed this .NET code:

using Amazon.SimpleSystemsManagement;
using Amazon.SimpleSystemsManagement.Model;
...

 var client = new AmazonSimpleSystemsManagementClient();

  var request = new GetParameterRequest()
   {
       Name = "RDSConnection"
  };

  var response = client.GetParameterAsync(request).GetAwaiter().GetResult();

  Console.WriteLine("Parameter value is "   response.Parameter.Value);

Result was successful:

enter image description here

  • Related