AWS CDK Typescript Lambda 处理程序事件类型

AWS CDK Typescript Lambda Handler Event Type

我正在使用 CDK 创建我的无服务器应用程序,我目前有一个由 S3 put 事件触发的 lambda,如下所示:

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: [ ... ]
        }));

通过查看文档,我似乎找不到 type 我应该在我的打字稿处理程序中使用什么:

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

    //some stuff

    return someThing
}

提前致谢!

您的 Lambda 收到的事件将是 S3Event from the @types/aws-lambda 包类型:

export interface S3Event {
    Records: S3EventRecord[];
}