Skip to content

Feature request: Enable TumblingWindow support for KinesisDataStreamRecord and DynamoDB #3915

Closed
@leandrodamascena

Description

@leandrodamascena

Use case

Original issue: aws-powertools/powertools-lambda-python#6627

To implement stateful Kinesis Data Streams, customers can enable tumbling window in their ESM configuration for Kinesis and DynamoDB stream. When they do this, the payload has some extra keys such as window, state, shardId, isFinalInvokeForWindow and isWindowTerminatedEarly.

{
    "Records": [
        {
            "kinesis": {
                "kinesisSchemaVersion": "1.0",
                "partitionKey": "1",
                "sequenceNumber": "49590338271490256608559692538361571095921575989136588898",
                "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==",
                "approximateArrivalTimestamp": 1607497475.000
            },
            "eventSource": "aws:kinesis",
            "eventVersion": "1.0",
            "eventID": "shardId-000000000006:49590338271490256608559692538361571095921575989136588898",
            "eventName": "aws:kinesis:record",
            "invokeIdentityArn": "arn:aws:iam::123456789012:role/lambda-kinesis-role",
            "awsRegion": "us-east-1",
            "eventSourceARN": "arn:aws:kinesis:us-east-1:123456789012:stream/lambda-stream"
        }
    ],
    "window": {
        "start": "2020-12-09T07:04:00Z",
        "end": "2020-12-09T07:06:00Z"
    },
    "state": {
        "1": 282,
        "2": 715
    },
    "shardId": "shardId-000000000006",
    "eventSourceARN": "arn:aws:kinesis:us-east-1:123456789012:stream/lambda-stream",
    "isFinalInvokeForWindow": false,
    "isWindowTerminatedEarly": false
}

While adding these fields to our zod schemas is enough to parse events, we still need to discuss - in a separate issue maybe - how to modify our BatchProcessing utility to support these scenarios, as we need to return an additional state field when using PartialFailure.

Kinesis documentation: https://docs.aws.amazon.com/lambda/latest/dg/services-kinesis-windows.html
DynamoDB documentation: https://docs.aws.amazon.com/lambda/latest/dg/services-ddb-windows.html

Solution/User Experience

Add new fields.

Alternative solutions

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

completedThis item is complete and has been merged/shippedfeature-requestThis item refers to a feature request for an existing or new utilitygood-first-issueSomething that is suitable for those who want to start contributingparserThis item relates to the Parser Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions