broad-zoo-34077
07/28/2022, 4:53 PMwhite-airport-8778
infracost auth login
is only used to download the pricing DB dump from our service (so your self-hosted instance stays uptodate with latest price changes automatically).brief-raincoat-4753
07/28/2022, 5:13 PMwhite-airport-8778
--path
flag isn’t pointing to terraform directory or plan JSON file. Can you cat $plan_json_path
to see if it’s the right path or if it’s a valid plan JSON file?brief-raincoat-4753
07/28/2022, 5:26 PMwhite-airport-8778
brief-raincoat-4753
07/28/2022, 7:16 PMlittle-author-61621
post-install
helm hook to run the job only on install and clean it up afterwards. Let me know what you think and if you have any other ideas?brief-raincoat-4753
08/01/2022, 5:34 PMbrief-raincoat-4753
08/01/2022, 5:34 PMwhite-airport-8778
brief-raincoat-4753
08/01/2022, 5:49 PMwhite-airport-8778
plan_json_path=$(echo $run_plan_resp | sed 's/.*\"json-output\":\"\([^\"]*\)\".*/\1/')
had to be changed to use json-output-redacted
to get the CI stage to work and generate the plan.json. I can’t find anything about json-output-redacted
in the Terraform Cloud API docs.
When plan.json is downloaded to the directory that has the plan terraform project, infracost breakdown --path=plan.json --log-level=debug
shows (notice the odd provider=terraform_dir
):
time="2022-08-01T19:23:41Z" level=debug enable_cloud_os=false func="<http://github.com/infracost/infracost/internal/hcl.(*projectLocator).walkPaths|github.com/infracost/infracost/internal/hcl.(*projectLocator).walkPaths>" file="/app/internal/hcl/parser.go:607" enable_cloud_comment=false project_name= provider=terraform_dir project_path=./plan.json routine=7 currency=USD sync_usage=false msg="walking path ./plan.json to discover terraform files"
When plan.json is downloaded to an empty directory, infracost breakdown --path=plan.json --log-level=debug
shows:
Error: No valid Terraform files found at the given path, try a different directory
Try setting --path to a Terraform plan JSON file. See <https://infracost.io/troubleshoot> for how to generate this
So it seems like the CLI isn’t able to detect the file as a valid Terraform plan JSON. When we cat plan.json | jq
it shows ok, meaning it’s a valid JSON file. Running cat plan.json | jq '. |= keys'
shows:
[
"output_changes",
"provider_schemas",
"resource_changes",
"resource_drift"
]
little-author-61621
planned_values
. I'm guessing the "redacted" JSON format is different. So my first thought is to look at what the resp we get from Terraform Cloud is in the run_plan_resp
little-author-61621
prior_state
and planned_values
keys. I’ve not seen json-output-redacted
before, only json-output
and can’t find anything in Terraform docs or Terraform Cloud UI about it either. @brief-raincoat-4753 do you know why the plan JSON is coming through in this redacted format? If not we can reach out to Hashicorp to find out why this can happen.brief-raincoat-4753
08/01/2022, 9:22 PMjson-output
format it fails to pull it from the API. Why idk 🤷 but when i change that line to be json-output-redacted
and pull the plan from this endpoint it works.
However, after talking with @white-airport-8778 and leveraging this template instead. I was able to get the results i wanted. However, I couldn't when using the other example template i posted at the start of this thread.little-author-61621
json-output-redacted
was returned instead of json-output
. But, the other template you got working is great since it doesn’t rely on pulling any plan JSON form Terraform Cloud simple smilewhite-airport-8778
INFRACOST_TERRAFORM_CLOUD_TOKEN
so your vars are fetched from there?
Are you now seeing gitlab merge-request comments ok?brief-raincoat-4753
08/01/2022, 9:56 PMwhite-airport-8778
INFRACOST_ENABLE_CLOUD: false
was causing errors in the gitlab CI yaml? do you remember what the error was?brief-raincoat-4753
08/03/2022, 1:42 AM