DEV Community

Cover image for AWS Cost Notification to Discord
K-Rintaro
K-Rintaro

Posted on

AWS Cost Notification to Discord

AWS pricing system is very complicated, so there are many useful tools that can notify AWS cost daily or monthly.
Many tools are developed for Slack, but I love Discord.
Therefore, I developed AWS Cost Notification System for Discord.

This system can notify "Today's AWS cost" to Discord at 23 o'clock every day.
Also, that can notify "Last Month's AWS cost" to Discord at 23 o'clock first day of the month. (This can be changed at index.js)

All source code: https://github.com/K-Rintaro/aws-cost-discord-notify

aws-cost-discord-notify

Requirement

node.js
npm packages
・aws-cost-explorer
・dotenv
・discord.js
・node-cron
・node-fetch

How to use

aws-cost-discord-notify needs to use AWS Cost Explorer API.
That costs 0.01 USD every request.

  1. Create your Discord bot at https://discord.com/developers/applications
  2. Create AWS IAM user and get access key id & secret access key

Example policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ce:*"
      ],
      "Resource": [
        "*"
      ]
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode
  1. Create .env file and set Discord token, AWS access key and AWS secret access key that you got.
  2. Get index.js from GitHub repo and set your Discord channel id. You can change notification time, too.

I hope I can be of any help to you.

Top comments (0)