Add existing dynamodb table with stream to CDK


I currently have a dynamodb table that’s been in use for a couple of years, originally created in the console. It contains lots of valuable data. It uses a stream to periodically send a snapshot using a lambda trigger of the table to s3 for analytics. The table itself is heavily used by end users to access their data.

I want to migrate my solution into CDK. The options I want to explore:

  1. When you use the Table.fromTableArn construct, you don’t get access to the table stream arn so it’s impossible to attach a lambda trigger. Is there a way around this?
  2. Is there a way to clone the dynamoDB table contents in my CDK stack so that my copy will start off in exactly the same state as the original? Then I can add and manage the stream etc in CDK no problem.
  3. It’s worth checking my assumption that these are the only 2 options.


  1. Subscribing Lambda to an existing Dynamo Table:

We don’t need to have table created within same stack. We can’t use addEventSource on lambda but we can use addEventSourceMapping and add necessary policies to Lambda, which is what addEventSource does behind the scenes.

  1. Importing existing DynamoDb into CDK:

We re-write dynamo db with same attributes in cdk, synth to generate Cloudformation and use resource import to import an existing resources into a stack. Here is an SO answer

Leave a Reply