I have step function with lambda_1 as starting point.
This step function is going to be triggered when object is added to S3. I am getting the event and trying to fetch objectKey and bucket from that .
This is my lambda handler written in TypeScript:
export const handler: Handler<EventBridgeEvent<'Object Created', S3EventDetail>> = async (event) => {
//....
const { bucket, object } = event.detail;
}
S3EventDetail is a type I created to match with eventBridge structure
interface S3EventDetail {
detail: {
version: string;
bucket: {
name: string;
};
object: {
key: string;
size: number;
etag: string;
'version-id': string;
sequencer: string;
};
'request-id': string;
requester: string;
'source-ip-address': string;
reason: string;
};
version: string;
id: string;
'detail-type': string;
source: string;
account: string;
time: string;
region: string;
resources: string[];
}
I get bucket or object using this line
const { bucket, object } = event.detail;
when I run the code with a sample event it works, but when I build I get the error
Property 'bucket' does not exist on type 'S3EventDetail'.