Amplify-cli: Ability to add Dynamo -> Lambda stream to send emails on model create/update

Created on 3 Dec 2018  路  8Comments  路  Source: aws-amplify/amplify-cli

Is your feature request related to a problem? Please describe.
Not sure what the amplify way to add a stream from a gql transformer-created table is so I can trigger a lambda when a new model entry is created or updated. My use case is basically I need to send an email whenever a comment @model is added to a post @model.

Describe the solution you'd like
Amplify already creates the dynamodb table. It also supports lambda functions, so I need ability to setup a stream on the dynamodb table to call that lambda function.

Describe alternatives you've considered
Currently I just setup the stream manually through the AWS console. To make this more robust, I guess I can set it up through an aws cli script after amplify push.

Additional context
This is also mentioned in https://github.com/aws-amplify/amplify-cli/issues/80. We need clarity/support in how to best add functionality that is not immediately supported by the amplify tools currently.

feature-request graphql-transformer

Most helpful comment

Hey @hisham, thanks for this issue. This is a great use case. There is currently no way to do this in the CloudFormation template but you can go to the AWS console and manually add a stream although I'm not positive what will happen on a subsequent stack update as it varies across services. We are doing a lot of feature planning and I will make sure that this gets added to the list for prioritization.

In terms of more general guidance there are a few things in process of happening that clear up most use cases.

  1. The transform output is getting broken up into nested stacks which will provide smaller documents that can be managed independently.

  2. We will be building support for custom resolvers/data sources that will allow you to do custom operations against data sources we create for you as well as against existing resources in your account. We are also thinking about how we can allow you to take what we provide and then augment it slightly with custom logic for authorization or other use cases without having it overwritten every time you build a schema. The new pipeline resolvers features open up opportunities here.

Your feedback is extremely helpful when making cases for prioritization so keep them coming and I will update as soon as I have more information.

All 8 comments

Hey @hisham, thanks for this issue. This is a great use case. There is currently no way to do this in the CloudFormation template but you can go to the AWS console and manually add a stream although I'm not positive what will happen on a subsequent stack update as it varies across services. We are doing a lot of feature planning and I will make sure that this gets added to the list for prioritization.

In terms of more general guidance there are a few things in process of happening that clear up most use cases.

  1. The transform output is getting broken up into nested stacks which will provide smaller documents that can be managed independently.

  2. We will be building support for custom resolvers/data sources that will allow you to do custom operations against data sources we create for you as well as against existing resources in your account. We are also thinking about how we can allow you to take what we provide and then augment it slightly with custom logic for authorization or other use cases without having it overwritten every time you build a schema. The new pipeline resolvers features open up opportunities here.

Your feedback is extremely helpful when making cases for prioritization so keep them coming and I will update as soon as I have more information.

That's awesome, thanks @mikeparisstuff. My current dynamo db tables have to be in a region not supported by amplify cli, so I actually created them by hand (following the schema of the tables the graphql-transformer created), and then also added the stream through the AWS console. So I'm not affected by subsequent updates.

Because of this setup, I'm especially interested in support for custom data sources (dynamodb tables in my case) created outside of the gql-transformer, but following the format it wants tables in, in a region that is not officially supported by amplify cli (ca-central-1).

@mikeparisstuff

Our team would love this feature too! @RayStroud has implemented a workaround for the time being but having this as a feature would be much appreciated.

@mikeparisstuff This feature would open up some great options for us as well!

Hey guys,
We've added functionality for custom resolvers and custom appsync cfn stacks. Please use npm install -g @aws-amplify/cli to install the latest version of the CLI. For documentation regarding it, please refer to https://aws-amplify.github.io/docs/cli/graphql#overwrite-a-resolver-generated-by-the-graphql-transform

Here's the launch announcement for the same - https://aws.amazon.com/blogs/mobile/amplify-adds-support-for-multiple-environments-custom-resolvers-larger-data-models-and-iam-roles-including-mfa/

Please feel free to re-open the issue if you think this launch didn't solve your issues.

I don't have permission to re-open, but this use case still doesn't seem to be supported even with the new nested stacks stuff. See https://github.com/aws-amplify/amplify-cli/issues/987

There is a PR for exporting the StreamArn open, see #1140

@garrett-gottlieb We recently added a feature to attach a trigger to the DDB tables generated by the GraphQL transformer. You can checkout the documentation out here - https://aws-amplify.github.io/docs/cli-toolchain/quickstart#as-a-part-of-the-graphql-api-types-with-model-annotation

Also, we merged #1140 to export the streamARN

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jexh picture jexh  路  3Comments

zjullion picture zjullion  路  3Comments

nicksmithr picture nicksmithr  路  3Comments

amlcodes picture amlcodes  路  3Comments

onlybakam picture onlybakam  路  3Comments