https://infracost.io logo
#general
Title
# general
m

mysterious-teacher-68276

09/15/2022, 6:52 PM
hey vitale 👋
m

mammoth-accountant-5963

09/15/2022, 6:52 PM
Heya
m

mysterious-teacher-68276

09/15/2022, 6:53 PM
the
TF_ROOT
variable needs to point to the directory that contains your terraform root module
m

mammoth-accountant-5963

09/15/2022, 6:54 PM
all my root code is in subdirectories
m

mysterious-teacher-68276

09/15/2022, 6:54 PM
so I’m assuming these are different Terraform projects & not sub modules?
m

mammoth-accountant-5963

09/15/2022, 6:54 PM
correct
inside azure we have multiple projects
same for cloudflare etc...
m

mysterious-teacher-68276

09/15/2022, 6:55 PM
In this case I’d recommend using a config file
here’s a link to the github actions example which uses a config file: https://github.com/infracost/actions/tree/master/examples/multi-project-config-file
and the link to the infracost docs https://www.infracost.io/docs/features/config_file/
which describes the config file in more detail
but essentially you’ll need to define a list of projects in that file and pass it to infracost
e.g:
m

mammoth-accountant-5963

09/15/2022, 6:56 PM
can I add wildcard
TF_ROOT: XYZ/ABC/*
m

mysterious-teacher-68276

09/15/2022, 6:59 PM
With a config file you cannot add a wild card, you’ll need to specify each project as such:
Copy code
version: 0.1

projects:
  - path: azure/project-1
  - path: azure/project-2
Infracost does support auto-detection, which means you’d just pass
ci-infra/path-to/env
without the
*
. But autodetection doesn’t support more fine grained configuration you’d get with a config file. So i’d recommend setting up that
m

mammoth-accountant-5963

09/15/2022, 7:10 PM
So I have a monorepo that has many workspaces
the issue is my workspaces are based on project names and not just dev,ts, prod
so the versions file would be tedious to manage
this is what the hierarchy looks like
m

mysterious-teacher-68276

09/15/2022, 7:18 PM
so do each of these sub folders have all the contained information to run as an individual terraform project (e.g. all required vars)
m

mammoth-accountant-5963

09/15/2022, 7:18 PM
some do some go deeper