Lambda NET6: How to read connection string from Parameter Store?

0

Lambda NET 6 -> RDS PostgreSQL . During development I run it on my local workstation as a NET 6 Web app-> localhost PostgreSQL, After deploying to AWS I use RDS. The question: How can I read connection string from appsettings.json file in local version and from AWS Parameter store in case AWS?

Oleg
asked a year ago374 views
1 Answer
1
Accepted Answer

Hi Oleg.

You can use the .NET Configuration Provider to easily read information from AWS Systems Manager Parameter Store. This extension is hosted on GitHub and is free and open source.

I hope this helps (if so, please accept the answer).

profile pictureAWS
EXPERT
answered a year ago
profile picture
EXPERT
reviewed a month ago
  • Hi Jose, thank you for the interesting link. One question: how can I detect where code is executing to get config parameters from appsettings file when local machine and from Parameter store when in AWS?

  • Oleg,

    You would use environment variables for that. Note in the documentation the one called AWS_EXECUTION_ENV. It will return something prefixed with "AWS_Lambda" if it is running in Lambda.

    I hope this answers the question.

  • Also check LAMBDA_TASK_ROOT which will be null or empty for an environment other than Lambda.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions