https://infracost.io logo
#help
Title
# help
c

cuddly-analyst-30573

01/26/2023, 8:43 PM
Can I configure a different path for the top-level / TF root-level (working)
.infracost
directory?
w

white-airport-8778

01/26/2023, 9:02 PM
Not just now, what’s the use-case/problem you’re trying to solve? We use to have that in each sub-dir/project but moved it to the top level as an optimization to avoid re-downloading modules for each folder in mono repos
c

cuddly-analyst-30573

01/26/2023, 9:50 PM
Not really necessary; mostly just because we have multiple
.terraform
folders (
TF_DATA_DIR
) with the state (and modules...) for each environment.
Is it necessary for Infracost to redownload the modules, instead of using what's in
.terraform
, anyway?
c

crooked-daybreak-55253

01/27/2023, 2:43 AM
Makes sense to me and it looks doable in the code. I think it would be nice to hear @mysterious-teacher-68276’s opinion before you open a github issue.
m

mysterious-teacher-68276

01/27/2023, 6:37 AM
hey @cuddly-analyst-30573, if you have modules already downloaded in your
.terraform
directories we use those and won’t redownload your modules into the top level cache. You might still see the
Downloading Terraform modules
spinner, but we’re not actually downloading the modules again. Are you seeing something different to suggest that we are redownloading? If so, that would be a regression that we’ve introduced, so I’d love to know about it!
c

cuddly-analyst-30573

01/30/2023, 6:57 PM
Nope; I just thought they were redownloading! I was more worried about the duplication of the files / that the existing ones are already copied. Not symlinking is understandable, but I'm not sure how feasible it is to reuse the same modules in
.terraform
while just creating
manifest.json
. Also noticed that sometimes the modules appear twice even in
.infracost
but sometimes the name is some sort of hash, or there're
manifest-hash.json
files, but I haven't really looked into what the engine is doing (maybe it's due to module version changes?). Ideally, I'd want Infracost to look at the modules in
config/$environment/.terraform/modules
. I could try building Infracost from source with the
downloadDir
changed, but I'd probably need to make a few more changes to make it work as expected.
m

mysterious-teacher-68276

01/30/2023, 7:04 PM
Ok great to hear @cuddly-analyst-30573, thought we might have a bug there. 😮‍💨 . So we’ve chosen to go a different route to Terraform source to deal with module downloading and versioning. This approach is, in general, faster and more suited to Infracost’s use case. So just creating a manifest pointing to Terraform cache directory would be problematic for future functionality. However, if this is something that you really need, then I’d recommend creating a issue in GitHub outlining your reasoning. Then we can triage and see if others in the community want this.
6 Views