In previous chapters, we saw how to use environment variables with AWS Lambda to dynamically pass data to the function code without changing any code. According to the Twelve Factor App methodology (https://12factor.net/) , you should always separate your configuration from your code to avoid checking sensitive credentials to a repository and to be able to define multiple releases of your Lambda functions (staging, production, and sandbox) with the same source code. Moreover, environment variables can be used to change the function behavior based on different settings (A/B testing).
If you want to share secrets across multiple Lambda functions, you can use AWS's System Manager Parameter Store.
The following example illustrates how environment variables can be used to pass MySQL credentials to the function's code:
func handler() error...