question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Export the DynamoDB table Stream Arn as an stack's output

See original GitHub issue

Is your feature request related to a problem? Please describe. Currently, there is no easy way to add a stream event, for example, to trigger a Lambda function, because the Stream Arn is not available in any stack. I’ve created a function using amplify function add, now, I want to edit the template to add an AWS::Lambda::EventSourceMapping but it is not possible except if I hardcoded the Stream Arn in the template, but, It will fail if I create a new environment.

Describe the solution you’d like It will be awesome to have the DynamoDB table Stream Arn as an output, and exported using the process described in aws-amplify/amplify-category-api#440 and we will be able to add an AWS::Lambda::EventSourceMapping config to a function’s template. Something like

"EventSourceMapping": {
	"Type": "AWS::Lambda::EventSourceMapping",
	"Properties": {
		"EventSourceArn": {
			"Fn::ImportValue": {
				"Fn::Join": [":",
                    [
                        { "Fn::Sub": "${ParentStackName}" },
                        "GetAtt",
                        "MyDynamoDBTable",
                        "StreamArn"
                    ]
                ]
			}
		},
		"FunctionName": {
			"Fn::GetAtt": ["LambdaFunction", "Arn"]
		},
		"StartingPosition": "TRIM_HORIZON"
	}
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
matwerber1commented, Dec 15, 2019

Hi. Thanks for feedback above. If it helps anyone, I summarized the recommendations above in this project:

https://github.com/matwerber1/aws-amplify-subscribe-lambda-to-dynamodb-api-table-stream/

3reactions
kstro21commented, Dec 3, 2019

Hi, @psporysz, I think it is not a workaround, it is the way to do it. Note you can write it like

"Fn::ImportValue": {
	"Fn::Sub":  "${apiresourcenameGraphQLAPIIdOutput}:GetAtt:MyModelTable:StreamArn"
}

It is easy to read

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change data capture for DynamoDB Streams
On the DynamoDB console dashboard, choose Tables and select an existing table. · On the Exports and streams tab, in the DynamoDB stream...
Read more >
How to reference the latest Stream of a DynamoDB table in a ...
Is there a way to reference the latest stream via a variable similar to arn:aws:dynamodb:${AWS::Region}::${AWS::AccountId}:table/eventbus-test/ ...
Read more >
Using dynamo stream arn output as value in another stack ...
StreamArn #output the fufillments table stream arn Export: Name: StreamArn. In another stack , I am trying to import the dynamo stream arn...
Read more >
Migrate DynamoDB tables with zero downtime and no data loss
The export functionality of DynamoDB requires you to enable point-in-time recovery. You also need to enable a DynamoDB stream to stream any ...
Read more >
AWS Lambda Events - Kinesis & DynamoDB Streams
stream : arn:aws:dynamodb:region:XXXXXX:table/foo/stream/1970-01-01T00:00:00.000 ... an ARN that was exported by a different service or CloudFormation stack.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found