Your Environment
Question
I recently upgraded to the latest version of AWS Toolkit. Now when I use the 'From template' option in the 'Run/Debug Configurations' screen I can't see an option to add environment variables. It does appear if I use 'From handler' instead but then I lose the ability to run a function with layers.
Is there a way to add environment variables with the 'From template' option? This could be done in AWS Toolkit version 1.16-193.
Thanks.
You can do it in the run config by going to the SAM CLI tab and adding the --env-vars or -n flags and the absolute path to your env.json file in the local invoke args section.
Sorry for the inconvenience, it was removed as we re-did the UI and it was deemed confusing given the current UX and the actual limitations of SAM:
In handler mode, you could add any env vars you wanted, but in template mode, only env vars defined in the template would actually be overridden and that was not explained to the user leading to confusion.
We can look into fixing that UI to reveal that limitation. @rdt712 is correct on the current work around.
I also think what might be useful is an "import from remote lambda" feature for both template and handler modes - this would allow us to point at a remote Lambda function and automatically import the environment variables from it. Handy when you have environment variables that are populated by refs' in cfn/cdk.