I am following the readme here: https://github.com/awslabs/aws-sam-local
I have a lambda written in python 3.6 and its similar to the helloworld example here : https://g
Any environment variables you want to use with SAM Local in this manner need to exist in your SAM template. From this GitHub issue:
... SAM Local only parses environment variables that are defined in the SAM template.
In the template, you can provide no value, an empty string, or choose a sensible default.
A portion of a template including environment variables:
Resources:
MyFunction1:
Type: 'AWS::Serverless::Function'
Properties:
.....
Environment:
Variables:
api_key:
BUCKET_NAME:
You can think of the environment variables file as a mechanism to override environment variables that the template "knows" about. It does not work as a mechanism to inject arbitrary environment variables into the local runtime.