The Context Object - Serverless Architectures with AWS Lambda

The Context Object

Your Lambda function is also provided with a context object. The context object allows your function code to interact with the Lambda execution environment. The contents and structure of the context object vary, based on the language runtime your Lambda function is using, but at minimum it will contain:

  • AWS RequestId – Used to track specific invocations of a Lambda function (important for error reporting or when contacting AWS Support).

  • Remaining time – The amount of time in milliseconds that remain before your function timeout occurs (Lambda functions can run a maximum of 300 seconds as of this publishing, but you can configure a shorter timeout).

  • Logging – Each language runtime provides the ability to stream log statements to Amazon CloudWatch Logs. The context object contains information about which CloudWatch Logs stream your log statements will be sent to. For more information about how logging is handled in each language runtime, see the following: