简体   繁体   中英

AWS Lambda: How to get environment variables

Inside my lambda_handler function, how can I get the environment variables that I have defined?

def lambda_handler(event, context):
     
    # Get environment variables (see screenshot below)   
    key1 = event[0]
    key2 = event[1]
    key3 = event[2]

    return {
        'statusCode': 200,
        'body': key1
    }

Environment Variables在此处输入图像描述

These are not actually the environment variables, this is the event payload passed into the Lambda.

In your case you would access this by accessing its keys in the structure ie event['key1'] . To reiterate this event contents are the payload passed in by the invoker (be that a service or the SDK).

Environment variables do exist in Lambda, but are accessed in the native way the language would access the environment variables.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM