LoginSignup
2
0

More than 3 years have passed since last update.

AWSの概算合計請求額をAmazon SNSでメール通知する。

Posted at

はじめに

AWSの概算費用をメールで通知するスクリプトをAWS SDK for Rubyで作成しました。
処理の内容としては、「CloudWatchから値を取得」→「SNSを使ってメールで通知」という簡単なものです。
私は、EC2上のcronに登録して、1日2回通知するようにしています。

▼前提条件
Amazon SNSでトピック・サブスクリプションを作成していること
IAMでスクリプトが実行できる適切な権限のユーザーを作成していること
AWS SDK for Rubyが実行できる環境

コード

Githubにアップしています。
https://github.com/longunder/utils/blob/master/aws_charge_notification/charge_notification.rb

変数や、環境変数は環境によって異なるので適宜修正が必要です。

▼参考情報
https://docs.aws.amazon.com/sdkforruby/api/Aws/CloudWatch.html
https://docs.aws.amazon.com/sdkforruby/api/Aws/SNS.html

実行結果

下記のようなメールが届きます。件名でも金額が分かるようになっています。
mail.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0