Infracost for Azure

 By Morgan Lucas

This is a post intended for this site, as a way to get a feel of using it consistently. Older posts are here.

Infracost integrates with Infrastructure as Code technologies to check the costs of the infrastructure you're creating or changing, in multiple currencies, multiple cloud platforms, and can integrate with multiple repos and pull requests, promising to "Shift FinOps Left".

 It works with both Azure and AWS.

Installation on Windows 11

I installed it via chocolatey software management on Windows 11, using it to check Azure resources I created with Terraform. Don't forget to get the API key as well, it is a lot easier to set up than you think, and used the CLI in the program; here's that documentation (Option 1)

Don't read it until you're finished reading this, we have to improve standings.

Pulumi Integration?

While there is a page about it on the Infracost website, Infracost does not seem to integrate with Pulumi, another IaC tool (that I happen to know).

Using Infracost

This is the output for infracost breakdown; It does not acknowledge free tier eligible resources.

You'll notice that it rounds the cost down. See the highlighted 15.41$ at odds with the 15$ in the table. I played around with adding more Azure resouces and it will round up if the change is over fifty cents (0.50$).

A Few Infracost Commands 

There are more commands listed here

I switch between Australian Dollars (AUD) and USD. It would be nice to have the option for both but that's a nitpick that makes the output less streamlined. (Also the cost would be 10$ more in AUD. Oof!) 

Can we use a command to refine our table so it shows the accurate amount? 

Keeping Policies in Check

The tag policies feature seems similar to the regulations one can set up in Trivy, like I've done over here, to make Terraform code adhere to certain rules. 

Conclusion

It's very helpful so I can monitor my budget for Azure Resources It saves me clicks from entering the Azure Portal and going to Cost Management.