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?
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.
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