Skip to content

feat: Add DynamoDB Streams CDC pattern with Lambda durable functions … - #3188

Open
awsTest1992 wants to merge 1 commit into
aws-samples:mainfrom
awsTest1992:lambda-durable-ddb-streams-python-sam
Open

feat: Add DynamoDB Streams CDC pattern with Lambda durable functions …#3188
awsTest1992 wants to merge 1 commit into
aws-samples:mainfrom
awsTest1992:lambda-durable-ddb-streams-python-sam

Conversation

@awsTest1992

Copy link
Copy Markdown
Contributor

…(Python)

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ellisms ellisms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the submission, @awsTest1992 . Requesting a few changes.

- Effect: Allow
Action:
- lambda:InvokeFunction
Resource: !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-processor*"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend changing resource statement to:
Resource: - !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-processor" - !Sub "arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-processor:*"

import uuid
import logging
from datetime import datetime, timezone
from decimal import Decimal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an unused import. Remove if not needed.

missing = [f for f in required_fields if f not in new_image]

if missing:
raise UnrecoverableInvocationError(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to import this

KeyType: HASH

# Durable Function — processes stream records with checkpoints
StreamProcessorFunction:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend explicitly creating the associated CloudWatch logs group so that there is a retention policy, and the group is removed during stack destroy.

from aws_durable_execution_sdk_python.context import DurableContext, StepContext, durable_step
from aws_durable_execution_sdk_python.execution import durable_execution

logger = logging.getLogger()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend using the context.logger from the durable function sdk so that the logger is replay-aware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants