Shift Left: Azure Cost Management with Infracost

Executive technology leader responsible for platform reliability, cloud operations, security posture, and enterprise technology risk within an investor-backed fintech environment. I lead technology operations at the intersection of engineering execution, governance, and business outcomes — ensuring platforms are scalable, resilient, and trusted by investors, regulators, and clients.
Currently VP of DevOps at InvestorFlow, where I focus on building board-ready technology operations, strengthening risk and resilience, and shaping long-term platform strategy to support growth and regulatory confidence.
Infracost signup
For this article, we are only utilising the free version of Infracost. This is called Infracost CI/CD, and can be found under their Pricing window on https://www.infracost.io/pricing/

You can see their other services and features on this page. For this article, we are focusing only on the free plan. We will be limited to 1,000 monthly runs to scan our IaC, which is enough for a startup or small IaC estate.
First, select the Sign up / Log in button at the top right of the screen. From this screen, sign up for Infracost using one of the multiple methods. Once you have verified your signup, you will be presented with the CI/CD integration window, which we will follow up with later in this post.
Executing Infracost locally
We will need to install Infracost locally first to run it. This can be very powerful with the shift left mentality/approach, as you can run cost estimates before checking in the IaC to your repo.
If you are running macOS and use Brew to manage package installations, you can install Infracost using the following command:
brew install infracost
Or, if you are running Windows as your local OS, download the latest installation using this link.
When ready, using the terminal, enter the following command to authenticate to InfraCost:
infracost auth login
Now you are authenticated locally; you can execute InfraCost commands in the root directory of your IaC, which contains your Azure resources. This is an example of an Azure resource in Terraform:
terraform {
required_version = ">= 1.0.0"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.54.0"
}
}
}
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "example" {
name = "rg-example"
location = "eastus"
}
resource "azurerm_mssql_server" "example" {
name = "mssqlserverexample123"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
version = "12.0"
administrator_login = "adminuser"
administrator_login_password = *****
minimum_tls_version = "1.2"
}
resource "azurerm_mssql_database" "example" {
name = "mssqldatabaseexample"
sku_name = "Basic"
collation = "SQL_Latin1_General_CP1_CI_AS"
server_id = azurerm_mssql_server.example.id
}
output "mssqlserver_name" {
value = azurerm_mssql_server.example.name
}
output "mssqldatabase_name" {
value = azurerm_mssql_database.example.name
}
I execute the following command in the directory where I have my IaC:
infracost breakdown --path .
This generates the following estimates for me:
INFO Autodetected 1 Terraform project across 1 root module
INFO Found Terraform project main at directory .
Project: main
Name Monthly Qty Unit Monthly Cost
azurerm_mssql_database.example
├─ Compute (BASIC) 730 hours $4.90
├─ Long-term retention (RA-GRS) Monthly cost depends on usage: $0.05 per GB
└─ PITR backup storage (RA-GRS) Monthly cost depends on usage: $0.20 per GB
OVERALL TOTAL $4.90
*Usage costs can be estimated by updating Infracost Cloud settings, see docs for other options.
──────────────────────────────────
3 cloud resources were detected:
∙ 1 was estimated
∙ 2 were free
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Project ┃ Baseline cost ┃ Usage cost* ┃ Total cost ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━┫
┃ main ┃ $5 ┃ - ┃ $5 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━┛
Integrating Infracost to GitHub
Now we return to the InfraCost dashboard (https://dashboard.infracost.io/). Select GitHub as the source control integration and select Next.

You will then need to select the Connect button to start the integration with GitHub.

The Install Infracost window appears, asking you to select an organisation to which you want to install this.

You can choose all repositories or a select number when an organisation is selected. For this article, I selected All repositories and proceeded by selecting Install.

Finally, you can see the repositories in the Infracost dashboard; here, you can select the repositories you want to onboard to Infracost.

Once selected, you are asked to generate a pull request. You can either create a pull request with the example Terraform Infracost provides to confirm the integration or raise a legitimate PR which contains the Terraform you produced.
When a PR is generated, you will see Infracost comment on the PR about resource costs. But please be aware that Infracost does not support all resource types yet. As such, you must review what is not supported if the output suggests it cannot find a price.






