Environment Variables in AWS Lambda - amresh087/newronaRepos GitHub Wiki

serverless.yml

   service: my-aws-python3-demo
   frameworkVersion: '3'

   provider:
     name: aws
     runtime: python3.9

   # you can overwrite defaults here
     stage: dev
     region: us-east-1

   # you can add statements to the Lambda function's IAM Role here
     iam:
       role:
         statements:
           - Effect: "Allow"
             Action:
               - "lambda:*"
             Resource: 
               - "*"
   # you can define service wide environment variables here
     environment:
       variable1: value1
       variable3: value3
       FIRST_NAME: "Amresh Verma"

   functions:
     iam-example:
       handler: handler.hello
       timeout: 3
       memorySize: 128  

handler.py

   import json
   import os

   def hello(event, context):
     return os.environ['FIRST_NAME']

 

## Same like in vpc we can deploy