using the infracost CLI, is there a way to view th...
# help
using the infracost CLI, is there a way to view the estimated cost using the
file instead of the plan? basically, if a user changes values in the params file and saves, but doesn't deploy, we don't want an updated cost based on the params. we just want to know the estimated cost based on what's listed in the state file 🤞
Hi, you can pass a state JSON to the CLI. So use the terraform show command with the
flagto convert your .tfstate to a state JSON, then call
infracost breakdown -path=tfstate.json
Have you tried the HCL parsing though? In general we don’t recommend using plan.json files anymore. You can pass the terraform project directory as
and we’ll generate an estimate directly from the .tf files, i.e.
infracost breakdown --path=./my/terraform_project
. It tends to be much faster than generating a plan json.
so what we're doing on our backend for our platform is storing params set by customers in the UI. we don't want to run the estimator based on the params because customers can save params without deploying them
to be as accurate as possible for the costs our customers may see on their bill, we just want infracost to read the customer's statefile (stored in our s3 bucket) and generate the estimated cost from what's actually deployed
@crooked-daybreak-55253 I was able to get this working. how can i convert the breakdown into a scrapable file like JSON or something?
add a
flag to the breakdown command. You can also set
to put it in a file
@faint-oyster-21329 if you’re building an integration with Infracost, please follow these guidelines.