Reputation: 3907
I've googled around but with no luck... I need to read some configuration values stored inside a AWS Systems Manager -> AppConfig configuration (stored as text, not flag) but I've not found a C# example... I've also tried on the AWS Console to add the layer as specified here but with no success.
For now I've used a SecretManager but it's not the correct place to store the config information... can someone help me? Thanks
Upvotes: 3
Views: 3204
Reputation: 106
The Amazon.Extensions.Configuration.SystemsManager package might be helpful with what you are trying to achieve. You need to store your configuration as JSON.
This is how it can be implemented using the .NET Core Configuration mechanism.
builder.Configuration.SetBasePath(Environment.CurrentDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddSystemsManager($"/{builder.Configuration["AwsAppConfig:ApplicationId"]}/", TimeSpan.FromMinutes(5))
.AddAppConfigUsingLambdaExtension(builder.Configuration["AwsAppConfig:ApplicationId"], builder.Configuration["AwsAppConfig:EnvironmentId"], builder.Configuration["AwsAppConfig:ConfigurationProfileId"])
.Build();
For more information, you can check out the documentation here.
Upvotes: 1
Reputation: 2787
Since your question is about C# example for AppConfig, you can take a look on https://github.com/ScottHand/AppConfigNETCoreSample/tree/5f5db8d375e4df92dd7dc1b8a16f42bfb042e645.
There is interesting issue with .NET client though that https://docs.aws.amazon.com/appconfig/2019-10-09/APIReference/API_GetConfiguration.html is deprecated in favor of StartConfigurationSession
and GetLatestConfiguration
, however .NET client do not have yet support for these methods https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/appconfig/AmazonAppConfigAsyncClient.html
Recommended approach is though to go with lambda extension, so you can try to open another question with your problem of setting up the extension.
Alternatively you can use SSM Parameter Store which also might be suitable for your Lambda use case.
Upvotes: 1