Trigger Lambda from already existing DynamoDB

dynamodb
aws
lambda

#1

Hi,
I have already created DynamoDB with lost of records inside.
I can create a stream manually, but don’t want to copy stream ARN inside serverless yml.
I’ve tried to subscribe Lambda to wildcard ARN (arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/<tableName>/stream/*) but got an error:
Stream not found.
Is there any way to subscribe Lambda to particular existing table stream without hardcoding ARN.(it’s only one stream for one table, so I suppose it should work)?


#2

You will pretty much always have to hard code to an existing ARN. The only way to get it more “automated” is to backup the data in your table, delete it, define it in serverless.yml with stream option turned on and then link the function in that way and restore your data.

A tool I’ve found useful for doing these kinds of migrations is: https://github.com/bchew/dynamodump


#3

Yeah, I was thinking about it.
Thanks.