Helps you to estimate costs of Terraform Plans and right now is focused on the azurerm
Terraform Provider. Note these are estimates only (not actual costs)
based on "Pay-as-you-Go" pricing. The point of this API is only so you have an estimate, not a guarantee of potential future costs.
If you're looking for other pricing schemes, such as "reserved", "DevTest", or if your company has an agreement
with a cloud provider that gives you a discount off of standard "Pay-as-you-Go" list prices this will not be reflected here. Hopefully,
if you are looking for one of these pricing schemes, this API should at least provide you with an upper-bound. However,
it in no way represents a guarantee of prices between you and your cloud provider.
It is definitely designed to provide this functionality, but at present since I work at a company that uses Azure I'm focused on that. That being said, PR's welcome!
One more time for emphasis, this is only an estimate of expected future cloud costs!
terraform plan -out=plan.tfplan > /dev/null && terraform show -json plan.tfplan | curl -s -X POST -H "Content-Type: application/json" -d @- https://api-dev.pricing.tf/estimate{
"unsupported_resources": [
"azurerm_network_interface.example"
],
"unestimateable_resources": [
"azurerm_resource_group.example",
"azurerm_subnet.example",
"azurerm_virtual_network.example"
],
"estimate_summary": {
"hourly_cost_usd": 0.114,
"monthly_cost_usd": 83.22,
"yearly_cost_usd": 998.64
}
}The response provides:
unsupported_resourcesto let you know which resources weren't pricedestimate_summarywhich contains the Hourly, Monthly, and Yearly additional cost based on this Terraform planunestimateable_resourcesto let you know which resources are not currently able to be estimated based on this terraform plan
Note: currently "monthly" and "yearly" prices are only calculated as a multiple of hours. 1 Month = 730 Hours and 1 Year = 8760 Hours.
The code is all here and executes in a serverless function, you can read for yourself and see that we're not storing/logging anything you send. 😄
| Resource Name | Area | |
|---|---|---|
| [x] | azurerm_linux_virtual_machine |
Compute |
| [x] | azurerm_windows_virtual_machine |
Compute |
| [x] | azurerm_virutal_machine |
Compute |
| [x] | azurerm_virutal_machine_scale_set |
Compute |
| [x] | azurerm_linux_virutal_machine_scale_set |
Compute |
| [x] | azurerm_windows_virutal_machine_scale_set |
Compute |
| [x] | azurerm_kubernetes_cluster |
Containers |
| Resource Name | Area | |
|---|---|---|
| [x] | azurerm_resource_group |
Management |
| [x] | azurerm_virtual_network |
Networking |
| [x] | azurerm_subnet |
Networking |
| [x] | azurerm_network_interface |
Networking |
Not all billable resources in Azure are tied to an hourly price. For example, consider VNETs/egress, StorageAccount Blob Storage consumed size, or anything tied to API call count like KeyVault. These resources depend on further consumption after provisioning, so they are in-effect unestimateable from the standpoint of this API. In theory, one could derive an estimate based on average consumption across all Azure usage, but I don't work for Microsoft/nor have access to that data. So, they will probably remain unestimated unless you have a good idea and want to contribute!
- Ensure that go >= 1.13 and
serverless2.x is installed on your machine - Make a PR (add a test too)
- Assign me (zparnold) and I will try to get it merged and deployed.
The api/pricers/ folder is where a collection of interfaces of type Pricer are implemented. The only function necessary to
implement this interface is GetHourlyPrice() which returns a float64. Should you want to use the existing price database (Dynamo)
take a look at the resource enumeration section below. There is also a prices.csv that should give you a full list of
priceable objects in Azure returned by their public API here: https://docs.microsoft.com/en-us/rest/api/cost-management/retail-prices/azure-retail-prices
To add another resource to be priced:
- Add a new file, preferably in the
api/pricers/folder using a name that would help others understand it - Implement the function from above
- Add a
casestatement in theapi/main.gowhich binds the terraform resource name to the pricer (copy one from the method.)
| Status | Task |
|---|---|
| [x] | Integration tests exist |
| Integration tests in CI pipeline | |
| Automated deployment in CI Pipeline | |
| [x] | Basic compute resources supported |
| Basic storage resources supported | |
| Estimateable networking resources supported | |
| Some PaaS or SaaS resources supported maybe? (Azure App Services, Redis, Azure Functions, AKS, ACI) |