Lambda retries kinesis event properly processed

25 Views Asked by At

I have a lambda processing kinesis events.

Kinesis has 3 retries in case of failure.

The lambda process the events properly but it is called 4 times.

I have looking for what can be the cause and I have found this:

[cloudshell-user@ip-10-130-89-49 ~]$  aws lambda list-event-source-mappings --event-source-arn arn:aws:kinesis:us-east-1:xxxx:stream/xxxx

{
"EventSourceMappings": [
    {
        "UUID": "xxx-xx-xx-xx-xxxx",
        "StartingPosition": "LATEST",
        "BatchSize": 100,
        "MaximumBatchingWindowInSeconds": 3,
        "ParallelizationFactor": 1,
        "EventSourceArn": "arn:aws:kinesis:us-east-1:xxxxxx:stream/xxxxx-ingestion-kinesis",
        "FunctionArn": "arn:aws:lambda:us-east-1:xxxxx:function:yyyyyy:PROD",
        "LastModified": "2024-03-26T12:46:00+00:00",
        "LastProcessingResult": "PROBLEM: Function response syntax is invalid. Please check function implementation.",
        "State": "Enabled",
        "StateTransitionReason": "User action",
        "DestinationConfig": {
            "OnFailure": {}
        },
        "MaximumRecordAgeInSeconds": 3600,
        "BisectBatchOnFunctionError": true,
        "MaximumRetryAttempts": 3,
        "TumblingWindowInSeconds": 60,
        "FunctionResponseTypes": []
    }
]

}

I have been searching for

"PROBLEM: Function response syntax is invalid. Please check function implementation."

but I don´t find anything about it.

Any idea?

2

There are 2 best solutions below

0
emilio On

Your lambda code produces an error or at least the response is wrong and because of your setting

   "MaximumRetryAttempts": 3,

it calls the function 3 times after the initial call, because it interprets it as error.

You might read here for detailed explanation.

0
David Marciel On

In my case the problem was in the template.yml

I tried to deploy a template.yml using the Events field of lambda in order to connect with kinesis, but it didn´t work. Once I moved it to its own EventSourceMapping entity it fixed the issue.