https://infracost.io logo
#contributors
Title
# contributors
d

damp-ambulance-61372

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)
l

little-author-61621

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

damp-ambulance-61372

07/23/2021, 9:33 AM
@little-author-61621 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
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
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
)
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
.
l

little-author-61621

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.
👍 1
d

damp-ambulance-61372

07/23/2021, 9:59 AM
We should also consider this behavior (having both wildcard and resource) in
--sync-usage-file
logic
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
🙌 1
5 Views