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
function_name – The name of the Lambda function. ... invoked_function_arn – The Amazon Resource Name (ARN) that's used to invoke the function. Indicates if the invoker specified a version number or alias. memory_limit_in_mb – The amount of memory that's allocated for the function. ...
🌐
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
package example; import com.amazonaws.services.lambda.runtime.Context; import com.amazonaws.services.lambda.runtime.CognitoIdentity; import com.amazonaws.services.lambda.runtime.ClientContext; import com.amazonaws.services.lambda.runtime.LambdaLogger; public class TestContext implements Context{ public TestContext() {} public String getAwsRequestId(){ return new String("495b12a8-xmpl-4eca-8168-160484189f99"); } public String getLogGroupName(){ return new String("/aws/lambda/my-function"); } public String getLogStreamName(){ return new String("2020/02/26/[$LATEST]704f8dxmpla04097b9134246b8438f1
Discussions

What are event and context in function call in AWS Lambda?
Here is detailed documentation about context, with an example. ... Sign up to request clarification or add additional context in comments. ... 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 ... More on stackoverflow.com
🌐 stackoverflow.com
What fields/properties do 'event' and 'context' have in a Python Lambda invoked by API Gateway?
Assuming you are using a proxy integration the event looks like this: https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html#apigateway-example-event The context object: https://docs.aws.amazon.com/lambda/latest/dg/python-context.html More on reddit.com
🌐 r/aws
4
3
February 25, 2022
amazon web services - How to see context variable in lambda function - Stack Overflow
Lambda request id: 32d4e450-576b-4bd6-abb9-d1bd893077ed Mon May 24 07:20:58 UTC 2021 : Method completed with status: 502 · context is not json format ? How can I see context in handler ? ... Ooh, nice link! It looks like context is a class, upon which functions can be called. It isn't a data object ... More on stackoverflow.com
🌐 stackoverflow.com
AWS Lambda logging everything in the execution context
That wouldn't be Lambda doing that, have you confirmed you aren't using any Lambda Extensions or extending a class that might be logging in your handler code? Search your codebase and dependencies for "Lambda Deserialize" and see what turns up. More on reddit.com
🌐 r/aws
9
3
March 22, 2023
🌐
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
awsRequestId – The identifier of the invocation request. ... identity – (mobile apps) Information about the Amazon Cognito identity that authorized the request. cognitoIdentityId – The authenticated Amazon Cognito identity. cognitoIdentityPoolId – The Amazon Cognito identity pool that authorized the invocation. clientContext – (mobile apps) Client context that's provided to Lambda by the client application.
🌐
GitHub
gist.github.com › gene1wood › c0d37dfcb598fc133a8c
Details on the AWS Lambda Python LambdaContext context object when instantiated from a CloudFormation stack · GitHub
More information on the context object can be found here : http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html ... { 'aws_request_id': 'a3de505e-f16b-42f4-b3e6-bcd2e4a73903', 'log_stream_name': '2015/10/26/[$LATEST]c71058d852474b9895a0f221f73402ad', 'invoked_function_arn': 'arn:aws:lambda:us-west-2:123456789012:function:ExampleCloudFormationStackName-ExampleLambdaFunctionResourceName-AULC3LB8Q02F', 'client_context': None, 'log_group_name': '/aws/lambda/ExampleCloudFormationStackName-ExampleLambdaFunctionResourceName-AULC3LB8Q02F', 'function_name': 'ExampleCloudFormationStackName-ExampleLambdaFunctionResourceName-AULC3LB8Q02F', 'function_version': '$LATEST', 'identity': <__main__.CognitoIdentity object at 0x7fd7042a2b90>, 'memory_limit_in_mb': '128' }
🌐
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
The following example introduces how to use the context object to monitor how long your Lambda function takes to complete. This allows you to analyze performance expectations and adjust your function code accordingly, if needed. package main import ( "context" "log" "time" "github.com/aws/...
🌐
Learning-Ocean
learning-ocean.com › tutorials › aws › aws-lambda-context-object
Aws - Context Object in AWS Lambda - Learning-Ocean
Here’s a simple example to explore the Context object: import json def lambda_handler(event, context): print("Function Name:", context.function_name) print("Memory Limit (MB):", context.memory_limit_in_mb) print("Function Version:", context.function_version) print("Invocation ARN:", context.invoked_function_arn) print("AWS Request ID:", context.aws_request_id) print("Remaining Time (ms):", context.get_remaining_time_in_millis()) return { "statusCode": 200, "body": json.dumps("Context object explored!") }
🌐
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
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] namespace GetProductHandler; public class Function { private readonly IDatabaseRepository _repo; public Function() { this._repo = new DatabaseRepository(); } public async Task<APIGatewayProxyResponse> FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) { Logger.AppendKey("AwsRequestId", context.AwsRequestId); var id = request.PathParameters["id"]; using var cts = new CancellationTokenSource(); try { cts.CancelAfter(context.RemainingTime.Add(TimeSpan.FromSeconds(-1)))
Find elsewhere
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.

🌐
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?
February 25, 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?

🌐
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
package as a development dependency and import the Context type. For more information, see Type definitions for Lambda. getRemainingTimeInMillis() – Returns the number of milliseconds left before the execution times out. ... invokedFunctionArn – The Amazon Resource Name (ARN) that's used to invoke the function. Indicates if the invoker specified a version number or alias. memoryLimitInMB – The amount of memory that's allocated for the function. awsRequestId – The identifier of the invocation request.
🌐
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
aws_request_id – The identifier of the invocation request. log_group_name – The log group for the function. log_stream_name – The log stream for the function instance. deadline_ms– The date that the execution times out, in Unix time milliseconds. identity – (mobile apps) Information about the Amazon Cognito identity that authorized the request. client_context– (mobile apps) Client context that's provided to Lambda by the client application.
🌐
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.
🌐
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, monitor execution, and handle errors.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › define lambda function handler in python
Define Lambda function handler in Python - AWS Lambda
January 31, 2026 - The context object is a Python ... method on the context object. For example, the following code snippet assigns the value of the aws_request_id property (the identifier for the invocation request) to a variable named request....
🌐
Stack Overflow
stackoverflow.com › questions › 67668114 › how-to-see-context-variable-in-lambda-function
amazon web services - How to see context variable in lambda function - Stack Overflow
Note you can simply print the context object and it will appear in CloudWatch Logs. ... You can print it and see if you want. It would be something like this: LambdaContext([aws_request_id=7d78a745-bb86-42b8-89f0-389e9bdc3dcfe,log_group_name=/aws/lambda/mldx-devops-v1-TimeLambda-hINHLpDGpaNR,log_stream_name=2022/09/01/[$LATEST]0553dabc81194a57adf2a96775f88d02,function_name=mldx-devops-v1-TimeLambda-hINHLpDGpaNR,memory_limit_in_mb=128,function_version=$LATEST,invoked_function_arn=arn:aws:lambda:eu-west-1:187276065257:function:mldx-devops-v1-TimeLambda-hINHLpDGpaNR,client_context=None,identity=CognitoIdentity([cognito_identity_id=None,cognito_identity_pool_id=None])])
🌐
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
use lambda_runtime::{service_fn, LambdaEvent, Error}; use serde_json::{json, Value}; async fn handler(event: LambdaEvent<Value>) -> Result<Value, Error> { let invoked_function_arn = event.context.invoked_function_arn; Ok(json!({ "message": format!("Hello, this is function {invoked_function_arn}!") })) } #[tokio::main] async fn main() -> Result<(), Error> { lambda_runtime::run(service_fn(handler)).await }
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with powershell › using the lambda context object to retrieve powershell function information
Using the Lambda context object to retrieve PowerShell function information - AWS Lambda
ClientContext – (mobile apps) Client context that's provided to Lambda by the client application. Logger – The logger object for the function. The following PowerShell code snippet shows a simple handler function that prints some of the context information. #Requires -Modules @{ModuleName='AWSPowerShell.NetCore';ModuleVersion='3.3.618.0'} Write-Host 'Function name:' $LambdaContext.FunctionName Write-Host 'Remaining milliseconds:' $LambdaContext.RemainingTime.TotalMilliseconds Write-Host 'Log group name:' $LambdaContext.LogGroupName Write-Host 'Log stream name:' $LambdaContext.LogStreamName
🌐
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 ·
🌐
Readthedocs
run-lambda.readthedocs.io › en › latest › context.html
Context Objects — Run Lambda 0.1.7.2 documentation
Constructs and returns a MockLambdaContext instance represented by the called builder object. ... Sets a default value that will be returned from the get_remaining_time_in_millis() method of the built MockLambdaContext value if a Lambda function is called without a timeout.