aws_dynamodb.Table.from_table_attributes().table_stream_arn returns null when passing table_name or arn
See original GitHub issueaws_cdk.aws_dynamodb.Table class has attributes table_arn and table_stream_arn but when we are importing the already created table outside the cdk stack with static method from_table_attributes(self, id='dynamo-table', table_name='_tablename_')
it returns ITable object which has value of table_arn already set but table_stream_arn value is not set and returns None.
Use Case
I am trying to create dynamodb trigger on already created table outside the cdk stack. For this I am importing value of table with from_table_attributes(self, id='dynamo-table', table_name='_tablename_')
static method it returns ITable object which I am passing to aws-lambda-event-source.DynamoEventSource(Impotedtableobject, starting_position='aws_lambda.StartingPosition.TRIM_HORIZON')
.
DynamoEventSource class return error below error that streams needs to be created:-
_jsii.errors.JavaScriptError:
Error: DynamoDB Streams must be enabled on the table cdk-environment/notificationslkjfs
at DynamoEventSource.bind (/tmp/jsii-kernel-Un4KOI/node_modules/@aws-cdk/aws-lambda-event-sources/lib/dynamodb.js:18:19)
at _wrapSandboxCode (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7663:51)
at Kernel._wrapSandboxCode (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:8299:19)
at ret._ensureSync (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7663:25)
at Kernel._ensureSync (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:8272:20)
at Kernel.invoke (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7662:26)
at KernelHost.processRequest (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7371:28)
at KernelHost.run (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7311:14)
at Immediate.setImmediate [as _onImmediate] (/home/ec2-user/environment/cdk-environment/.env/lib/python3.6/dist-packages/jsii/_embedded/jsii/jsii-runtime.js:7314:37)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)_
While the streams are actually created on table but it is not able to refer that. Now if I propogate the table_stream_arn value in from_table_attributes static method of dynamodb.Table class it works fine but since we are dealing with different environments in different aws account passing the table_stream_arn value hardcoded in code is not a good way, it should be referred through from_table_attributes method
Proposed Solution
Other
- 👋 I may be able to implement this feature request
- ⚠️ This feature might incur a breaking change
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (4 by maintainers)
Top GitHub Comments
I think i developed a solution for our application, where we faced the exact same issue due to integration of a multiregion stack architecture, where we only create our global dynamob tables in one main stack.
For our application we created a helper method which creates or returns an existing table, also with stream configuration
In the method we check the region of our scope, if it is the main region (us-east-1) we only create the database instance
if we create the eu stack or any other regional stack we want to refer the replicated table and not create a new one. But due to the inssufficient support from cdk, we have to do an AWS SDK Call during deployment. We can use dynamoDbs listStreams operation for listing and reading all the available stream configurations for one table.
You can have a look at the doc strings how to access the sdk calls output. Obviously you need to know how many stream configurations where created in the first place. But like you see with a CustomResource it is possible to keep this approach dynamic.
Anyway in my opinion cdk should offer this possibility out of the box.
The more I think about it the more I think this would be building a 🦶🏻🔫. I’ll be closing this issue off as I don’t think this is something we should be doing (for the reasons I mentioned in the previous update).