Title
#contributors
Mohammad Yosefpor

Mohammad Yosefpor

07/22/2021, 6:19 PM
• In documents (https://www.infracost.io/docs/usage_based_resources#resource-arrays) I've seen notes for resource arrays and modules. My question is does the wildcard method also work with
for_each
resources? (it's not clear in docs)
Alistair (Infracost)

Alistair (Infracost)

07/22/2021, 6:22 PM
It should work for
count
and
for_each
. +1 we should clarify this.
Mohammad Yosefpor

Mohammad Yosefpor

07/23/2021, 9:33 AM
@Alistair (Infracost) it seems the wildcard char in usage-file is not working with for_each. (tested with
infracost/example-terraform/sample1
aws_lambda_function.hello_world
9:33 AM
aws_lambda_function.hello_world["hello"] ├─ Requests 0 1M requests $0.00 └─ Duration 0 GB-seconds $0.00 aws_lambda_function.hello_world["hi"] ├─ Requests 0 1M requests $0.00 └─ Duration 0 GB-seconds $0.00
9:35 AM
Oh sorry my bad it is working ok, but the issue is
--sync-usage-file
is destructive when using with wildcards (both for
for_each
and
count
)
9:36 AM
it deletes all the wildcard
aws_lambda_function.hello_world[*]
and replaces them with individual
aws_lambda_function.hello_world["hi"]
and
"hello"
with default value
0
.
Alistair (Infracost)

Alistair (Infracost)

07/23/2021, 9:38 AM
hmmm that's an interesting issue. I guess in that case it should recognise the wildcards and not overwrite them.
Mohammad Yosefpor

Mohammad Yosefpor

07/23/2021, 9:59 AM
We should also consider this behavior (having both wildcard and resource) in
--sync-usage-file
logic
10:57 AM
submitted an issue for
--sync-usage-file
flag behavior: https://github.com/infracost/infracost/issues/875 submitted a PR for clarifying wildcard usage with for_each: https://github.com/infracost/docs/pull/81