Try to retrieve secure string from parameter store #144
-
Hi EveryOne I am trying to following this tutorial https://aws.amazon.com/blogs/developer/net-core-configuration-provider-for-aws-systems-manager/ but i am trying to using secure string instead string then i am facing issue 'cause is not working |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi @jurado75, Good afternoon. I'm unsure what you are doing wrong, unfortunately, I'm unable to reproduce the issue. Reproduction Steps:
builder.Configuration.AddSystemsManager("/myapplication")
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["ConnectionStrings:DefaultConnection"];
return Content(defaultConnectionString);
}
}
}
RESULT: You might want to check if the credentials used by your application have at least the permissions mentioned at https://github.com/aws/aws-dotnet-extensions-configuration#parameter-store. Also as mentioned in section ** Allowing only specific parameters to run on nodes** at https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-access.html, you should also add the permission to Thanks, @bot propose-answer |
Beta Was this translation helpful? Give feedback.
-
I agree with you, i was a mistake from my side, right now its working properly. Cheers mate :) |
Beta Was this translation helpful? Give feedback.
-
For anyone who might be interested: It works just fine when accessing data via the configuration object. The problem arises when working with the Options pattern. Under that scenario, the parameters are retrieved with their raw encrypted values. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
Hi @jurado75,
Good afternoon.
I'm unsure what you are doing wrong, unfortunately, I'm unable to reproduce the issue.
Reproduction Steps:
/myapplication/ConnectionStrings/DefaultConnection
of TypeSecureString
and valueServer=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;
. The parameter is secured usingKMS Key ID
valuealias/aws/ssm
(default for current AWS account).Amazon.Extensions.Configuration.SystemsManager
version5.0.2
.Program.cs
to add below line beforevar app = builder.Build()
: