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.

feita há 3 anos1,6 mil visualizações
2 Respostas
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
respondido há 3 anos
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
respondido há um ano

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas