I want to send a notification to discord when amplify's app is deployed.

0

It seems that only email notifications are possible. In the case of slack, I understand that you can receive notifications via your email address. But discord has no way. I want to be notified via discord.

已提問 2 年前檢視次數 1236 次
2 個答案
0

Hi, Good question

I think it is possible to use Event Bridge/CloudWatch events with Lambda and Webhooks

Here is an example https://towardsdatascience.com/discord-notification-using-cloudwatch-alarms-sns-and-aws-lambda-71393861699f

Here is another example to slack using Webhook (please note it's not same as the one you asked in the question, however it gives you an idea) https://security-hub-workshop.awssecworkshops.com/04-enrichment-and-integration/

hope this helps!

profile picture
Sri
已回答 2 年前
0

To send notifications on Discord when your AWS Amplify project is updated, you can make a Lambda function to achieve it.

Create a Discord Webhook:

  • In your Discord server, go to the channel where you want to receive notifications.
  • Click on the gear icon next to the channel name to edit the channel.
  • Go to the "Integrations" section and click "Webhooks."
  • Click "Create Webhook" and follow the prompts to create a webhook URL. You can customize the name and avatar for the webhook.

Create an AWS Lambda Function:

  • In the AWS Lambda console, create a new Lambda function.

  • Choose a runtime (e.g., Node.js, Python, etc.).

  • Configure a trigger for the function. You can use an S3 bucket as a trigger and set up the bucket to trigger the Lambda function whenever your Amplify project is updated (e.g., whenever new files are uploaded to the bucket).

  • Write the Lambda function code to send a notification to the Discord webhook. Here's an example using Node.js and the axios library:

    const axios = require('axios');
    
    exports.handler = async (event) => {
      const webhookURL = 'YOUR_DISCORD_WEBHOOK_URL';
      const message = 'Amplify project updated!';
    
      try {
        await axios.post(webhookURL, { content: message });
        return 'Notification sent to Discord.';
      } catch (error) {
        console.error('Error sending notification:', error);
        throw new Error('Failed to send notification to Discord.');
      }
    };

Deploy the Lambda Function:

  • Package and deploy your Lambda function code along with any dependencies using the AWS CLI or other deployment tools.

Set Up S3 Bucket Trigger:

  • In the AWS S3 console, configure a bucket notification that triggers your Lambda function whenever new files are uploaded to the bucket. You can use an S3 event like "ObjectCreated" to trigger the Lambda function.
AWS
已回答 9 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南