Sharing what worked for me, for a Netlify lambda function:
-
Adding environment variables through Netlify’s UI widget (on the site’s “Build & Deploy settings” page).
-
netlify.toml
[build]
Command = "npm run lambda-build"
Functions = "lambda"
- Adding
node -p 'process.env'
to my package.jsonlamba-build
command:
"lambda-build": "netlify-lambda build functions && node -p 'process.env'"
This way, when the function is deployed, env variables will we loaded and available to the function.