[FinOps] Using Open Source Bill Bot to Receive AWS Cost Reports via Slack

What is Bill Bot? 

- This open-source solution allows you to receive cost reports via Slack on a daily and monthly basis. The contributors are Christian Bonzelet, an AWS Solutions Architect from Germany, and Mauricio Klein, a developer from Spain. This setup has been verified and is available as open-source for anyone to use.

reference: https://github.com/cremich/cdk-bill-bot


Bill Bot Architecture:

- The core of Bill Bot is storing CUR data in AWS S3. CUR stands for AWS Cost and Usage Report, which represents cost reports. The CUR data stored in S3 is crawled using Glue crawlers to create/update a database in the Data Catalog.

At this point, AWS Athena is ready to query the data. The step function operates based on a scheduled time, which is set to 8 AM UTC by default. The step function works by using a Lambda function to calculate the date for the previous day, then queries the billing data for that date using Athena. Finally, it executes a Lambda function to send the query results to Slack, allowing you to receive alerts via Slack.


HOW CUR is storing data in S3?

1. Report Creation: You first create a Cost and Usage Report in the AWS Billing Console.

2. Configuration: Specify the Amazon S3 bucket where you want the report to be delivered.

3. Delivery: AWS generates the report and delivers it to the specified S3 bucket. The report is updated at least once a day and can be configured to update up to three times a day12.

4. Format: The report files are in CSV format, which can be accessed using spreadsheet software or applications via the Amazon S3 API


[S3 bucket policy]

{

    "Statement": [

        {

            "Effect": "Allow",

            "Principal": {

                "Service": "billingreports.amazonaws.com"

            },

            "Action": [

                "s3:GetBucketAcl",

                "s3:GetBucketPolicy"

            ],

            "Resource":"arn:aws:s3:::DOC-EXAMPLE-BUCKET",

            "Condition": {

                "StringEquals": {

                    "aws:SourceArn": "arn:aws:cur:us-east-1:${AccountId}:definition/*",

                    "aws:SourceAccount": "${AccountId}"

                }

            }

        },

        {

            "Sid": "Stmt1335892526596",

            "Effect": "Allow",

            "Principal": {

                "Service": "billingreports.amazonaws.com"

            },

            "Action": "s3:PutObject",

            "Resource": "arn:aws:s3:::DOC-EXAMPLE-BUCKET/*",

            "Condition": {

                "StringEquals": {

                    "aws:SourceArn": "arn:aws:cur:us-east-1:${AccountId}:definition/*",

                    "aws:SourceAccount": "${AccountId}"

                }

            }

        }

    ]

}


Once the open-source Bill Bot setup is complete, you can receive the following results.



Bill Bot offers the advantage of easily monitoring cloud costs, enabling businesses and individuals to analyze costs and prevent waste.

Comments

Popular posts from this blog

[Kubernetes] Node Overcommitted

[AWS] What is the Cloud Formation?

How to Install jenkins using Helm chart on instance