SLS Offline DynamoDB Streams: Several issues referencing DynamoDB table streams
I am using SLS Offline DynamoDB Streams (SODS) to develop and test a Serverless + NodeJS application that uses DynamoDB streams to trigger additional Lambda functions. I have struggled with specifying the ARN of the DynamoDB stream correctly and during that course found several issues around this.
Issue 1: At the very bottom of the SODS NPM page an example describes a variant using a tableName key. This does work and from all I can tell is also not supported by the getTableName function.
Issue 2: Line 186 of index.js is missing an additional null check for arn:
if (tableEvent.arn && tableEvent.arn['Fn::GetAtt']) {
Issue 3: I did not test this but from all I can tell, there are two more ways to specify a DynamoDB table stream in Serverless that are not supported by SODS:
- stream:
type: dynamodb
arn:
Fn::ImportValue: MyExportedDynamoDbStreamArnId
- stream:
type: dynamodb
arn:
Ref: MyDynamoDbTableStreamArn
It could be that those two ways are not feasible for local deployments (again, I didn't test them) but I figured I'll point it out anyway.
Time permitting I'll put together a pull request for no. 2. Not sure what you would want to do about no. 1 and 3.
Got the same issue and solved by adding streamName property under stream event. But I'm not sure it is a good or bad approach.
Or, it can be solved by passing arn string correctly.
Or, use CloudFormation Fn::GetAtt: (Target table should be contained to CloudFormation Resource)
Hello and sorry for late answer :/
As correctly point out @cmygray Fn::GetAtt would do the job. CloudformationLike resolving is very limited and so farr there is no support for local Fn::ImportValue and Ref
getTableName does not exist anymore, tableName might have been lost at some point. Will need to check
getTableNamedoes not exist anymore,tableNamemight have been lost at some point. Will need to check
after checking repo when message was introduced [9805f89], that might be a problem of wording:
To me arn could be deduce from tableName if your add the key tableName in your function's configuration. Useful if your use dynalite and regularly recreate a new DynamoDBStreams. implicitely talks about the tableName in the events in the function, not the function configuration itself