Hi everyone, Before I jump into opening an issue,...
# general
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
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
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
to infracost.
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
The storage one looks like a bug. It looks like passing
as the attribute value now uses v2 by default so we need to update this in Infracost.
it's not setup as storage
apologies my fault 😐
Ah, ok. I'm seeing updates to the terraform docs for that so it looks like we should update something.
I'll update it on my side to Storage V2
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.
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
Awesome thanks 🙏. Yeah annotations is a good idea.
yep java and c# use them and it would not interfere at all with terraform way of working
@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?
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
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