Should SST pick up automatically .env file and loa...
# help
b
Should SST pick up automatically .env file and load them into process.env? https://docs.serverless-stack.com/environment-variables I’ve added .env file but seems like process.env is empty. Am I doing something wrong? Should I include dotenv and dotenv.config() in the beginning of the app? 🙂 I’m using v0.30
g
One thing that confused me is that the variables in your
.env
files are available to your SST/CDK code, not the Lambda functions that you are creating. In order to make them visible to your deployed functions, you need to pass them along using the
environment
key when you define your functions. Hope that helps
Copy code
environment: {
                    "VAR_FOR_MY_LAMBDA": process.env.VAR_FOR_MY_LAMBDA
}
ie, they’re available to the code in the
/lib
folder, not the
/src
folder, if you are following the example templates.
b
That might be good to point out in docs as well 🙂 Thanks!
j
That makes sense. Thanks for pointing it out. Let’s open an issue @Frank?