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
posta un anno fa399 visualizzazioni
1 Risposta
2
Risposta accettata

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
ESPERTO
con risposta un anno fa
profile picture
ESPERTO
verificato 16 giorni fa
profile picture
ESPERTO
verificato 2 mesi fa
  • 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.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande