aws / aws/aws-cdk

lambda.add_event_source: Unable to add trigger to existing Stream enabled DynamoDB table

Open
#24,731 9 comments 12 reactions 0 assignees View on GitHub
@aws-cdk/aws-lambda bug effort/medium p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

If we add an existing DynamoDB stream-enabled table using "dynamodb.Table.from_table_arn".

The lambda add_event_source using "DynamoEventSource" throws a runtime error "_RuntimeError: Error: DynamoDB Streams must be enabled on the table_".

### Expected Behavior

Should be able to add the event trigger for the DynamoDB table.

### Current Behavior

Not able to add the event trigger.

### Reproduction Steps

Below CDK resources should be able to deploy:

# Stream enabled DynamoDB table
existing_table = _dynamodb.Table.from_table_arn(
self, "my_table", **TABLE_ARN**
)

# Simple lambda
trigger_lambda = _lambda.Function(
self,
id="trigger",
runtime=_lambda.Runtime.PYTHON_3_9,
handler="lambda_trigger.lambda_handler",
code=_lambda.Code.from_asset("lambda_functions/trigger")
)

# Lambda Trigger

trigger_lambda.add_event_source(
DynamoEventSource(
existing_table,
starting_position=_lambda.StartingPosition.LATEST,
batch_size=1,
retry_attempts=3,
filters=[
_lambda.FilterCriteria.filter(
{"new_notification": _lambda.FilterRule.is_equal("INSERT")}
)
],
)
)

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.69.0 (build 60a5b2a

### Framework Version

2.69.0

### Node.js Version

16.17.0

### OS

Mac OS 13.2.1

### Language

Python

### Language Version

3.10.0

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start at the DynamoEventSource and Table.from_table_arn entry points, then inspect existing-table stream handling and related tests. Reproduce the deployment with the supplied Python configuration; done means an imported stream-enabled DynamoDB table can be attached without the “Streams must be enabled” runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, typescript
Domain
cloud, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.