Hi everyone, does anyone know how infracost add va...
# general
p
Hi everyone, does anyone know how infracost add var file ?
l
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
thank you, how about I have multiple file
l
You can repeat that flag, e.g.
infracost breakdown --path=. --terraform-var-file=myvars1.tfvar --terraform-var-file=myvars2.tfvar
p
message has been deleted
I used infracost.yml
infracost breakdown --config-file infracost.yml
is my file correctly ?
l
👍 looks like that should work
p
message has been deleted
this is my project structure
but it still does not recognize file
message has been deleted
l
hmm, odd… are there any more details if you run with
--log-level=debug
?
p
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
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
ah, my bad I searched but didn't find it
thank you very much
l
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
I will 😄
🙌 1
l
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
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
Interesting, what does your
.terraform/modules/modules.json
file show?