However, if I set the environment variable on the website UI, it does work.
This seems to have an issue with the environment variables from the configuration file.
Environment variables set in the UI are also accessible in other environments associated with your site, including serverless functions at execution time, snippet injection during post processing, and more.
Which means only UI environment variables are shared with AWS Lambda, which is a bit weird.
Yup! That is how our system works at the moment - only variables in the UI are “Deployed” with your functions. This allows you to split things like API tokens you need at build time, from things you need at function serve time, so you don’t send “everything” to AWS. Security aside, AWS limits the quantity of environment data you can send to 4kb as concatenated + encoded text (cf Understand the Lambda environment variable size quota) so this split is needed for many customers who need more environment data (plus we include a whole lot by default! see Build environment variables | Netlify Docs for details) than lambdas can have.
Would it be possible to at least have an option to specify values to “deploy” to AWS Lambda from the configuration file? Not everything is “secret” and it is quite annoying some times to split values between the config, and the UI.
Maybe a special functions_env field or something similar?
Hey @lambrospetrou,
Yes, agreed that this would be an awesome feature. We have an open request for this internally and I’ve added this thread to that conversation so we can be sure to follow up with you if it ships.
Hey there, has setting node version via netlify config file been added since?
I agree, good DX would be a single SPOT (single point of truth) (node versions is certainly no concern for security).
Hey @MentalGear,
You can set NODE_VERSION for your Netlify build in the netlify.toml, yes, but no environment variables in your netlify.toml will make it to your functions unless they are specified in the UI. Hope that helps clear things up