Home > Back-end >  AWS CDK Typescript Lambda Handler Event Type
AWS CDK Typescript Lambda Handler Event Type

Time:04-06

I'm using CDK to create my serverless app, and I current have a lambda trigger by an S3 put event, like so:

const function = new NodejsFunction(this, `id-here`, {
            entry: path.join(__dirname, '/../src/lambda/index.ts'),
            ...more props
        });

function.addEventSource(new eventsources.S3EventSource(this.myBucket, {
            events: [ s3.EventType.OBJECT_CREATED ],
            filters: [ ... ]
        }));

I can't seem to find, by looking through the docs, what type I should be using in my typescript handler:

export const handler  = (event: <What goes here?>) => {

    //some stuff

    return someThing
}

Thanks in advance!

CodePudding user response:

The events your Lambda receives will be of the type S3Event from the @types/aws-lambda package:

export interface S3Event {
    Records: S3EventRecord[];
}
  • Related