Predicting infrastructure costs with Infracost
In today’s world, creating and allocating resources in the cloud is relatively easy, so easy that sometimes you might lose track of the changes and its implications. (like this dude)
Infracost is an amazing tool that helps you estimate the cost of your infrastructure in several cloud providers, such as AWS, GCP, Azure, and more.
Installing Infracost
You can follow the official documentation
Show cost breakdown locally
First of all, navigate to the folder containing the tf files and run the following command to show cost breakdown:
infracost breakdown --path .
You will get something like this:
Connecting Infracost to your repository
This will definitely add more value if you are planning to use it in a company or/with different team members.
First of all, you will need to create an account in https://login.infracost.io/ and then, in the main dashboard you will find the instructions to connect your repo.
After setting your repository, you are ready to go.
Now everytime you create a Pull Request containing infrastructure changes, Infracost will post a comment similar to this:
Infracost will point you all the errors and warnings related to pricing and FinOps found in your code, so you can deploy safely your infrastructure.