vscode-infracost
vscode-infracost copied to clipboard
Extension cannot index newly generated project in an existing workspace
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:
- 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. - 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.