Setting AWS_LAMBDA_JS_RUNTIME in netlify.toml for template / deploy button

Thanks for node 18 support in functions!

I’m currently writing a template repository (to be deployed via the Deploy to Netlify button) and I plan to use fetch a lot, so I need to set some env vars. I tried using this in netlify.toml

[context.production.environment]
  AWS_LAMBDA_JS_RUNTIME = "nodejs18.x"
  NODE_NO_WARNINGS = "1"

but it does not work. I’ve looked around and I see Are environment variables specified in netlify.toml accessible in functions? - #2 by hrishikesh and Defining environment variables for git LFS in netlify.toml - #2 by luke and Can I set `AWS_LAMBDA_JS_RUNTIME` without having to use the UI which say “no”

Other than setting them in [template.environment], is there a way to pre-define those variables for users? netlify-plugin-inline-functions-env will probably not work as the vars are not used in code, so inlining is useless.

Thanks!

That’s not possible. Since Netlify Functions need variables to be set in the UI, doing anything inside the toml would not work.

I believe you can create a custom build plugin and that change the site’s environment variables:

However, I am not sure if those variables make it to the Functions or not.