infracost / vscode-infracost

See cost estimates for Terraform right in your editor💰📉

Home Page:https://www.infracost.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extension cannot index newly generated project in an existing workspace

hugorut opened this issue · comments

Consider the following VSCode workspace:

prod/ # terraform project
dev/ # terraform project

If a user adds a further project to this workspace, e.g. stag, then the Infracost extension will not show price code lenses on resources within this project. This occurs because this stag project does not exist in the initial init run. To fix this, we could run a init on every file we cannot associate with a project. However, this would be very slow for a user.

Some initial ideas about how we could handle this without impacting speed:

  1. A naive approach would be to check if the stag folder is at the same level as other detected projects, e.g. dev. We would have to somehow exclude module calls from this.
  2. We could expose a shallow project detection method in the Infracost CLI. Which uses the same method as breakdown but avoids all the block computation and price lookup. This could then be safely called for every unassociated file, as it would be quick to run.