Sorry, wasn't sure how to make the question itself brief enough...

I can post data from Postman to my local Lambda function. The issue is that when running locally, I have use this line of code...

event = JSON.parse(event.body);

...so that I can do this...

event.Records.forEach(function(record)
{
   // do some stuff
}

But when I deploy the function to AWS, parsing event.body is unnecessary. In fact it throws an error.

I was assuming that there is something different about the JSON (or other aspects of the request) that I'm posting from Postman to my local app when compared to what Kinesis actually sends. But the JSON blob I'm posting locally was logged directly from Lambda on AWS to Cloudwatch.

I'm missing something.

TBH, this only matters because having to comment out that line as a step in the deployment process is annoying and error-prone.

Here's the JSON (names have been changed to protect the innocent):

{
    "Records": [
        {
            "kinesis": {
                "kinesisSchemaVersion": "1.0",
                "partitionKey": "Thursday, 11 April 2019",
                "sequenceNumber": "49594660145138471912435706107712688932829223550684495922",
                "data": "some base 64 stuff",
                "approximateArrivalTimestamp": 1555045874.83
            },
            "eventSource": "aws:kinesis",
            "eventVersion": "1.0",
            "eventID": "shardId-000000000003:1234123412341234123412341234123412341234123412341234",
            "eventName": "aws:kinesis:record",
            "invokeIdentityArn": "arn:aws:iam::1234123412341234:role/lambda-kinesis-role",
            "awsRegion": "us-west-2",
            "eventSourceARN": "arn:aws:kinesis:us-west-2:1234123412341234:stream/front-end-requests"
        }
    ]
}

0 Answers