hello! Ive been playing around with using `.Detect...
# help
n
hello! Ive been playing around with using
.DetectedProjects
and
.DetectedRootModules
in my config template file, but there seems to be an implicit max depth for detecting projects. For example if I use this template:
Copy code
projects:
{{- range $project := .DetectedProjects }}
  - path: {{ $project.Path }}
    name: {{ $project.Name }}
{{- end }}
it doesnt detect any projects at
./deploy/terraform/a/b/c/d/e/root.tf
Is there a way to configure the max-depth here?
l
It’s not configurable at the moment and is set to 7 directories. How many directories deep do you have?
n
I think the example I gave is the deepest we go, so 8 i guess? I know the directory structure is not ideal but its what im working with 🤷
Is it possible to only detect projects within a certain directory? I really only care about paths in
./deploy/terraform
so could I do something like
./deploy/terraform/.DetectedProjects
?
l
Where are you running it from? Infracost Cloud, GitHub Actions, CLI, etc?
n
To test locally im running the CLI to generate config files from a template, but ultimately Im going to be running this via github actions
l
Would something like this get round it for just now?
Copy code
infracost generate config --repo-path=deploy/terraform --template-path=infracost.yml.tmpl --out-file=deploy/terraform/infracost.yml

cd deploy/terraform

infracost breakdown --config-file=infracost.yml
n
so that would work from the CLI, but can I do something similar for github actions? I thought the
infracost.yml.tmpl
file has to live at the root of the repo and so the config file would also start looking from the root and not
deploy/terraform
, unless Im misunderstanding
l
It should be fine with GitHub Actions since you can just run the same commands. The template file and generated config can live anywhere as long as you point to it when you’re running the other commands. The thing that won’t work is the GitHub App integration. For that we’d have to add some way of configuring the max depth.
We can look at adding that option as well.
n
oh yea I think I misspoke then. I meant the Github App integration
l
Ah okay, yeah. Let me talk the team. We might be able to squeeze in a quick option to configure it into the next CLI release which should be early next week.
n
that would be amazing, thank you
m
hey @narrow-dinner-45042 support for configuring the max search depth has been released in the 0.10.34 CLI. You can configure the depth with the following config file syntax.
Copy code
version: 0.1
autodetect:
  max_search_depth: 8

projects:
{{- range $project := .DetectedProjects }}
  ...
Please note this feature is in preview and is not publicly documented.
n
thank you! Ill try it out
looks good on the CLI! Does the Github App integration also have these new changes?
m
yes it does
github app always works off master
so we don’t depend on releases
n
hm, I have tried updating my git repo’s
infracost.yml.tmpl
file, but github PR comments still appear to be showing projects from the old config file
I have also tried updating the “Default repo config file” in the infracost website to no avail
m
ok @crooked-daybreak-55253 can look into this for you, what is your github organization id?
n
I dont have a paid infracost cloud plan, so I cant try setting a repo-specific override. I wonder though if theres an override still left from when I had a free trial that I now can no longer change
where do I find my org id?
the Org Id I see on the infracost website is
ede3c7f4-29ec-4890-b187-dada03424add
c
Hi, you were right there is a config template set in the Repos->Settings tab. I’ve extended your trial by a week so you can go in and clear that out. I’m also adding a ticket so we can decide how to handle that in the future (either ignore the repo config template or let people access them?). Thanks for your patience!
n
nice! thank you. Ill go in and clear that and test PR comments again
ok great PR comments look good now
thank you again
@little-author-61621 @mysterious-teacher-68276 sorry to resurrect an old thread, but I have a followup question. Does using
.DetectedProjects
in my config file have any affect on the number of CI/CD runs counted for my Github App integration? Weve noticed a spike in our infracost usage in the month of March, and Im trying to understand the root cause. Im wondering if using
.DetectedProjects
had an affect here? Like infracost now has to figure out the projects on its own, so every PR run counts regardless of if there are terraform changes?
l
@narrow-dinner-45042
.DetectedProjects
shouldn’t have an effect, but every PR run will count.
n
every PR run will count.
Does this include PRs that have no terraform changes? If so, is that a change in behavior? I cant refer back to it now because the slack messages are gone, but I was previously told that runs on PRs with no tf changes do not count towards the monthly limit
l
If you have this setting enabled then we don’t do runs for non-terraform changes, so they don’t count.
Copy code
Only post a comment in pull requests that have Terraform changes (recommended)
I remember from before that I think you have this turned on.
n
Yea I can confirm we still have that setting enabled
Hmm ok, so it seems our increase in runs is due to some other reason
Ill keep digging around, thanks!
if two projects are changed in a given PR, and infracost posts a comment with the cost differences for each of the projects, does that count as 1 infracost run or 2?
l
Hi @narrow-dinner-45042 a PR has 2 runs, one for the breakdown of the main branch and then one for the diff from the PR branch. It doesn’t matter how many projects are in the repo, they will count as the same run.