Skill 8.2.1
Estimate the cost of infrastructure as code changes before deployment
Key Concepts
Infrastructure as code (IaC) tools such as Terraform, AWS CloudFormation and Bicep describe resources in files. Before a change is applied, the tool can produce a plan that lists resources to be created, changed or destroyed, with their configuration. A cost estimation tool reads the plan, looks up prices for each resource and reports the monthly cost difference of the change.
Posting the estimate as a pull request comment lets authors and reviewers see that changing an instance type adds USD 1,200 a month at the moment they can still change it, rather than weeks later in the bill. Infracost is a widely used open-source tool for this with Terraform.
Estimates have limits. They are usually based on list prices, so they ignore commitment and negotiated discounts. Usage-based charges, such as requests, data transfer and storage growth, cannot be read from the plan and need usage assumptions. Estimates are therefore best used for comparing changes, not as an exact forecast.