AWS Builder Center

AI powerd AWS cloud cost optimization platform built on AWS serverless services with generative AI

Explore how AWS serverless services and generative AI can work together to identify cloud cost optimization opportunities. This article explains an AI-powered system that collects AWS resource, cost, and utilization data, analyzes potential inefficiencies using rule-based logic, and uses Amazon Bedrock to generate clear, actionable recommendations. It also covers the roles of AWS Lambda, Amazon EventBridge, DynamoDB, CloudWatch, Cost Explorer, and Amazon SNS

AWS SBGL @ UOA | Co-founder @ Beyond Campus | DevOps Assistant Intern

AI-Powered Cloud Cost Optimization: Combining AWS Serverless Services with Generative AI

Introduction

Cloud computing makes it easier to build, deploy, and scale applications. However, managing cloud costs can become challenging as the number of resources grows. Unused resources, oversized instances, and inefficient resource utilization can lead to unnecessary spending.
As someone learning cloud computing and DevOps, I wanted to explore how AWS services and generative AI could work together to identify potential cost optimization opportunities.
This led me to work on AI-Powered Cloud Cost Optimization, a project that combines AWS serverless services, cost and utilization data, rule-based analysis, and Amazon Bedrock to generate understandable cloud cost optimization recommendations.

The Problem I Wanted to Solve

Monitoring cloud expenses is not just about checking a billing dashboard. Understanding why costs are increasing and what actions might help reduce them is equally important.
For example:
  • An EC2 instance may be running continuously while using very little CPU.
  • An EBS volume may be provisioned with more capacity than necessary.
  • Cloud resources may continue generating costs even when they are not providing much value.
  • Raw billing and monitoring data may not clearly explain which optimization opportunity should be investigated first.
I wanted to build a system that could bring these different types of information together and turn them into actionable recommendations.

My Approach and Architecture

The project uses AWS services to collect, analyze, and communicate cost optimization insights.
The architecture follows this general workflow:
  1. Amazon EventBridge: Triggers the automated collection workflow.
  2. AWS Lambda: Runs separate collection and analysis functions.
  3. AWS service APIs: Collect resource information, cost data, and utilization metrics.
  4. AWS Cost Explorer and Amazon CloudWatch: Provide cost and monitoring data.
  5. Amazon DynamoDB: Stores the collected data and recommendation history.
  6. Rule-based recommendation engine: Evaluates resource utilization and identifies potential optimization opportunities.
  7. Amazon Bedrock: Helps turn structured findings into clear, human-readable explanations.
  8. Amazon SNS: Delivers recommendations through email notifications.
The intended workflow separates data collection from recommendation generation, making the system easier to understand, test, and extend.

How the Recommendation Engine Works

One of the most important design decisions was deciding where to use conventional logic and where to use AI.
I chose a hybrid approach combining rule-based analysis and generative AI.

1. Collecting the data

The system gathers information about AWS resources, their costs, and relevant utilization metrics. The data is stored in DynamoDB so that the analysis stage can work with a structured view of the collected information.

2. Identifying optimization opportunities

The recommendation engine applies predefined rules to identify situations worth investigating.
For example, an EC2 instance with consistently low CPU utilization might be flagged for an instance-sizing review. Before recommending a change, a more complete analysis should also consider memory usage, network activity, workload patterns, and performance requirements.
The system can then estimate potential savings using available pricing and cost data.

3. Using Amazon Bedrock

Once the rule-based analysis produces structured findings, Amazon Bedrock can help explain them in natural language.
Instead of presenting only a metric such as low average CPU utilization, the system can explain why the resource deserves attention, what the user should investigate, and what risks should be considered before making a change.
An important principle is that the AI should explain the findings, not invent the financial calculations. The underlying code and cost data should determine the estimated savings, while the language model helps communicate the recommendation.

4. Delivering recommendations

Amazon SNS can send recommendations to the user through email. DynamoDB can retain the recommendation history for future reference.
This makes the output more useful than a raw collection of metrics: the user receives a potential optimization opportunity along with an explanation of why it matters.

Why I Chose a Human-in-the-Loop Approach

Cloud cost optimization must not come at the expense of application reliability.
Automatically stopping instances, deleting storage volumes, or changing production infrastructure can cause outages or data loss if the system misunderstands the workload.
For this reason, the project follows a human-in-the-loop approach. It provides recommendations for review rather than automatically performing destructive actions.
The goal is to help users make better-informed decisions while keeping infrastructure changes under their control.

What I Learned

Working on this project helped me explore several important cloud engineering concepts:
  • Serverless architecture: Using AWS Lambda to separate tasks into focused functions.
  • Event-driven automation: Using Amazon EventBridge to initiate workflows.
  • Cloud monitoring: Understanding how CloudWatch metrics can provide insight into resource utilization.
  • Cost analysis: Exploring how AWS Cost Explorer and resource information can support optimization decisions.
  • Data persistence: Using DynamoDB to store collected information and recommendation history.
  • Generative AI integration: Using Amazon Bedrock to explain structured findings in a more understandable way.
  • Security and responsible automation: Applying IAM permissions and keeping infrastructure changes under human control.
I also learned that AI integration is not simply about sending cloud data to a language model. A reliable solution needs structured inputs, verifiable calculations, sensible rules, and safeguards against unsupported recommendations.

Challenges and Design Considerations

There are several details that a useful cost optimization system must handle carefully.
First, low CPU utilization does not automatically mean an instance is unnecessary. A workload may require substantial memory, experience periodic traffic spikes, or have strict availability requirements.
Second, cost estimates depend on pricing models, regions, usage patterns, discounts, and other factors. Any estimated savings should be treated as potential savings rather than guaranteed results.
Third, AWS monitoring data has limitations. For example, EC2 memory utilization generally requires the CloudWatch agent or custom metrics because it is not available by default in standard EC2 metrics.
These considerations are important for making recommendations useful, safe, and technically defensible.

Future Improvements

There are several directions in which I would like to extend the project:
  • Improve recommendation accuracy by incorporating more workload and utilization signals.
  • Add historical analysis to identify trends in resource usage and spending.
  • Introduce prioritization based on estimated savings, operational risk, and implementation effort.
  • Add an approval workflow for carefully controlled remediation actions.
  • Explore infrastructure-as-code and CI/CD to improve repeatability and maintainability.
  • Build a dashboard to visualize spending trends and recommendation history.
These are potential future enhancements, not features claimed as part of the current implementation.

Final Thoughts

This project has helped me understand how AWS services and generative AI can complement each other in a practical cloud engineering use case.
The biggest takeaway for me is that useful AI-powered cloud automation needs more than a language model. It needs reliable data collection, rule-based validation, trustworthy calculations, secure permissions, and human oversight.
I am continuing to learn and improve my skills in AWS, Cloud/DevOps, and AI-driven infrastructure solutions. Projects like this help me connect individual AWS services into a larger system and better understand how cloud engineering problems can be approached in practice.
I would love to hear from the AWS community: How would you approach building a cost optimization system that balances potential savings, workload performance, and operational risk? Would you prioritize rule-based recommendations, AI-assisted analysis, or a combination of both?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article