Title
#general
Hugo (Infracost)

Hugo (Infracost)

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

Vitale Mazo

09/15/2022, 6:52 PM
Heya
Hugo (Infracost)

Hugo (Infracost)

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

Vitale Mazo

09/15/2022, 6:54 PM
all my root code is in subdirectories
Hugo (Infracost)

Hugo (Infracost)

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

Vitale Mazo

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

Hugo (Infracost)

09/15/2022, 6:55 PM
In this case I’d recommend using a config file
6:55 PM
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
6:55 PM
and the link to the infracost docs https://www.infracost.io/docs/features/config_file/
6:56 PM
which describes the config file in more detail
6:56 PM
but essentially you’ll need to define a list of projects in that file and pass it to infracost
6:56 PM
e.g:
v

Vitale Mazo

09/15/2022, 6:56 PM
can I add wildcard
6:56 PM
TF_ROOT: XYZ/ABC/*
Hugo (Infracost)

Hugo (Infracost)

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:
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
v

Vitale Mazo

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

Hugo (Infracost)

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)
v

Vitale Mazo

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