aws-slack-bot

command module
v0.0.0-...-fc93924 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 23, 2018 License: MIT Imports: 5 Imported by: 0

README

License Go Report Card GoDoc Build Status

aws-slack-bot

This bot is implemented in golang and is meant to send AWS Usage report to an integrated slack channel. The following services are watched and reported:

  1. EC2 Usage.
  2. S3 Usage.
  3. CloudFront Usage.
  4. RDS Usage.
  5. Elasticache Usage.
  6. Estimated Billing.

You can specify any region(s) you want to watch and the frequency of reporting using cron definition

Usage

The application is release via Docker, which can be found here: https://hub.docker.com/r/wumuxian/aws-slack-bot/ Choose a version to use, currently the latest version is wumuxian/aws-slack-bot:v0.0.2

You need to set the following parameters to make it work.

Environment Variables Decription
AWS_ACCESS_KEY_ID You access key ID to the AWS account
AWS_SECRET_ACCESS_KEY You access secret to the AWS account
AWS_ACCOUNT_ID The AWS account ID you want to watch
SLACK_WEBHOOK_URL The slack channel web-hook
CRON_DEFINITION The cron job definition that sets the frequency of the report
REGIONS Comma separated regions you want to watch, e.g. us-east-1,eu-central-1

Notes: Please note that your IAM must be granted relevant read access to the services. If not then you won't receive report for that service.

If you don't specify the CRON_DEFINITION, the default will be 0 0 1 * * MON-FRI, which means "Every 9am in the morning, from Monday to Friday, SGT Timezone"

If you don't specify the REGIONS, the default will be us-east-1, which is US East (N. Virginia)

The SLACK_WEBHOOK_URL is a required field, if not specified, the program won't run.

The CRON_DEFINITION must have correct cron syntax, otherwise the program won't run.

Example execution script using docker:

docker run -d \
  -e AWS_ACCESS_KEY_ID="" \
  -e AWS_SECRET_ACCESS_KEY="" \
  -e AWS_ACCOUNT_ID = "" \
  -e SLACK_WEBHOOK_URL="" \
  -e CRON_DEFINITION="0/5 * * * * ?" \
  -e REGIONS="us-east-1,ap-southeast-1" \
  --name aws-slack-bot wumuxian/aws-slack-bot:v0.0.2

Development

If you want to contribute to the repo, please continue to read.

Dependencies

Setup

dep init
dep ensure

Run locally

go run *.go

Build docker image

./build.sh

Feel free to build to your own images, just modify the build.sh script.

Release

./release.sh

Fee free to release to your own repo, just modify the release.sh script

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package jobs defines a few cron jobs that can be scheduled to run.
Package jobs defines a few cron jobs that can be scheduled to run.
Package stats contains functions to gather usage stats of different services and consolidated billing estimations.
Package stats contains functions to gather usage stats of different services and consolidated billing estimations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL