Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension fails to run in large workspaces that aren't fully Terraform #35

Open
ddulic opened this issue Jul 21, 2022 · 3 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@ddulic
Copy link

ddulic commented Jul 21, 2022

Hello, I am seeing the following issue

Could not run the infracost cmd in the /Users/ddulic/Work/work-project-name directory. This is likely because of a syntax error or invalid project. See the Infracost Debug output tab for more information. Go to View > Output & select "Infracost Debug" from the dropdown. If this problem continues please open an issue here: https://github.com/infracost/vscode-infracost.
debug: initializing workspace
debug: running Infracost in project: /Users/ddulic/Work/work-project-name
debug: running Infracost cmd INFRACOST_CLI_PLATFORM=vscode infracost breakdown --path "/Users/ddulic/Work/work-project-name" --format json --log-level info
error: Infracost cmd error trace Error: Command failed: INFRACOST_CLI_PLATFORM=vscode infracost breakdown --path "/Users/ddulic/Work/work-project-name" --format json --log-level info
[91mError:[0m No valid Terraform files found at the given path, try a different directory

Try setting --path to a Terraform plan JSON file. See [4;1mhttps://infracost.io/troubleshoot[0m for how to generate this.

I am assuming that the issue is that I have a large workspace where not all projects are Terraform projects.

This should not prevent the extension from running.

Reinstalling the expansion doesn’t resolve the issue.

I am able to run infracost breakdown --path . directly in the Terraform projects to get the output, but the extension still doesn’t work.

Running infracost breakdown --path . in the top-level folder housing all the projects works as intended and skips the folders that aren’t TF.

@hugorut hugorut added the bug Something isn't working label Jul 21, 2022
@hugorut hugorut self-assigned this Jul 21, 2022
@hugorut
Copy link
Collaborator

hugorut commented Jul 21, 2022

hey @ddulic, thanks for raising this issue.

So the extension should be fine running in a workspace where not all projects are Terraform projects. At this point the extension is just a UI wrapper for the binary, so it's a bit weird that you can run infracost breakdown --path . in the /Users/ddulic/Work/work-project-name from your terminal and it be fine. I've got a few follow up questions to hopefully debug what's going on here:

  1. could you run infracost breakdown --path /Users/ddulic/Work/work-project-name --format json --log-level info where the /Users/ddulic/Work/work-project-name is the real file path show in the Infracost debug log. Does this succeed?
  2. If you answer no to the above could you run infracost breakdown --path /Users/ddulic/Work/work-project-name --format json --debug-report and upload the infracost-debug-report.json created here.
  3. If yes to point 1 could you try and open one of the valid terraform projects under /Users/ddulic/Work/work-project-name as a VSCode workspace and see if Infracost can work within it?
  4. Could you write a shallow tree output of the /Users/ddulic/Work/work-project-name and post it here? Highlighting which folders are root Terraform projects e.g.:
/Users/ddulic/Work/work-project-name/
    folder/
    myfolder/
    myproject/ # tf project
    infra/
         dev/ #tf project
         prod/ #tf project

Thanks

@ddulic
Copy link
Author

ddulic commented Jul 21, 2022

Thanks for the prompt reply @hugorut!

it's a bit weird that you can run infracost breakdown --path . in the /Users/ddulic/Work/work-project-name from your terminal and it be fine.

Actually, that was just me confirming that I can run infracost directly in Terraform projects, and it works, just to clarify that the CLI tool is working.

When I attempt to run it in the folder that is causing the extension to crash I get the following:

~/Work/work-project-name
❯ infracost breakdown --path .
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.

Just wanted to clarify that.


So /Users/ddulic/Work/work-project-name is not a TF Project. Would you still like me to run all the debug steps?

@hugorut
Copy link
Collaborator

hugorut commented Jul 21, 2022

@ddulic does /Users/ddulic/Work/work-project-name have any terraform projects in? If so how many nested folders deep are these? I think the maximum level of folder nesting we check is 5 layers deep.

If these are less than 5 folders deep, yes please I'd love if you could run the debug steps. Thanks

matthieupetite added a commit to matthieupetite/vscode-infracost that referenced this issue Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants