Chapters
Try It For Free
No items found.
December 31, 2024

How we built a scalable system of generating recommendations for cloud cost optimization

Table of Contents
How we built a scalable system of generating recommendations for cloud cost optimization

How we built a scalable system of generating recommendations for cloud cost optimization

co-authors: Nikunj Badjatya, Rohit Reddy, Rajarshee Chatterjee.



 

Table of contents


 


       

     

Overview

As cloud adoption continues to rise, efficient cost management demands a robust and automated strategy. Native cloud provider recommendations, while helpful, often have limitations — they primarily focus on vendor-specific optimizations and may not fully align with unique business requirements. Additionally, cloud providers have little incentive to highlight cost-saving opportunities beyond a certain extent, making it essential for organisations to implement customised, independent cost optimization strategies.

At Harness, we developed a Policy-Based Cloud Cost Optimization Recommendations Engine that is highly customisable and operates across AWS, Azure, and Google Cloud. This engine leverages YAML-based policies powered by Cloud Custodian, allowing organisations to define and execute cost-saving rules at scale. The system continuously analyses cloud resources, estimates potential savings, and provides actionable recommendations, ensuring cost efficiency across cloud environments.

Benefits of a policy based Cloud Cost Optimization Recommendations Engine

  • Customisability: Users can define policies tailored to their organisation’s cost optimization strategy. Policies allow filtering resources based on conditions such as resource metrics, operational state (e.g., running, stopped), lifecycle phase (e.g., age, creation date), and compliance attributes to enforce governance and cost optimization.
  • Multi-Cloud Support: Works across AWS, Azure, and GCP, ensuring a consistent and unified cost-saving strategy. Avoids vendor lock-in by not relying solely on provider-native cost recommendations.
  • Automated Cost Optimization: Automatically applies policies across multiple accounts and regions to detect and remediate cost inefficiencies. Continuously refines recommendations as cloud resources evolve.
  • Transparent and Scalable Approach: Cost-saving logic is fully visible in YAML policies, unlike opaque cloud provider recommendations. Scales effortlessly as new resources and accounts are added.

Key Components Involved

Cloud Custodian

Cloud Custodian, an open-source CNCF-backed tool, is at the core of our policy-based engine. It enables defining governance rules in YAML, which are then executed as API calls against cloud accounts. This allows seamless policy execution across different cloud environments.

Cloud Cost Data Sources

The system relies on detailed billing and usage reports from cloud providers to calculate cost savings:

  • AWS Cost and Usage Report (CUR) — Provides granular cost breakdowns at a per-resource level.
  • Azure Billing Report — Offers insights into cloud usage, pricing models, and applied discounts.
  • Google Cloud Cost Usage Report — Captures detailed billing data, including SKU-level pricing and committed use discounts.

Solution Overview

The solution leverages Cloud Custodian to define YAML-based policies that identify cloud resources based on specific filters. The cost of these resources is retrieved from relevant cost data sources (AWS Cost and Usage Report (CUR), Azure Billing Report, and GCP Cost Usage Data). The identified cost is then multiplied by the predefined savings percentage to estimate the potential savings from the recommendation.

Blog image

The diagram above illustrates the workflow of the recommendation engine. It begins with user-defined or Harness-defined cloud custodian policies, which are executed across various accounts and regions. The Harness application processes these policies, fetches cost data from cloud provider reports (AWS CUR, Azure Billing Report, GCP Cost Usage Data), and computes savings. The final output is a set of cost-saving recommendations that help users optimize their cloud spending.

How It Works — A Step-by-Step Breakdown with an example

Below is an example YAML rule that deletes unattached Amazon Elastic Block Store (EBS) volumes. When this policy is executed against any account and region, it filters out and deletes all unattached EBS volumes.

yaml

policies:

/* Syntax highlighting for code blocks */ .hljs-keyword { color: #569cd6; font-weight: bold; } .hljs-string { color: #ce9178; } .hljs-number { color: #b5cea8; } .hljs-comment { color: #6a9955; font-style: italic; } .hljs-function { color: #dcdcaa; } .hljs-variable { color: #9cdcfe; } .hljs-type { color: #4ec9b0; } .hljs-built_in { color: #4fc1ff; } .hljs-operator { color: #d4d4d4; } .hljs-punctuation { color: #d4d4d4; } .hljs-attr { color: #92c5f8; } .hljs-property { color: #9cdcfe; } .hljs-title { color: #dcdcaa; } .hljs-class { color: #4ec9b0; } .hljs-meta { color: #569cd6; } .hljs-literal { color: #569cd6; } .hljs-symbol { color: #ce9178; } .hljs-regexp { color: #d16969; } .hljs-link { color: #3794ff; text-decoration: underline; } .hljs-selector-tag { color: #569cd6; } .hljs-selector-id { color: #ffd700; } .hljs-selector-class { color: #d7ba7d; } .hljs-addition { color: #4fc1ff; background-color: rgba(79, 193, 255, 0.1); } .hljs-deletion { color: #f85149; background-color: rgba(248, 81, 73, 0.1); }

  • Policy Definition: YAML policies are written using Cloud Custodian to target specific resource inefficiencies.
  • Policy Execution: Policies are executed across multi-cloud accounts and regions, filtering unoptimized resources.
  • Cost Data Integration: The system retrieves the cost of filtered resources from AWS CUR, Azure Billing Report, and GCP Cost Usage Data.
  • Savings Calculation: The estimated cost savings is derived by applying the predefined savings percentage associated with each policy.
  • Recommendation Generation: The final output is a set of actionable cost-saving recommendations that users can review and apply.

Conclusion

Harness CCM’s Policy-Based Recommendation Engine offers an intelligent, automated, and scalable approach to optimizing cloud costs. Unlike native cloud provider tools, it is designed for multi-cloud environments, allowing organisations to define custom cost-saving policies and gain transparent, data-driven insights for continuous optimization.

With over 50 built-in policies and full support for user-defined rules, Harness enables businesses to maximise savings, enhance cost visibility, and automate cloud cost management at scale. By reducing unnecessary cloud spend, companies can reinvest those savings into innovation, growth, and core business initiatives — rather than increasing the profits of cloud vendors.

Sign up for Harness CCM today and experience the power of automated cloud cost optimization firsthand!

Anmol Maheshwari

Anmol Maheshwari is a Staff Software Engineer at Harness and former Oracle engineer, with deep expertise in building enterprise-grade platforms and developer tooling. With experience delivering high-scale systems and collaborating with Fortune 500 clients, he specializes in designing reliable, secure, and performance-driven software architectures. A graduate of the Indian Institute of Technology (IIT) Roorkee, Anmol has contributed across product engineering, integrations, and developer experience — helping organizations accelerate innovation through automation, platform engineering, and intelligent infrastructure. He is trusted within engineering communities for his leadership in solving complex technical problems, mentoring teams, and driving outcomes that deliver real business value.

Cloudopoly: Master Cloud Spend to Achieve Strategy, Savings, and Scale

Join the FinOps Excellence Summit on July 16th. Learn from industry leaders about cloud cost optimization, savings strategies, and AI-powered FinOps. Register now!

Register now

Similar Blogs

No items found.
No items found.
Cloud Cost Management