aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
460 stars 116 forks source link

Automatically Enable notifications for all connected branches #13

Closed kmfreas closed 4 years ago

kmfreas commented 5 years ago

Which Category is your question related to?

Amplify Console

What AWS Services are you utilizing?

Auth/Storage/Console

I'm using amplify console as our CI/CD system but I'm having a hard time finding features in it that are available in other alternatives like CircleCI. My problem right now is trying to create a build complete/failed webhook for slack. It works ok for complete if I put it in frontend postBuild. But obviously if a step fails beforehand it never gets to that point.

So my question is how can I catch a build error and then run a bash command afterwards?

Thanks for looking into this!

swaminator commented 5 years ago

Have you checked out the Email notification feature? It's actually an SNS topic which you can subscribe to. You can use that SNS topic to kickoff a Slack notification: https://medium.com/cohealo-engineering/how-set-up-a-slack-channel-to-be-an-aws-sns-subscriber-63b4d57ad3ea

kmfreas commented 5 years ago

Hey thanks for replying, I wasn't able to test this out until now. It works fine, however I can't figure out how to get it to work with all branches, especially future ones. Right now I have a lambda function using the aws-js-sdk to create the Amplify branches as they're pushed to github.

I'm using createBranch and it has an option for enableNotifications but that doesn't seem to do anything?

How do I get a newly created branch to send emails to my lambda arn?

RyanHow commented 5 years ago

Hey I just found this article here

Looks like there is a way to do it through cloudwatch?

https://medium.com/@dabit3/introducing-the-amplify-console-8-exciting-features-7e4075ff7b36

8: Notifications Setup email notifications when your deployment succeeds or fails. Amplify Console submits build events to Amazon CloudWatch giving you a lot more capability to setup alarms and send events to services like Slack to notify users of changes.

swaminator commented 5 years ago

@RyanHow yes you can, it just requires you to configure it. Check out https://github.com/aws-amplify/amplify-console/issues/13#issuecomment-502240507

mwarkentin commented 5 years ago

@swaminator looks like that links back to this PR?

mwarkentin commented 5 years ago

@swaminator have you discussed amplify console notification support with the AWS chatbot team? That would be great. 😊

adriencg commented 4 years ago

@kmfreas I know this is late..but you can actually modify the event pattern that Amplify creates to notify your email about all branches (past, present, future) assuming you've created at least one notification via the Amplify console.

Go to the Amazon EventBridge console, under "Rules" find the rule for your app (should look like amplify---branch-notification). Modify the Event pattern by just deleting the "branches" array entirely (make sure to hit 'Update' at the bottom of the page after modifying the event pattern inline). You can quickly test by connecting a new branch.

This works b/c EventBridge treats a missing field as a wildcard, so by deleting the branches array you're telling the service to deliver events about all branches.

swaminator commented 4 years ago

@mwarkentin @kmfreas @RyanHow this feature is now available in the Console

github-actions[bot] commented 2 years ago

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