Event represents the event or trigger that caused the invocation of the lambda. For example, if your lambda is triggered by an upload to S3 this will contain information about the object being uploaded for example:

    {
      "Records": [
        {
          "eventVersion": "2.0",
          "eventTime": "1970-01-01T00:00:00.000Z",
          "requestParameters": {
            "sourceIPAddress": "127.0.0.1"
          },
          "s3": {
            "configurationId": "testConfigRule",
            "object": {
              "eTag": "0123456789abcdef0123456789abcdef",
              "sequencer": "0A1B2C3D4E5F678901",
              "key": "HappyFace.jpg",
              "size": 1024
            },
            "bucket": {
              "arn": bucketarn,
              "name": "sourcebucket",
              "ownerIdentity": {
                "principalId": "EXAMPLE"
              }
            },
            "s3SchemaVersion": "1.0"
          },
          "responseElements": {
            "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH",
            "x-amz-request-id": "EXAMPLE123456789"
          },
          "awsRegion": "us-east-1",
          "eventName": "ObjectCreated:Put",
          "userIdentity": {
            "principalId": "EXAMPLE"
          },
          "eventSource": "aws:s3"
        }
      ]
    }

Here is detailed information about events, with an example.

Context Provides information about the invocation, function, and execution environment of your lambda. So you can use this to check the memory allocation or to retrieve the number of milliseconds left before the execution times out. Here is detailed documentation about context, with an example.

Answer from Jarred Olson on Stack Overflow
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › using the lambda context object to retrieve python function information
Using the Lambda context object to retrieve Python function information - AWS Lambda
When Lambda runs your function, it passes a context object to the handler. This object provides methods and properties that provide information about the invocation, function, and execution environment.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with node.js › using the lambda context object to retrieve node.js function information
Using the Lambda context object to retrieve Node.js function information - AWS Lambda
When Lambda runs your function, it passes a context object to the handler . This object provides methods and properties that provide information about the invocation, function, and execution environment.
Top answer
1 of 3
30

Event represents the event or trigger that caused the invocation of the lambda. For example, if your lambda is triggered by an upload to S3 this will contain information about the object being uploaded for example:

    {
      "Records": [
        {
          "eventVersion": "2.0",
          "eventTime": "1970-01-01T00:00:00.000Z",
          "requestParameters": {
            "sourceIPAddress": "127.0.0.1"
          },
          "s3": {
            "configurationId": "testConfigRule",
            "object": {
              "eTag": "0123456789abcdef0123456789abcdef",
              "sequencer": "0A1B2C3D4E5F678901",
              "key": "HappyFace.jpg",
              "size": 1024
            },
            "bucket": {
              "arn": bucketarn,
              "name": "sourcebucket",
              "ownerIdentity": {
                "principalId": "EXAMPLE"
              }
            },
            "s3SchemaVersion": "1.0"
          },
          "responseElements": {
            "x-amz-id-2": "EXAMPLE123/5678abcdefghijklambdaisawesome/mnopqrstuvwxyzABCDEFGH",
            "x-amz-request-id": "EXAMPLE123456789"
          },
          "awsRegion": "us-east-1",
          "eventName": "ObjectCreated:Put",
          "userIdentity": {
            "principalId": "EXAMPLE"
          },
          "eventSource": "aws:s3"
        }
      ]
    }

Here is detailed information about events, with an example.

Context Provides information about the invocation, function, and execution environment of your lambda. So you can use this to check the memory allocation or to retrieve the number of milliseconds left before the execution times out. Here is detailed documentation about context, with an example.

2 of 3
3

From the docs

When Lambda runs your function, it passes a context object to the handler. This object provides methods and properties that provide information about the invocation, function, and execution environment.

Event (and the args) are described here.

To put it more simply, think of event as an input to a regular function. Context is an extra input supplied by AWS to give you a variety of meta context and such.

🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with java › using the lambda context object to retrieve java function information
Using the Lambda context object to retrieve Java function information - AWS Lambda
When Lambda runs your function, it passes a context object to the handler . This object provides methods and properties that provide information about the invocation, function, and execution environment.
🌐
Learning-Ocean
learning-ocean.com › tutorials › aws › aws-lambda-context-object
Aws - Context Object in AWS Lambda - Learning-Ocean
In AWS Lambda, the Context object is a critical component passed to your function alongside the event parameter.
🌐
GitHub
gist.github.com › gene1wood › c0d37dfcb598fc133a8c
Details on the AWS Lambda Python LambdaContext context object when instantiated from a CloudFormation stack · GitHub
Alexa's skill id is delivered the context object during certain audio playback requests. does that have an alias? ... Just found this, but for anyone else looking, AWS Lambda's Python runtime does not have a succeed() capability.
🌐
Reddit
reddit.com › r/aws › what fields/properties do 'event' and 'context' have in a python lambda invoked by api gateway?
r/aws on Reddit: What fields/properties do 'event' and 'context' have in a Python Lambda invoked by API Gateway?
September 23, 2022 -

I am writing a Python Lambda that will be invoked via HTTP. A web service will make an HTTP call to an API Gateway resource that I define, which will then invoke the Lambda. My Lambda handler will look like:

def lambda_handler(event, context):
    // do stuff down here
    return responseObject

I am trying to find documentation on event and context so I know how to do things like:

  • extract query string parameters from requests

  • extract path parameters from requests

  • inspect the request entity

  • etc.

Surprising I can find no official AWS documentation on what fields/properties these two objects have on them when they are invoked from an API Gateway resource action. I found this article which was sort of helpful but nothing official from AWS. Can anyone point me in the right direction?

🌐
Readthedocs
aws-lambda-for-python-developers.readthedocs.io › en › latest › 02_event_and_context
Chapter 2: What is the event & context? - AWS Lambda for Python Developers
It's main role is to provide information about the current execution environment. Unlike event, the methods and properties of the context object remain the same regardless of the lambda was invoked or triggered.
Find elsewhere
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with go › using the lambda context object to retrieve go function information
Using the Lambda context object to retrieve Go function information - AWS Lambda
In Lambda, the context object provides methods and properties with information about the invocation, function, and execution environment. When Lambda runs your function, it passes a context object to the handler . To use the context object in your handler, you can optionally declare it as an ...
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with c# › using the lambda context object to retrieve c# function information
Using the Lambda context object to retrieve C# function information - AWS Lambda
When Lambda runs your function, it passes a context object to the handler . This object provides properties with information about the invocation, function, and execution environment.
🌐
Orchestra
getorchestra.io › guides › context-in-aws-lambda
Context in AWS lambda | Orchestra
September 9, 2024 - In AWS Lambda, the context object is a key component that provides runtime information about the Lambda function's execution. It is passed as a parameter to the Lambda handler function and contains useful data that can help manage function behavior, ...
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with ruby › using the lambda context object to retrieve ruby function information
Using the Lambda context object to retrieve Ruby function information - AWS Lambda
When Lambda runs your function, it passes a context object to the handler . This object provides methods and properties that provide information about the invocation, function, and execution environment.
🌐
DEV Community
dev.to › cfjps › what-is-the-lambda-execution-context-and-why-use-it-3i0b
What is the Lambda Execution context and why use it? - DEV Community
August 14, 2021 - When your Lambda function gets ... runtime environment. The execution context is a temporary runtime environment that initializes any external dependencies of your lambda code....
🌐
Readthedocs
run-lambda.readthedocs.io › en › latest › context.html
Context Objects — Run Lambda 0.1.7.2 documentation
Returns remaining execution time, in milliseconds. Should be called inside of Lambda function. ... Using the MockLambdaContext.Builder class to construct MockLambdaContext instances is strongly encouraged. ... Constructs and returns a MockLambdaContext instance represented by the called builder object.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with typescript › using the lambda context object to retrieve typescript function information
Using the Lambda context object to retrieve TypeScript function information - AWS Lambda
When Lambda runs your function, it passes a context object to the handler . This object provides methods and properties that provide information about the invocation, function, and execution environment.
🌐
PyPI
pypi.org › project › aws-lambda-context
aws-lambda-context
December 3, 2018 - JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
🌐
AWS re:Post
repost.aws › questions › QUi-PLcd7QTAqcS5XQ8bhy3A › how-to-read-the-client-context-sent-with-a-post-request-to-the-lambda-api-invoke
How to read the Client Context sent with a POST request to the Lambda API Invoke? | AWS re:Post
January 16, 2023 - Lambda functions receive two parameters: Event object and Context object. The event object contains all the information about why it was triggered. The context object contains different run-time information, e.g., request ID.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with rust › using the lambda context object to retrieve rust function information
Using the Lambda context object to retrieve Rust function information - AWS Lambda
This object provides properties with information about the invocation, function, and execution environment. request_id: The AWS request ID generated by the Lambda service. deadline: The execution deadline for the current invocation in milliseconds. invoked_function_arn: The Amazon Resource ...
🌐
Javadoc.io
javadoc.io › doc › com.amazonaws › aws-lambda-java-core › 1.0.0 › com › amazonaws › services › lambda › runtime › Context.html
Context (AWS Lambda Java Core Library 1.0.0 API)
Latest version of com.amazonaws:aws-lambda-java-core · https://javadoc.io/doc/com.amazonaws/aws-lambda-java-core · Current version 1.0.0 · https://javadoc.io/doc/com.amazonaws/aws-lambda-java-core/1.0.0 · package-list path (used for javadoc generation -link option) https://javadoc.io/doc/com.amazonaws/aws-lambda-java-core/1.0.0/package-list ·