serverless-mysql icon indicating copy to clipboard operation
serverless-mysql copied to clipboard

Pick DB Host based on environment

Open aj0y opened this issue 4 years ago • 3 comments

I have multiple "environments" setup for Lambda. One for staging and one for production etc. The DB host is different for each environment. If the mysql configuration needs to be outside the lambda handler, how can i inform it about the environment it's being invoked in? and subsequently the host/db configuration to use?

The environment is usually passed through the context parameter in the aws handler code. Any ideas on how to solve that?

aj0y avatar Aug 17 '20 19:08 aj0y

I guess the solution is to run the configuration code inside the handler?

aj0y avatar Aug 17 '20 19:08 aj0y

if your using lambda#edge use ssm, if your using lambda you can use env variables.

stephanelpaul avatar Oct 10 '20 23:10 stephanelpaul

@aj0y have you solved it? facing simillar issue here

Markkos89 avatar Jul 02 '22 06:07 Markkos89

Hey @aj0y, thanks for opening this issue!

You should take a look at this comment.

It contains a snippet that can help you achieve exactly what you're looking for.

naorpeled avatar Jun 03 '23 22:06 naorpeled