1

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!

1 Answer 1

3

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

export interface S3Event {
    Records: S3EventRecord[];
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @fedonev! I'm new to Typescript and didn't realise it would be in a separate package!
How do you know this? How do I look up the one for my use case (state-machine listening to API-Gateway)? How would I look up other use-cases?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.