Building a serverless automated Cost Visibility report
Journey: 📊 Community Builder 📊
Subject matter: Building on AWS
Task: Building a serverless automated Cost Visibility report
I recently shared an article relating to cost visibility on LinkedIn Here
This project is all about observability, and understanding what is happening in the account.
Using the 6 Pillars of the AWS Well-Architected Framework, Cost Optimisation will be achieved in this build.
I will be setting up a serverless cost monitoring and reporting system that uses Email to notify on spending patterns.
Credit: This serverless architecture was created using some guidance from Pushkar Joshi on Medium Here and TechStoryLines Here. I picked bits from each article to help me fulfill my requirements.
What did I use to build this environment?
- Lambda [with layers]
- Amazon Simple Email Service
- Amazon EventBridge
- AWS Management Console
- IAM
What is built?
- A configured, layered Lambda function using Python
- A call to the AWS Cost Explorer API
- A verified email service
- An Amazon EventBridge configuration to call the Lambda function on a rate-based schedule
Using the principle of least privilege:
Taken from the AWS documentation Here:
“The principle of least privilege states that identities should only be permitted to perform the smallest set of actions necessary to fulfill a specific task.”
To obtain the correct Lambda Permission for this, I used some further documentation Here.
I used the Cost Explorer API which enables me to programmatically query data for the cost and usage of AWS services.
This solution uses a Lambda function to query aggregated data from the API, format that data, and send it to a defined list of recipients.
Once I had configured all of the areas, I successfully received a cost visibility report!
Some of the highlights…
Lambda Function:
Lambda policy:
Lambda Layer:
SES verified email:
EventBridge Schedule:
Cost visibility report:
My interpretation of the architecture:
I hope you have enjoyed the article, I enjoyed the build!