The event data passed to Lambda contains the Instance ID.

You then need to call describe_tags() to retrieve a dictionary of the tags.

import boto3
client = boto3.client('ec2')

client.describe_tags(Filters=[
        {
            'Name': 'resource-id',
            'Values': [
                event['detail']['instance-id']
            ]
        }
    ]
)
Answer from John Rotenstein on Stack Overflow
🌐
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 - See Code best practices for Python ... function handler, the Lambda runtime passes two arguments to the function, the event object that contains data for your function to process and the context object that contains information about the function invocation....
🌐
Reddit
reddit.com › r/aws › [deleted by user]
Trying to better understand Lambda event objects (Python)
December 22, 2022 - Was it an async invocation that needs no response or is api gateway expecting a response object? ... I’ve got a lambda servicing 200,000 requests a month that maps to 1) SQS 2) SNS 3) DynamoDB, all with their own event formats. First thing my lambda does is rip the event open, see what the EventSource is and then pass the event off to a different in-lambda python function for each event source, each of those functions knows how to parse their own events and they all hand back a python object that I then interact with.
Discussions

python - What does lambda event: do? - Stack Overflow
What is the difference between lambda: and lambda event:. I did some research but can still not work out the difference. Consider this code: import tkinter as tk root = tk.Tk() r = 0 def func(n)... 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
September 23, 2022
amazon web services - Navigating Event in AWS Lambda Python - Stack Overflow
7 How to invoke Lambda function with Event Invocation Type via API Gateway? 5 How to access the event object with python in AWS Lambda? More on stackoverflow.com
🌐 stackoverflow.com
Accessing Lambda Python event - ERROR
lambda error when getting a trigger event from an S3 bucket in another account and reading the object ... How do I resolve "unknown service", "parameter validation failed", or "object has no attribute" errors from a Python (Boto3) Lambda function? More on repost.aws
🌐 repost.aws
2
0
May 14, 2024
🌐
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
Each event will have a different ... the same. The lambda function is triggered, it will inspect its event and perform a logic on the event before returning and terminating. Now that we've covered event, let's move onto context. context is a Python objects that implements methods ...
🌐
AWS Cloud Community
docs.powertools.aws.dev › lambda › python › latest › utilities › data_classes
Event Source Data Classes - Powertools for AWS Lambda (Python)
This example is based on the AWS Cognito docs for Verify Auth Challenge Response Lambda Trigger. app.pyCognito Verify Auth Challengen Example Event · The example integrates with Amazon Connect by handling contact flow events. The function converts the event into a ConnectContactFlowEvent object, providing a structured representation of the contact flow data.
🌐
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
You can use the interface definition for type hints, or to further inspect the structure of the Lambda context object. For the interface definition, see lambda_context.py · in the powertools-lambda-python repository on GitHub. The following example shows a handler function that logs context information. import time def lambda_handler(event, context): print("Lambda function ARN:", context.invoked_function_arn) print("CloudWatch log stream name:", context.log_stream_name) print("CloudWatch log group name:", context.log_group_name) print("Lambda Request ID:", context.aws_request_id) print("Lambda function memory limits in MB:", context.memory_limit_in_mb) # We have added a 1 second delay so you can see the time remaining in get_remaining_time_in_millis.
🌐
GeeksforGeeks
geeksforgeeks.org › cloud computing › lambda-function-handler-in-python
Lambda Function Handler In Python - GeeksforGeeks
July 23, 2025 - An event is generally a JSON Formatted String that contains the data that was passed by the external sources when invoking a Lambda function. It is usually of the 'dict' type in python but it can also be other types, such as 'list', 'int', 'float', ...
Find elsewhere
🌐
CloudThat
cloudthat.com › home › blogs › understanding aws lambda event sources in python
Understanding AWS Lambda Event Sources in Python
February 9, 2026 - In AWS CDK (Python), the aws_lambda_event_sources library gives you pre-built classes for common AWS services. ... Let’s you connect AWS services (like Amazon SQS, Amazon S3, Amazon DynamoDB, Amazon SNS, Amazon Kinesis, Kafka) to AWS Lambda · Works with the high-level function.add_event_source() API ... SqsEventSource – Create an Amazon SQS queue as a trigger for AWS Lambda. S3EventSource – Use an Amazon S3 bucket’s object upload and removal events.
🌐
Kevinhakanson
kevinhakanson.com › 2022-04-10-python-typings-for-aws-lambda-function-events
Python Typings for AWS Lambda Function Events | kevinhakanson.com
I was building a Python-based AWS Lambda function similar to what was announced by New – Use Amazon S3 Event Notifications with Amazon EventBridge and the code looked similar to this - full of “magic strings” that I had to discover. import boto3 def lambda_handler(event, context): bucket = event['detail']['bucket']['name'] file_key = event['detail']['object']['key'] s3 = boto3.client('s3') file_to_process = s3.get_object(Bucket=bucket, Key=file_key) Python has a module called typing that provides support for type hints, which make for a nice autocomplete experience in Visual Studio Code.
🌐
GitHub
gist.github.com › gene1wood › 24e431859c7590c8c834
A python AWS Lambda function which logs the contents of the event and context variables passed into the function. · GitHub
February 27, 2021 - A python AWS Lambda function which logs the contents of the event and context variables passed into the function. - log_aws_lambda_event_and_context.py
🌐
PyPI
pypi.org › project › aws-lambda-event-handler
aws-lambda-event-handler · PyPI
This package provides a decorator for Python Lambda functions handling individual records in the event payload of the AWS Lambda function. ... The following demonstrates how to create a handler object that will be used as the entrypoint for ...
      » pip install aws-lambda-event-handler
    
Published   Aug 25, 2018
Version   0.0.3
🌐
Medium
medium.com › @reach2shristi.81 › starting-your-lambda-journey-with-python-74d95346dd0
Starting your Lambda Journey with Python | by Min_Minu | Medium
June 25, 2023 - The event parameter provides the input data to your Lambda function. Extract relevant information from the event object and perform the required processing or logic.
🌐
AWS Cloud Community
docs.powertools.aws.dev › lambda › python › 1.19.0 › utilities › data_classes
Event Source Data Classes - Lambda Powertools Python
The classes are initialized by passing in the Lambda event object into the constructor of the appropriate data class or by using the event_source decorator.
🌐
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?

🌐
Medium
medium.com › cyberark-engineering › aws-lambda-event-validation-in-python-now-with-powertools-431852ac7caa
AWS Lambda Event Validation in Python — Now with PowerTools | by Ran Isenberg | CyberArk Engineering | Medium
April 23, 2022 - You will offload the maintenance of Pydantic based AWS events schemas from your code to AWS. You will be introduced to one of the best new AWS Lambda related libraries which might solve you other issues you didn't even know you had. Recently, I had the pleasure of contributing a new parser utility code to an amazing and relatively new project on Github: AWS Lambda Powertools. This repo, which started as Python oriented (but now supports other languages such as Java and more to follow) provides an easy to use solution for lambda logging, tracing (with cloud watch metrics), SSM utilities and now validation and advanced parsing for incoming AWS Lambda events.
🌐
AWS re:Post
repost.aws › questions › QUrmI15oZ3TxqM1Q0nYKJqFA › accessing-lambda-python-event-error
Accessing Lambda Python event - ERROR | AWS re:Post
May 14, 2024 - When you issue a test event, the Lambda function's "event" will contain the json passed in the test event. In other words, in this case, the json "{ "Username" : "Priscilla"}" is passed as is to the event, so "queryStringParameters" is None. The cause of the error is that "queryStringParameters" is not included in the test event json.