infracost/actions

No valid Terraform files found at the given path, try a different directory | Github action

samarth3112 opened this issue · 2 comments

  • name: Generate Infracost cost estimate baseline
    run: |
    ls -l

     sed -i '1,2d' plan.json
     infracost breakdown --path plan.json  --format json --out-file /tmp/infracost-base.json
    
  • name: Generate Infracost diff
    run: |
    infracost diff --path plan.json --format=json --compare-to=/tmp/infracost-base.json --out-file=/tmp/infracost.json

Output : Run ls -l
total 11188

-rw-r--r-- 1 runner docker 6605 Nov 15 08:52 CHANGELOG.md
-rw-r--r-- 1 runner docker 384 Nov 15 08:52 CODEOWNERS
-rw-r--r-- 1 runner docker 5641 Oct 28 08:55 README.md

drwxr-xr-x 2 runner docker 4096 Nov 15 08:52 bin
drwxr-xr-x 4 runner docker 4096 Nov 15 08:52 infrastructure
-rw-r--r-- 1 runner docker 247309 Nov 15 08:53 plan.json

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.
Error: Process completed with exit code 1.


But doing an ls shows file is present is the same path as plan.json. Not sure what has changed , since this was working earlier .Guidancen please

@samarth3112 Hello! Thank you for creating the issue!

From the issue's description, it looks like that plan.json is not a valid Terraform JSON file. Can you double-check that? Here are instructions on how you can generate this file: docs.

UPD: Also, FYI, if you have your TF code available in the GitHub action, Infracost CLI can parse it directly, just point it to the directory like infracost --path=${TF_ROOT} where TF_ROOT is the path your TF project directory.

I'm going to close this issue as we haven't heard back so I assume the issue is resolved. Feel free to comment if the issue still stands.