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

polite-art-38360

06/07/2022, 11:37 AM
Hi everyone, does anyone know how infracost add var file ?
l

little-author-61621

06/07/2022, 11:39 AM
Hi, you should be able to pass a
--terraform-var-file=myvars.tfvar
flag to the
infracost breakdown
or
infracost diff
command. Does that work for you?
p

polite-art-38360

06/07/2022, 11:44 AM
thank you, how about I have multiple file
l

little-author-61621

06/07/2022, 11:46 AM
You can repeat that flag, e.g.
infracost breakdown --path=. --terraform-var-file=myvars1.tfvar --terraform-var-file=myvars2.tfvar
p

polite-art-38360

06/07/2022, 11:47 AM
message has been deleted
I used infracost.yml
infracost breakdown --config-file infracost.yml
is my file correctly ?
l

little-author-61621

06/07/2022, 11:47 AM
👍 looks like that should work
p

polite-art-38360

06/07/2022, 11:48 AM
message has been deleted
this is my project structure
but it still does not recognize file
message has been deleted
l

little-author-61621

06/07/2022, 11:52 AM
hmm, odd… are there any more details if you run with
--log-level=debug
?
p

polite-art-38360

06/07/2022, 11:59 AM
I saw it
seem like it does not understand some git ssh module
time="2022-06-07T185734+07:00" level=warning parser=terraform_hcl msg="Failed to load module err: missing module with source 'registry.terraform.io/git@git.company.org:cost_be/terraform-core-modules/api-gateway.git?ref=1.0.2 git@git.company.org:cost_be/terraform-core-modules/api-gateway.git?ref=1.0.2' - try to 'terraform init' first" time="2022-06-07T185734+07:00" level=warning parser=terraform_hcl msg="Failed to load module err: missing module with source 'registry.terraform.io/../cognito ../cognito' - try to 'terraform init' first"
l

little-author-61621

06/07/2022, 12:03 PM
Thanks, that looks similar to the issue that was just reported here: https://github.com/infracost/infracost/issues/1730. We’ll try and get a patch in for the next version sometime this week. In the meantime you can run Infracost with the
--terraform-force-cli
flag as a workaround which runs it in the old way by calling out to the Terraform/Terragrunt binary.
p

polite-art-38360

06/07/2022, 12:04 PM
ah, my bad I searched but didn't find it
thank you very much
l

little-author-61621

06/07/2022, 12:04 PM
No worries, I’ll reach back out to you when the issue is fixed. Let me know if you have any more issues.
1
p

polite-art-38360

06/07/2022, 12:06 PM
I will 😄
🙌 1
l

little-author-61621

06/07/2022, 1:18 PM
I’ve got a potential fix in https://github.com/infracost/infracost/pull/1731, but another workaround for just now might just be changing the
source
attribute in your HCL module block to match whatever Terraform has written out as the source for that module in the
.terraform/modules/modules.json
file.
p

polite-art-38360

06/07/2022, 2:28 PM
thank you, with flag --terraform-force-cli, I got the estimation of my project 😄
🙌 1
currently my format for module git is "git@git.company.org:cost_be/terraform-core-modules/api-gateway.git"
when I tried to change to "git::ssh://git@git.company.org:cost_be/terraform-core-modules/api-gateway.git"
I got the error
so I think it doesn't work for my case as well
l

little-author-61621

06/07/2022, 2:59 PM
Interesting, what does your
.terraform/modules/modules.json
file show?
12 Views