antonbabenko / terraform-cost-estimation

Anonymized, secure, and free Terraform cost estimation based on Terraform plan (0.12+) or Terraform state (any version)
https://terraform-cost-estimation.com/
Apache License 2.0
686 stars 62 forks source link

How can I integrate it with a GitHub action? #13

Open schosterbarak opened 4 years ago

schosterbarak commented 4 years ago

Great tool. would love to continuously acknowledge the estimated price of https://github.com/bridgecrewio/terragoat on every push to master

antonbabenko commented 4 years ago

Hi Barak!

You can do this by running terraform plan on GH action and then sending tfplan file to cost.modules.tf with or without preprocessing via terraform.jq, as described here - https://github.com/antonbabenko/terraform-cost-estimation#example---get-cost-estimates-during-terraform-plan

You can also make your pipeline fail if price is too high:

$ ... | curl -s -X POST -H "Content-Type: application/json" -d @- https://cost.modules.tf/ > costs.json
$ jq 'if .monthly|tonumber > 10 then "$" else "$$$" end' costs.json