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
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.
Discussions

node.js - Node AWS SDK v3: Types for `event` and `context` arguments in Lambda functions? - Stack Overflow
Sign up to request clarification or add additional context in comments. ... Does this answer imply that the new v3 aws-sdk does not actually provide these types and that the correct solution is to rely on this independent library? 2022-05-16T21:58:58.797Z+00:00 ... @types/aws-lambda is pretty much active so I guess this is still the way to go in 2022. 2022-06-27T06:49:49.23Z+00:00 ... Yes, event the official docs mention to install this library: docs.aws.amazon.com/lambda/latest/dg/typescript... More on stackoverflow.com
🌐 stackoverflow.com
amazon web services - How do you elegantly import AWS - Lambda in Typescript? - Stack Overflow
I am building a typescript project on aws lambda. As aws-sdk comes with type definitions already I would expect it also to hold a definition for aws lambda. But I seem to have to install @types/aws- More on stackoverflow.com
🌐 stackoverflow.com
September 12, 2018
Which type do I return with AWS lambda responses in typescript to suite AWS APIGateway Method Response? - Stack Overflow
The @types/aws-lambda package provides types for using TypeScript inside of an AWS Lambda function. For AWS Lambda functions invoked using API Gateway's Lambda Proxy integration type take the following steps: ... import { APIGatewayProxyEvent, Context, APIGatewayProxyResult } from "aws-lambda" ... More on stackoverflow.com
🌐 stackoverflow.com
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
🌐
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.
🌐
Typescript Practices
omakoleg.github.io › typescript-practices › content › lambda.html
AWS Lambda | Typescript Practices
import { DynamoDBStreamHandler, DynamoDBStreamEvent } from "aws-lambda"; export const handleStreamEvent: DynamoDBStreamHandler = async ( event: DynamoDBStreamEvent ): Promise<void> => { await Promise.resolve(1); console.log("Process db event"); }; ... export type APIGatewayProxyHandler = Handler< APIGatewayProxyEvent, APIGatewayProxyResult >; export type DynamoDBStreamHandler = Handler<DynamoDBStreamEvent, void>; // Handler Generic export type Handler<TEvent = any, TResult = any> = ( event: TEvent, context: Context, callback: Callback<TResult> ) => void | Promise<TResult>; // For callback use case export type Callback<TResult = any> = ( error?: Error | string | null, result?: TResult ) => void;
🌐
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 and a callback.
🌐
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
    
🌐
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.
Find elsewhere
🌐
GitHub
github.com › StefH › serverless-aws-lambda-typescript-examples › blob › master › serverless-aws-lambda-typescript-webpack › src › handler.ts
serverless-aws-lambda-typescript-examples/serverless-aws-lambda-typescript-webpack/src/handler.ts at master · StefH/serverless-aws-lambda-typescript-examples
import { Context, Callback } from 'aws-lambda'; import { HttpRestHelper } from './httpRestHelper'; import { Post } from './post'; · exports.handleIt = function(event: any, context: Context, callback: Callback) { let helper: HttpRestHelper = new HttpRestHelper(); ·
Author   StefH
🌐
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.
🌐
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.
🌐
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
🌐
DEV Community
dev.to › elhamnajeebullah › serverless-and-aws-lambda-with-typescript-example-for-beginners-26he
Serverless and AWS Lambda with TypeScript example for beginners - DEV Community
January 9, 2023 - In this example, the function logs the name of the function and the AWS request ID from the context argument, and logs the message of each SNS record from the event argument. Is AWS cost-effective? AWS Lambda automatically scales your functions, so you don't have to worry about capacity planning or infrastructure management.
🌐
Cloudmailin
cloudmailin.com › blog › using-typescript-with-aws-lambda
Using TypeScript with AWS Lambda and SAM - Cloudmailin
August 27, 2021 - The package is a set of AWS Lambda Types that are just a bonus to help work with Lambda. npm install --save-dev typescript @types/node @types/aws-lambda
🌐
AWS Cloud Community
docs.powertools.aws.dev › lambda › typescript › 1.4.1 › core › logger
Logger - AWS Lambda Powertools for TypeScript
October 25, 2022 - This is a Jest sample that provides the minimum information necessary for Logger to inject context data: ... If you don't want to declare your own dummy Lambda Context, you can use ContextExamples.helloworldContext from @aws-lambda-powertools/commons.
🌐
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 - Unit Test and Integration Test for AWS Lambda/NodeJS in TypeScript · When we are using NodeJS as the runtime for AWS Lambdas, JavaScript is the default language. However, due to the lack of typing checking in JavaScript, from time to time, buggy code is deployed to Lambda inadvertently. Such as a small typo like this: exports.lambdaHandler = async (event, context) => { const queries = event.queytStringParameters; // ...
🌐
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