Are you a solo using an AWS account, a startup building on AWS, or a big company with multiple AWS Organizations having a multi-account setup? Do you also find it challenging to track billing and manage costs across all the accounts?
In my 5+ years of AWS journey, I have seen many organizations struggle with the complexity of tracking and managing their cloud expenses.
The Pain Point
One of the most common challenges organizations face using AWS is the lack of real-time visibility into their cloud expenses.
The critical complexity is in the early identification of outliers in case of cost spikes, or identification of unnecessary costs because of dormant resources. The lack of visibility and timely insight into daily expenses can lead to unexpected bills and budget overruns, causing significant stress and financial strain.
Although we do have the provisions of Budget Alerts, it’s hard to predict daily cost initially and the range varies quite a lot based on usage. Moreover, it’s such a daunting and time-consuming task to keep monitoring daily costs using AWS Cost Explorer daily.
Wouldn’t it be nice to get a simple notification that tells you daily cost by services and by accounts, and save the hassle of jumping across AWS accounts billing dashboards?
So for this, I bring you a serverless solution called ‘AWS Cost Report’!
The Solution: AWS Cost Report
The AWS Cost Report is an open-source project that addresses this challenge by automating the collection and reporting of AWS cost data.
By leveraging serverless technologies, this solution provides a seamless and efficient way to monitor daily costs and receive notifications in your preferred communication platform (Slack or Microsoft Teams).
Access it on Github: https://github.com/ibatulanandjp/aws-cost-report
Key Features
- Automated Cost Data Collection: The solution fetches daily cost data from AWS Cost Explorer, eliminating the need for manual data retrieval.
- Daily Notifications: Receive daily cost reports in Slack or Microsoft Teams, providing timely insights into your cloud expenses.
- Multi-Account Support: The solution can be deployed in a master account to aggregate costs from multiple child accounts, providing a consolidated view of expenses.
- Customizable Configuration: Easily configure the solution to suit your needs, including account IDs, preferred currency, timezone offset, and notification platform.
Technical Architecture
The AWS Cost Report project is built using AWS Lambda and AWS CDK, ensuring a scalable and cost-effective solution. Let’s dive into the technical architecture of the system.
Architecture Overview
Multi-Account
This deployment architecture can be used where you have one or multiple departments or organizational units managing their own AWS Organization, then you can deploy it at the Master Account level. The system will aggregate the account-wise cost and send notifications to the subscribed channel.
Standalone Account
This setup is useful to deploy to a single account and get notifications daily in the subscribed channel specific to that account only.
Components
AWS Lambda Function
The core functionality of the application is implemented within an AWS Lambda function. This function performs the following tasks:
- Fetch Cost Data: The function uses the AWS Cost Explorer API to fetch daily cost data for the specified account(s).
- Process Data: The fetched data is processed to calculate costs in the preferred currency and format the information for notification.
- Send Notifications: The function constructs a notification message and sends it to the configured Slack or Microsoft Teams channel using webhook URLs.
AWS CloudWatch Events Rule
A CloudWatch Events rule is scheduled to trigger the Lambda function daily at a specific time (e.g., 8 am JST or 23:00 UTC). When triggered, the rule invokes the Lambda function to collect and process the cost data.
External Notification Platforms (Slack or Microsoft Teams)
The application sends notifications to the specified Slack or Microsoft Teams channel using webhook URLs configured in the application.
Daily Notification Output
Once configured and deployed in the AWS account(s), you’ll start receiving daily notifications for the costs incurred sorted by service.
The notification summarizes your AWS costs, helping you stay informed about your cloud expenses. Here’s an example of how the notification will look in Slack and Microsoft Teams:
Slack Notification
Microsoft Teams Notification
The notification message includes the following information:
- Date: The date for which the cost data is reported.
- Account: Account ID and alias name set for that account.
- Total Cost: The total cost (in your preferred currency) incurred for the specified accounts on the given date.
- Cost by Service: A breakdown of the expenses by AWS service, showing top services and how they contributed to the total cost.
So, just go and clone the Github Repo now 🚀: https://github.com/ibatulanandjp/aws-cost-report.git
Hope this helps manage your AWS costs and would be happy to accept contributions on the repo, to make it more robust, and allow it to cater notifications to different platforms.
If you are into AWS, I recommend your next read to be:
Switch between AWS Accounts in your CLI like never before
This article was originally published on Medium.
Author Of article : Atul Anand Read full article