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.

질문됨 3년 전1.6천회 조회
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
답변함 3년 전
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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠