简体   繁体   中英

Testing Python “Hello World” in AWS Lambda

I will apologies first hand if my question formatting is messed up. A noob programmer here

I was following steps defined in the AWS Lambda Developer Guide to run the Hello World code. Ref Page 44

def my_handler(event, context):
    message = 'Hello {} {}!'.format(event['first_name'],
                                    event['last_name'])
    return {
        'message' : message
}     

Test error in AWS 在此处输入图片说明

I believe my error is that the code is looking for events but the input test event on the test page is providing 3 key values which have no relation to my code.

testpage 在此处输入图片说明

Make sure the Test Event in the AWS Console provides values that the program expects. It's passing three keys key1 , key2 , key3 while the program expects first_name and last_name

Just change the Test Event's values to the following instead

{
    "first_name": "foo",
    "last_name": "bar
}

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