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.

Amplify can detect and integrate with Appsync-backing Dynamo table streams when adding Function

See original GitHub issue

Is your feature request related to a problem? Please describe. When creating a lambda with amplify function add, Amplify should provide the option to integrate with a Dynamo Stream from tables associated with Appsync apis. Currently, Amplify does not appear to detect these tables.

Describe the solution you’d like The integration described above.

Describe alternatives you’ve considered Used amplify function add to create a Hello World lambda, then (1) manually updated lambda permissions in generated CloudFormation and (2) added connection to Dynamo Stream in the Dynamo console.

Additional context Using version 1.1.30, here is CLI experience where Amplify did not find the Appsync-integrated DynamoDB tables:

> amplify function add
Using service: Lambda, provided by: awscloudformation
? Provide a friendly name for your resource to be used as a label for this category in the project: myNewLambdaFunction
? Provide the AWS Lambda function name: myNewLambdaFunction
? Choose the function template that you want to use: CRUD function for Amazon DynamoDB table (Integration with Amazon API Gateway and Amazon Dy
namoDB)
? Choose a DynamoDB data source option Use DynamoDB table configured in the current Amplify project
There are no DynamoDB resources configured in your project currently
? Choose a DynamoDB data source option
❯ Use DynamoDB table configured in the current Amplify project
  Create a new DynamoDB table

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
RossWilliamscommented, Jul 13, 2019

You can modify the function’s cloudformation template to add the event source mapping since every table’s stream arn is exported. An example:

{
    $MY_RESOURCE_NAME: {
            "Type": "AWS::Lambda::EventSourceMapping",
            "Properties": {
                "BatchSize": 1,
                "Enabled": true,
                "EventSourceArn": {
                    "Fn::ImportValue": {
                        "Fn::Join": [
                            ":",
                            [
                                {
                                    "Ref": "AppSyncApiId"
                                },
                                "GetAtt",
                                $MY_DYNAMO_TABLE_NAME,
                                "StreamArn"
                            ]
                        ]
                    }
                },
                "FunctionName": {
                    "Fn::GetAtt": [
                        $MY_LAMBDA_FUNCTION_RESOURCE_NAME,
                        "Arn"
                    ]
                },
                "StartingPosition": "LATEST"
            },
            "DependsOn": [
                 $MY_LAMBDA_FUNCTION_RESOURCE_NAME,
            ]
        }
}

The import value is a direct copy from the Outputs -> Export property in your table’s autogenerated cloudformation stack.
You probably also need to update your function properties in backend-config.json to add a dependsOn for the AppSyncApiId property if it isn’t already.

0reactions
github-actions[bot]commented, May 26, 2021

This issue has been automatically locked since there hasn’t been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Amplify can detect and integrate with Appsync-backing ...
When creating a lambda with amplify function add , Amplify should provide the option to integrate with a Dynamo Stream from tables ......
Read more >
Enhancing Amazon DynamoDB single-table design with AWS ...
Developers utilize AppSync to connect applications to data sources such as Amazon DynamoDB tables.
Read more >
AWS Amplify with Amazon DynamoDB Single Table and ...
Your browser can 't play this video. ... AWS Amplify with Amazon DynamoDB Single Table and Direct AWS Lambda Resolvers with Rick Houlihan....
Read more >
GraphQL APIs with AppSync, Amplify and Angular - YouTube
AWS AppSync automatically updates the data in web and mobile applications in real time, and updates data for offline users as soon as...
Read more >
Timeline feature: @function
In $ amplify add function , several templates are available. For example, if you select Lambda Trigger , you can set up DynamoDB...
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