Shifting left on costs with Infracost

A must-have tool for engineering teams with mature FinOps practices

Introduction

The earlier in the software development lifecycle that you can identify, triage, and resolve potential problems with cloud infrastructure, the less costly it is to fix them. This principle applies not only to costs, but also to performance, reliability, scalability, and security. In this week's newsletter, we’re going to present the benefits organizations can realize from having a culture of cost awareness, the importance of “shifting left” on costs, and a must-have tool for engineering teams with mature FinOps practices.

Benefits of a culture that has cost awareness

The first step to solving a problem is recognizing that it exists. Many teams within an organization have very little visibility into their costs. Information about costs is usually “siloed” into disparate parts of an organization, away from the decision-makers who could use it. Including engineers in any cost awareness practices is one of the best ways to ensure that all stakeholders have a shared sense of responsibility. When we help organizations develop a culture of cost awareness, we frequently see the following:

  • Faster time to decisions: Decision-makers receive the data they need to make the right decisions as they go, rather than waiting until the next billing cycle to see the impact of last month's decisions.

  • Improved resource allocations: Engineers, architects, managers, and leadership are quickly alerted to the impact of decisions. For example, a team might choose to switch instance types once they realize that the initial architecture is twice as expensive as the original estimate. Cost awareness allows teams to weigh the financial implications of different decisions regarding architecture, technology, and feature development. This leads to more cost-effective solutions that are more sustainable.

  • Reduced total cost of ownership: The costs of a given service don’t end with production. They persist over the long cycle of that service until it is deprecated and replaced. By tracking the costs of ownership over time, organizations can decide which projects to prioritize and which to outsource or repatriate.

Shifting left on costs

The term “shifting left” is used to describe the practice of addressing issues earlier in the software development life cycle. Within the context of cloud cost management, shifting left on costs means considering and managing costs in the earliest stages of the development process, rather than after the software has been shipped.

Mature engineering organizations often consider the costs of their services as part of an architect review process. By considering costs earlier in the development process, teams can more accurately predict their infrastructure expenses, respond to changes, and manage their budgets. This acts as a barrier to prevent cost overruns, ultimately ensuring that projects remain financially on track. The resulting solutions are more cost-effective with faster time-to-market for new features and products. Additionally, shifting left acts as a feedback loop toward building a culture of cost awareness since costs are integrated into the decision-making process from the start.

Infracost: A Tool for Cost Estimation and Management

Infracost is an open-source tool designed to help developers estimate and manage cloud infrastructure costs throughout the software development process. It provides cost visibility by integrating with popular infrastructure as code (IaC) frameworks like Terraform (and soon Pulumi), giving engineers a feedback loop for costs inside of their native workflow. FinOps practitioners have frequently rated Infracost as a must-have tool. Benefits of Infracost include:

  • Cost visibility: Infracost provides a cost breakdown for each resource and the total estimated cost, making it easier to understand and manage cloud costs during the development process.

  • Integration with CI/CD pipelines: Infracost can be integrated with your CI/CD pipelines, scanning for infrastructure code changes and providing cost estimates before any resources are launched. This helps catch potential cost issues early in the development process and enables teams to address them before they become more significant problems.

  • Support for multiple cloud providers: Infracost supports over 1,000 Terraform resources across AWS, Azure, and Google Cloud, making it a versatile tool for organizations using multiple cloud providers.

Infracost in action

Infracost helps inform engineers on expected costs changes in PRs.

In the example above, the Infracost bot highlights a $9 increase in monthly costs, representing a 28% rise. The engineer can then delve deeper into the output to gain a more comprehensive understanding of which resources are primarily responsible for the cost changes. This is a highly effective process for identifying and addressing potential issues, ensuring that the organization maintains cost efficiency while deploying new services and infrastructure.

The detailed breakdown reveals that the primary driver of this increase is the addition of an AWS instance, which contributes $8 to the total. Furthermore, the general-purpose SSD storage (gp2) for the root block device adds another $0.80 (and ideally, you’re changing that to gp3!). By examining this information, engineers can quickly assess the cost implications of their changes and determine whether they align with the project's budget and objectives.

Conclusion

A culture of cost awareness in software development is necessary to optimize infrastructure spending and better align development efforts with business objectives. By integrating tools like Infracost into your development workflow and adopting a shift-left approach to cost management, you can make sure that cost considerations are taken into account from the earliest stages of the development process.

Your organization can benefit from more efficient resource allocation, improved decision-making, and reduced overall costs. Start building a culture of cost awareness today and empower your team to make more informed decisions about their infrastructure choices.