aws-toolkit-jetbrains
aws-toolkit-jetbrains copied to clipboard
Lambda Local Run should support reading environment variables from a file
you can't setup env variables, or define the location of your requirements file
source: https://plugins.jetbrains.com/plugin/11349-aws-toolkit/reviews#review=44513
When invoking lambda's locally you should be able to define Environment Variables as part of the Run Configuration (see attached) - is this what you're looking for?
Interested in a bit more information about the requirements.txt - do you have a SAM/CloudFormation template?
JetBrains has changed the display of env vars, we have diverged. They now always show it with a white background to indicate editable

Good call
Hi, I don't see the Environment input white and its only editable clicking the icon, so though it wasn't editable sorry. I have a cfn template, by default the plugin finds requirements in the folder of CodeUri, where is the lambda code. It's nice, but my requirements file is shared with other lambdas, so I would like to have it outside that folder, anyway it's not a big problem, to copy it to the folder for run lambda correctly but of course it would be awesome to be able to configure the location of it, but my main problem was I couldn't find how to set the environment variables, so I couldn't use the plugin.
Btw, Is it possible a feature to configure for get environment variables from a .env file? setup manually all environment variables to every lambda of the template is very annoying.
Sorry for the delay in responding.
my requirements file is shared with other lambdas, so I would like to have it outside that folder
The toolkit uses the AWS SAM CLI to build the lambda package - by default it looks for the requirements.txt
at the base of the module (e.g. the CodeUri
directory) - however it is possible to override this behaviour in the run configuration:
- From the Local Lambda invoke run configuration, select the "SAM CLI" tab
- The Build Args box allows you to specify additional parameters to pass to the
sam build
command (docs) - To point to a different location you want the
--manifest
argument and then the location of therequirements.txt
Is it possible a feature to configure for get environment variables from a .env file
Would you see this as a one-time import from the .env file? or would you want the run-configuration to point at the file itself and re-load it on every invocation - that way changes to the file would automatically get picked up? It would be great if you could open a new feature request and include a little more detail on what the experience would be like.
I see, thanks for the response.
I really would like the run-configuration to point by default to the .env file and re-load it in every invocation of course, so If I want to run lambda in other environment, I just can change .env file params, and them running lambda again, its running with the new params.
And it should be able to configure the path to .env file, since for example, I have cloudformation files in cfn folder, not in root folder with the .env file.