Eventbridge Pipe - How to fetch extract object from array in output transformation- Input Source SQS & Target to Lambda (Cloudwatch event object input but receiving List<CloudwatchEvent<T>>)

0

I am trying to extract one SQS message from transform it into Cloudwatch event. The problem I am facing lambda side I am always getting list of items where as I am expecting object

Here is input payload for SQS event - batch size configured as 1 for SQS

{
  "messageId": "059f36b4-87a3-44ab-83d2-661975830a7d",
  "receiptHandle": "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...",
  "body": "{\"version\":\"0\",\"id\":\"17793124-05d4-b198-2fde-7ededc63b103\",\"detail-type\":\"ObjectCreated\",\"source\":\"aws.s3\",\"account\":\"123456789012\",\"time\":\"2021-11-12T00:00:00Z\",\"region\":\"ca-central-1\",\"resources\":[\"arn:aws:s3:::example-bucket\"],\"detail\":{\"version\":\"0\",\"bucket\":{\"name\":\"example-bucket\"},\"object\":{\"key\":\"example-key\",\"size\":5,\"etag\":\"b1946ac92492d2347c6235b4d2611184\",\"version-id\":\"IYV3p45BT0ac8hjHg1houSdS1a.Mro8e\",\"sequencer\":\"00617F08299329D189\"},\"request-id\":\"N4N7GDK58NMKJ12R\",\"requester\":\"123456789012\",\"source-ip-address\":\"1.2.3.4\",\"reason\":\"PutObject\"}}",
  "attributes": {
    "ApproximateReceiveCount": "1",
    "SentTimestamp": "1545082649183",
    "SenderId": "AIDAIENQZJOLO23YVJ4VO",
    "ApproximateFirstReceiveTimestamp": "1545082649185"
  },
  "messageAttributes": {},
  "md5OfBody": "e4e68fb7bd0e697a0ae8f1bb342846b3",
  "eventSource": "aws:sqs",
  "eventSourceARN": "arn:aws:sqs:us-east-2:123456789012:my-queue",
  "awsRegion": "us-east-2"
}

Lambda side response logs

[
{
    "Version": null,
    "Account": null,
    "Region": null,
    "Detail": "sushant",
    "detail-type": "Object Created",
    "Source": null,
    "Time": "0001-01-01T00:00:00",
    "Id": "17793124-05d4-b198-2fde-7ededc63b103",
    "Resources": null
}
]

Output transformation Output transformation

I have tried $.0 but I am always getting array. Here lambda is just for example How we can extract single object from array in eventbridge pipe

No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions