Amplify-cli: Notify Slack/Email when amplify push locally.

Created on 6 Jul 2020  路  9Comments  路  Source: aws-amplify/amplify-cli

I often need to test amplify backend (functions /apis) on my feature branch and was wondering is there a way I can trigger a Slack/Email notification on amplify push.

I looked at https://docs.aws.amazon.com/amplify/latest/userguide/notifications.html
But that only seems to work if I push to a specific branch (dev, prod), which doesn't seem to work well with feature branches.

pending-response platform question

Most helpful comment

I don't think the Amplify CLI provides such function out of the box, but you can write a custom plugin and handle the PostPush event, in which you can write your custom logic to send the notification.
https://docs.amplify.aws/cli/plugins/authoring

All 9 comments

@chantlong this seems to be a question / feature request related to Amplify console. Transferring the issue to Console's repo.

@chantlong have you tried using a custom amplifyPush script?

https://github.com/aws-amplify/amplify-console/blob/master/scripts/amplifyPush.sh

You could leverage that on all builds:

```backend:
phases:
build:
commands:
- '# Execute Amplify CLI with the helper script'
- amplifyPush --simple

@litwicki Thanks for the reply, although I am having trouble understanding how this script helps solve my problem.
I do not have Front End for the build because it is a React Native Mobile app, and I want to trigger this from an amplify push from my Terminal.

@chantlong maybe wire up a cloudwatch event for cloudformation, and have the event trigger a lambda that posts to slack. Also, I think @brene misinterpreted the question, and this should probably be transferred back to amplify-cli, since you aren't using amplify console...

I think @lorengordon is correct, @chantlong I misunderstood and thought you were using Amplify Console, my mistake! I'll move this back to the CLI team and let @brene and @flywheelms know we need some eyes here.

I don't think the Amplify CLI provides such function out of the box, but you can write a custom plugin and handle the PostPush event, in which you can write your custom logic to send the notification.
https://docs.amplify.aws/cli/plugins/authoring

@lorengordon @UnleashedMind I think those 2 ideas are what I'm looking for. Thanks!

I ended up making a custom plugin that notifies Slack if you do not use AWS Amplify Console.

https://www.npmjs.com/package/amplify-push-slack-notifier-plugin

That plugin seems cheaper to use that standard mechanism, can we use it on with console build ?

Was this page helpful?
0 / 5 - 0 ratings