Use aws-lambda types, it have types for most of the events.

Example handlers:

import { SQSHandler, SNSHandler, APIGatewayProxyHandler } from 'aws-lambda';

export const sqsHandler: SQSHandler = async (event, context) => {
  
}

export const snsHandler: SNSHandler = async (event, context) => {
}

export const apiV2Handler: APIGatewayProxyHandler = async (event, context) => {
  return {
    body: 'Response body',
    statusCode: 200
  }
}
Answer from nirvana124 on Stack Overflow
🌐
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. To enable type checking for the context object, you must add the @types/aws-lambda
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with typescript › define lambda function handler in typescript
Define Lambda function handler in TypeScript - AWS Lambda
The handler accepts the following arguments: event: Contains the input data passed to your function. context: Contains information about the invocation, function, and execution environment. For more information, see Using the Lambda context object to retrieve TypeScript function information.
Discussions

AWS Lambda - provide context object
What is the problem this feature would solve? Similar to AWS Lambda for NodeJS it would be good to provide similar context. We have legacy functions that rely on some of the data (such as awsReques... More on github.com
🌐 github.com
2
May 29, 2023
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
Testing Lambdas Locally - Need Guidance
I'm currently working on a project that involves AWS Lambdas, and I'm looking for some guidance on how to test them locally to speed up my iteration. I want to ensure that everything works smoothly before pushing changes to my AWS environment. ... For additional context, my tech stack is just ... More on reddit.com
🌐 r/aws
31
44
January 26, 2024
Why has Java fallen out of favor for use in lambdas?
Were they ever IN favor? Cold start times for JVM based lambdas were awful when I experimented with them a few years ago. I've read recently that improvements have been made, but honestly I like my lambdas to be extremely light weight, so interpreted languages just feel more in line with what I'm doing. More on reddit.com
🌐 r/aws
52
8
November 28, 2022
🌐
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.
🌐
10Pines
blog.10pines.com › 2019 › 07 › 23 › writing-object-oriented-typescript-code-for-aws-lambda
Writing Object-Oriented Typescript Code for AWS Lambda
July 16, 2024 - This is an object-oriented tutorial, but that doesn’t mean we’ll have to change the way this file is written. Think of it as the interface that AWS Lambda expects from our code. This is the default handler that the Serverless Framework makes for us. There are two things about it that are worth noticing: It receives an event, a context ...
🌐
GitHub
github.com › DefinitelyTyped › DefinitelyTyped › blob › master › types › aws-lambda › handler.d.ts
DefinitelyTyped/types/aws-lambda/handler.d.ts at master · DefinitelyTyped/DefinitelyTyped
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type · ) => void | Promise<TResult>; · /** * {@link Handler} context parameter. * See {@link https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html AWS documentation}. */ export interface Context { callbackWaitsForEmptyEventLoop: boolean; functionName: string; functionVersion: string; invokedFunctionArn: string; memoryLimitInMB: string; awsRequestId: string; logGroupName: string; logStreamName: string; identity?: CognitoIdentity | undefined; clientContext?: ClientContext | undefined; tenantId?: string | undefined; ·
Author   DefinitelyTyped
🌐
Amazon Web Services
docs.amazonaws.cn › 亚马逊云科技 › amazon lambda › developer guide › building lambda functions with typescript › amazon lambda context object in typescript
Amazon Lambda context object in TypeScript - Amazon 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 typescript
Building Lambda functions with TypeScript - AWS Lambda
import { Context, S3Event, APIGatewayProxyEvent } from 'aws-lambda'; export const handler = async (event: S3Event, context: Context) => { // Function code }; The import ... from 'aws-lambda' statement imports the type definitions. It does not import the aws-lambda npm package, which is an unrelated third-party tool. For more information, see aws-lambda ... when using your own custom type definitions. For an example function that defines its own type for an event object, see Example TypeScript Lambda function code.
Find elsewhere
🌐
Orchestra
getorchestra.io › guides › context-in-aws-lambda-2
Context in AWS lambda | Orchestra
September 10, 2024 - Let’s dive into a step-by-step guide to handle the context object in both TypeScript and Python Lambda functions. The following example demonstrates a Lambda function written in TypeScript that logs context information for a simple API endpoint. import { APIGatewayEvent, Context, Callback } from 'aws-lambda'; export const handler = async (event: APIGatewayEvent, context: Context, callback: Callback) => { console.log('Function Name:', context.functionName); console.log('Request ID:', context.awsRequestId); return { statusCode: 200, body: JSON.stringify({ message: 'Hello from TypeScript Lambda!'
🌐
Serverless First
serverlessfirst.com › aws-lambda-type-definitions
Add type definitions to your Lambda functions | Serverless First
March 6, 2020 - Having to look up the docs for each one can be a PITA. The @types/aws-lambda library gives you handler, event, context and response definitions for most of the major services that can trigger a Lambda function invocation.
🌐
AWS Cloud Community
docs.powertools.aws.dev › lambda › typescript › 2.11.0 › api › types › _aws_lambda_powertools_logger.types._internal_.LambdaFunctionContext.html
LambdaFunctionContext | Powertools for AWS Lambda (Typescript) API Reference
Context: Pick<Context, | "functionName" ... AWS Lambda context information. This object is a subset of the Context object from the aws-lambda package and is used only internally by the logger and passed to the log formatter....
🌐
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!") }
🌐
MAX BUILD SPEED
maxrohde.com › 2022 › 01 › 02 › typescript-types-for-aws-lambda
TypeScript Types for AWS Lambda - max build speed
August 11, 2025 - When developing a handler for a Lambda function, we need to work with three structured objects: event: Which contains information about the specific invocation of the Lambda. context: Which contains information about the Lambda function itself.
🌐
npm
npmjs.com › package › @types › aws-lambda-mock-context
@types/aws-lambda-mock-context - npm
November 5, 2019 - Stub TypeScript definitions entry for aws-lambda-mock-context, which provides its own types definitions. Latest version: 3.2.4, last published: a year ago. Start using @types/aws-lambda-mock-context in your project by running `npm i @types/aws-lambda-mock-context`. There are no other projects ...
      » npm install @types/aws-lambda-mock-context
    
Published   Oct 23, 2024
Version   3.2.4
🌐
Michaelbrewer
michaelbrewer.github.io › aws-lambda-events › lambda-context
Lambda Context - AWS Lambda Events
This object provides methods and properties that provide information about the invocation, function, and execution environment. ... During asynchronous invokes, the Lambda context field clientContext will not be populated.
🌐
Typescript Practices
omakoleg.github.io › typescript-practices › content › lambda.html
AWS Lambda | Typescript Practices
Sample of Lambda stream event handler which resolves parameters form SSM, skips any event except ‘INSERT’ validates something in payload and pushes data into another DynamoDB table · Assumed here that DynamoDBStreamEvent will be triggered for one record ... import { DynamoDBStreamEvent, DynamoDBStreamHandler } from "aws-lambda"; import { DynamoDB, SSM } from "aws-sdk"; import { initValidator } from "./validator"; // definition skipped import { eventHandlerInternal } from "./lib"; const region = "eu-west-1"; // Create cached clients const docClient = new DynamoDB.DocumentClient({ region, }); const ssm = new SSM({ region, }); // Create validator and cache it.
🌐
GitConnected
levelup.gitconnected.com › how-to-use-typescript-for-aws-lambda-in-3-steps-1996243547eb
How to Use TypeScript for AWS Lambda in 3 Steps | by Zijing Zhao | Level Up Coding
April 14, 2022 - preserveConstEnums: more like a syntax sugar, but I would like to keep it on because it could keep enum classes in the JavaScript code in the form of object, which helps understand the JavaScript code · outDir: any folder you would like to set as the compilation output ... First, create the folder src-ts, and move app.js to that folder. Join Medium for free to get updates from this writer. ... exports.lambdaHandler = async (event, context) => { const queries = JSON.stringify(event.queytStringParameters); return { statusCode: 200, body: `Queries: ${queries}` } };
🌐
AWS
docs.aws.amazon.com › powertools › typescript › stage › api › functions › _aws-lambda-powertools_logger.middleware_middy.injectLambdaContext.html
injectLambdaContext | API Reference
const logger = new Logger({ serviceName: 'serverlessAirline' }); export const handler = middy(() => { logger.appendKeys({ key1: 'value1' }); logger.info('This is an INFO log with some context'); }).use(injectLambdaContext(logger, { resetKeys: true, })); @param target - The Logger instance(s) to use for logging @param options - Options for the middleware such as clearing state or resetting Copy
🌐
GitHub
github.com › oven-sh › bun › issues › 6003
AWS Lambda - provide context object · Issue #6003 · oven-sh/bun
May 29, 2023 - What is the problem this feature would solve? Similar to AWS Lambda for NodeJS it would be good to provide similar context. We have legacy functions that rely on some of the data (such as awsRequestId etc). I found some of the variables ...
Author   vladaman
🌐
npm
npmjs.com › package › @types › aws-lambda
@types/aws-lambda - npm
1 month ago - TypeScript definitions for aws-lambda. Latest version: 8.10.161, last published: 25 days ago. Start using @types/aws-lambda in your project by running `npm i @types/aws-lambda`. There are 923 other projects in the npm registry using @types/aws-lambda.
      » npm install @types/aws-lambda