How is the return object in a Python-AWS lambda used?

In lambda function templates appear the return object

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": json.dumps({
            "message": "hello world 2",

I couldn’t find any documentation about how this object is used.

  • How must be configured?
  • What fields are mandatory?
  • When and how is it used? Can be consumed by other services?

Stack Overflow Asked by Aleix on November 22, 2021

1 Answers

One Answer

You do not need to return any value, but some calling systems want a response.

For example, if the Lambda function is invoked by API Gateway, it needs to send a response back to the original caller. See: Handle Lambda errors in API Gateway

It can also be used to pass back details errors: AWS Lambda function errors in Python

Answered by John Rotenstein on November 22, 2021

Add your own answers!

Related Questions

REACT vs REACT_PROJECT vs WEBPACK for storybook type?

1  Asked on July 29, 2020 by temporary_user_name


Random Background Image from Button Click

1  Asked on July 29, 2020 by charmy


Systemd-journald disk wear-out

0  Asked on July 29, 2020 by rohit


Function composition using Go syntax

1  Asked on July 28, 2020 by overexchange


Replacement to getch based code block in cpp

1  Asked on July 24, 2020 by sonu-ishaq


Combining if let statements in Rust

1  Asked on July 24, 2020 by deniz-basgoren


Ask a Question

Get help from others!

© 2021 All rights reserved.