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

ambitious-book-89337

09/27/2022, 10:32 AM
Hi everyone, Before I jump into opening an issue, I will run a case trough you guys. I'm running infracost against some resources that use for_each, meaning, they're indexed by a string. like
azurerm_storage_account.hat_test_reports[\"uksouth\"]
What I'm seeing when running breakdown is something like this:
Copy code
time="2022-09-27T11:24:39+01:00" level=warning msg="Using eastus for resource azurerm_storage_account.hat_function_app[\"ukwest\"] as its 'location' property could not be found."
time="2022-09-27T11:24:39+01:00" level=warning msg="Skipping resource azurerm_storage_account.hat_function_app[\"ukwest\"]. Infracost only supports StorageV2, BlockBlobStorage and FileStorage account kinds"
For the first message, location is there as it's mandatory by terraform for the second message, it's a StorageV2 😮 code in screenshot Worth opening an issue? Running on last infracost version Terraform Core 1.2.9
l

little-author-61621

09/27/2022, 10:35 AM
Hi @ambitious-book-89337. Looking at the code I'm seeing you're using a data resource to retrieve the location. Unfortunately our HCL parsing can't evaluate data resources since they require communicating with the cloud APIs. One thing to try is to generate a plan JSON file and pass that as the
path
to infracost.
a

ambitious-book-89337

09/27/2022, 10:36 AM
Yep that would work, and hat it
but doing that will prevent me from having the costs for all 3 environments and can also lead to remote state file locking when running in the pipeline while devs are testing as well
got your point...
what about the second message?
it's a storage v2, but it's not able to get it
Hmm just saw it
l

little-author-61621

09/27/2022, 10:38 AM
The storage one looks like a bug. It looks like passing
Storage
as the attribute value now uses v2 by default so we need to update this in Infracost.
a

ambitious-book-89337

09/27/2022, 10:39 AM
it's not setup as storage
apologies my fault 😐
l

little-author-61621

09/27/2022, 10:39 AM
Ah, ok. I'm seeing updates to the terraform docs for that so it looks like we should update something.
a

ambitious-book-89337

09/27/2022, 10:40 AM
I'll update it on my side to Storage V2
l

little-author-61621

09/27/2022, 10:43 AM
We have this open discussion: https://github.com/infracost/infracost/issues/1796 I'm not sure the existing suggestions would help you're case since you're looping through regions, but if there's any ideas you have for what we could do then let us know on the issue.
a

ambitious-book-89337

09/27/2022, 10:46 AM
I see, I n my case regions are part of a config variables, a list of regions with properties, and terraform just iterates through them. The reason I'm not using these variables all over the place is to force a correct dependency tree between resources, and hopefully terraform is able to follow that chain, we all know that terraform sometimes does nasty things with dependencies
well for a quick win, in absence of a better way to solve this, having the regions present in usage-file would work for me! That or... using special comments in terraform code dedicated to infracost
kind of code annotations
I've added my suggestions, thanks
l

little-author-61621

09/27/2022, 11:03 AM
Awesome thanks 🙏. Yeah annotations is a good idea.
a

ambitious-book-89337

09/27/2022, 11:04 AM
yep java and c# use them and it would not interfere at all with terraform way of working
w

white-airport-8778

09/27/2022, 4:14 PM
@ambitious-book-89337 I saw your GH comment too, just to be clear the region override would need to be per-resource in the usage-file, right?
a

ambitious-book-89337

09/27/2022, 4:17 PM
in my case, yep, but we could have kind of a parent region at top level of the config, allowing to be overridden at lower levels per resource
w

white-airport-8778

09/27/2022, 4:25 PM
Makes sense - thanks! We’ll see when we get time to work on that, we’re open to receiving community contributions on it too in case people have time to help