terraform-cost-estimation icon indicating copy to clipboard operation
terraform-cost-estimation copied to clipboard

How can I integrate it with a GitHub action?

Open schosterbarak opened this issue 5 years ago • 1 comments

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

schosterbarak avatar Jun 08 '20 22:06 schosterbarak

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

antonbabenko avatar Jun 09 '20 06:06 antonbabenko