I am developing AWS Lambda (NET6) function.
Now it uses appsettings.json file for RDS connection string and some other config parameters.
What in AWS can be used as a replacement for appsetings: AWS Parameter store, AWS SystemsManager etc?
Question posted in Amazon Web Sevices
The official Amazon Web Services documentation can be found here.
The official Amazon Web Services documentation can be found here.
2
Answers
As you mentioned, you need AWS Services to store Credentials and secrets that can be used in the Lambda function.
There are tools that can be used for the same purpose. Here are some:
To use Parameter Store:
This approach provides better security since you can leverage encryption and fine-grained access control over your parameters.
To use Secrets Manager:
Secrets Manager provides an additional layer of security, particularly suited for sensitive data.
AWS Systems Manager Parameter Store is an alternative to the
appsettings.json
file as it allows you to save data in a hierarchical order. In the .NET application, theConfigurationBuilder
is commonly used to initialize the values from theappsettings.json
file into the application.Similarly, if you use Amazon.Extensions.Configuration.SystemsManager NuGet package, it helps to initialize your app-settings details from the SSM parameter store into the lambda function. IMO, It’s the best alternative, as it requires only minimum code changes on your end.
Here’s an example of how to use it:
The mentioned SSM path in the configuration will load all the child elements underneath it into the
IConfiguration
. As a result, you can useIConfiguration
to read your configuration details that are stored in the SSM parameter store, just like how you read values fromappsettings.json
file.Note that to save database credentials or any other sensitive information in the SSM parameter store, use the parameter type as a
secure string
.You can also consider using the Secrets Manager to manage your RDS credentials, and it will help to rotate your DB credentials periodically.