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
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 typescript › define lambda function handler in typescript
Define Lambda function handler in TypeScript - AWS Lambda
The following example uses APIGatewayProxyCallback, which is a specialized callback type specific to API Gateway integrations. Most AWS event sources use the generic Callback type shown in the signatures above. import { Context, APIGatewayProxyCallback, APIGatewayEvent } from 'aws-lambda'; export const lambdaHandler = (event: APIGatewayEvent, context: Context, callback: APIGatewayProxyCallback): void => { console.log(`Event: ${JSON.stringify(event, null, 2)}`); console.log(`Context: ${JSON.stringify(context, null, 2)}`); callback(null, { statusCode: 200, body: JSON.stringify({ message: 'hello world', }), }); };
Discussions

node.js - Node AWS SDK v3: Types for `event` and `context` arguments in Lambda functions? - Stack Overflow
I'm switching to the new Node AWS SDK (v3) to take advantage of its modularity and Typescript support. The first thing I needed to do was to write a Lambda function, but I can't find types to suppo... More on stackoverflow.com
🌐 stackoverflow.com
How do I declare a TypeScript AWS Lambda handler for Lambda Function URLs? - Stack Overflow
The @types/aws-lambda npm module has TypeScript declarations for various ways a Lambda function can be triggered. For example, if the Lambda function is triggered via API Gateway, you can write: import { APIGatewayProxyHandler } from "aws-lambda"; export const handler: APIGatewayProxyHandler = async ( event, context... More on stackoverflow.com
🌐 stackoverflow.com
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
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
🌐
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.
🌐
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.
🌐
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 ...
🌐
GitHub
github.com › DefinitelyTyped › DefinitelyTyped › blob › master › types › aws-lambda › handler.d.ts
DefinitelyTyped/types/aws-lambda/handler.d.ts at master · DefinitelyTyped/DefinitelyTyped
* @example <caption>Logs the contents of the event object and returns the location of the logs</caption> * import { Handler } from 'aws-lambda' * * export const handler: Handler = async (event, context) => { * console.log("EVENT: \n" + JSON.stringify(event, null, 2)) * return context.logStreamName ·
Author   DefinitelyTyped
🌐
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 ...
Author   StefH
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 - import { SNSHandler } from 'aws-lambda'; export const handler: SNSHandler = async (event) => { const message = JSON.stringify(event.Records[0].Sns.Message); console.log('received message', message); }; No longer will you have to remember or google for the deep selector path to get at the body of your SNS or SQS message as you can easily navigate the event object inside your IDE:
🌐
MAX BUILD SPEED
maxrohde.com › 2022 › 01 › 02 › typescript-types-for-aws-lambda
TypeScript Types for AWS Lambda - max build speed
August 11, 2025 - I have recently added a new template to the Goldstack template library, Serverless API, that provides an easy starting place for developing a REST API using AWS Lambda. It took me quite a while to figure out the correct types to use for the handlers, so I thought I quickly document that here in this blog post. 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.
🌐
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!") }
🌐
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
Powertools for AWS Lambda (Typescript) API Reference · @aws-lambda-powertools/logger · types · <internal> LambdaFunctionContext · Lambda · Function · Context: Pick<Context, | "functionName" | "memoryLimitInMB" | "functionVersion" | "invokedFunctionArn" | "awsRequestId"> & { coldStart: boolean; } Keys available to the logger when customers have captured 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.
🌐
AWS Cloud Community
docs.powertools.aws.dev › lambda › typescript › 1.4.1 › core › logger
Logger - AWS Lambda Powertools for TypeScript
October 25, 2022 - If you don't want to declare your own dummy Lambda Context, you can use ContextExamples.helloworldContext from @aws-lambda-powertools/commons.
🌐
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 - 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}` } };