aws / aws/aws-cdk

lambda-event-source: DynamoEventSource expects an ITable, does not support CfnGlobalTable

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

Description

### Describe the bug

Looking to set up a `DynamoEventSource` from a Dynamo DB Global Table. We need to use `CfnGlobalTable` as this support the latest version and has better support for replicas.
``[](url)

### Expected Behavior

We expected either the `DynamoEventSource` to accept the `CfnGlobalTable` or the `CfnGlobalTable` expose `ITable` to make the hook up seemless.

### Current Behavior

We have no known way to hook up the global table.

### Reproduction Steps

define a `CfnGlobalTable`, and a Function `and` attempt to `AddEventSource` to the Lambda.

``` C#
var table = new CfnGlobalTable(this, "tableName", new CfnGlobalTableProps
{
...
StreamSpecification = new CfnGlobalTable.StreamSpecificationProperty
{
StreamViewType = StreamViewType.NEW_AND_OLD_IMAGES
},
....
});

var fn = new Function(this, "name", new FunctionProps
{
...
});

fn.AddEventSource(new DynamoEventSource(table, new DynamoEventSourceProps
{
Enabled = true,
}));
```

### Possible Solution

Fix up s the integration is seamless...

### Additional Information/Context

`CfnEventSourceMapping` is a possible alternative, but is not fully integrated it seems:

```C#
var mapping = new CfnEventSourceMapping(this, $"{props.Environment}-TenantStreamEnricherMapping",
new CfnEventSourceMappingProps
{
FunctionName = fn.FunctionName,
EventSourceArn = table.AttrStreamArn,
StartingPosition = "LATEST",
});

mapping.addPropertyOverride('FilterCriteria', {
Filters: [
{
Pattern: { // your filterpattern here}
],
});
```

### CDK CLI Version

2.61.1

### Framework Version

Dotnet 7

### Node.js Version

18.0.0

### OS

MacOS

### Language

.NET

### Language Version

DotNet 7

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by inspecting the DynamoEventSource API and the CfnGlobalTable integration points described in the issue, then review related event-source mapping tests if present. Done means a CfnGlobalTable can be connected to DynamoEventSource or the required table interface is exposed, with coverage for the reported C# usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, csharp
Domain
backend, cloud, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.