nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Aws lambda: access body payload from direct run

Open dimasxp opened this issue 2 months ago • 1 comments

Environment

node v18.18.2

Reproduction

Describe the bug

in case where s3 - event trigger -> runs lambda with nitro index.mjs

// router/index.ts
export default defineEventHandler(async (event) => {
	const body = await readBody(event);
        // body is empty here, 
});
//how to get original body payload from event trigger in event handler

Additional context

// payload from trigger:

{
  "Records": [
    {
      "eventVersion": "2.0",
      "eventSource": "aws:s3",
      "awsRegion": "us-east-1",
      "eventTime": "1970-01-01T00:00:00.000Z",
      "eventName": "ObjectCreated:Put",
      "userIdentity": {
        "principalId": "EXAMPLE"
      },
      "requestParameters": {
        "sourceIPAddress": "127.0.0.1"
      },
      "responseElements": {
        "x-amz-request-id": "EXAMPLE123456789",
        "x-amz-id-2": ""
      },
      "s3": {
        "s3SchemaVersion": "1.0",
        "configurationId": "testConfigRule",
        "bucket": {
          "name": "xxxxx",
          "ownerIdentity": {
            "principalId": "EXAMPLE"
          },
          "arn": "arn:aws:s3:::example-bucket"
        },
        "object": {
          "key": "xxxx.mp4",
          "size": 1024,
          "eTag": "xabcdef",
          "sequencer": "x4E5F678901"
        }
      }
    }
  ]
}

Logs

No response

dimasxp avatar May 06 '24 05:05 dimasxp