skip to Main Content

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?

2

Answers


  1. 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:

    1. AWS Systems Manager Parameter Store

    To use Parameter Store:

    • Store your configuration parameters in Parameter Store.
    • Configure your Lambda function to retrieve these parameters at runtime using the AWS SDK or AWS SDK for .NET.

    This approach provides better security since you can leverage encryption and fine-grained access control over your parameters.

    1. AWS Secrets Manager

    To use Secrets Manager:

    • Store your sensitive configuration information as secrets in Secrets Manager.
    • Configure your Lambda function to retrieve secrets from Secrets Manager at runtime using the AWS SDK or AWS SDK for .NET.

    Secrets Manager provides an additional layer of security, particularly suited for sensitive data.

    1. Environment Variables (Lambda’s ENV)
    Login or Signup to reply.
  2. 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, the ConfigurationBuilder is commonly used to initialize the values from the appsettings.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:

    IConfiguration configurations = new ConfigurationBuilder()
                            .AddSystemsManager("/root-ssm-path-of-your-lambda-function/")
                            .Build();
    

    The mentioned SSM path in the configuration will load all the child elements underneath it into the IConfiguration. As a result, you can use IConfiguration to read your configuration details that are stored in the SSM parameter store, just like how you read values from appsettings.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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search