Can I configure a different path for the top-level...
# help
c
Can I configure a different path for the top-level / TF root-level (working)
.infracost
directory?
w
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
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
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
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
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
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.