aws-sam-local environment variables

后端 未结 3 1435
暗喜
暗喜 2021-02-05 02:49

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

3条回答
  •  名媛妹妹
    2021-02-05 03:04

    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.

提交回复
热议问题