Title
#general
c

Christopher Avila

08/30/2022, 2:55 PM
Is there a way to use wildcards with modules that contain usage_based resources? for instance, my resource_usage block previously looked like:
module.developer_vms["eiq-dev-vm-developer-name-standard-1"].google_compute_instance.default[0]:
    monthly_hrs: 258.0 # Monthly number of hours the instance ran for.
about 20 times over. I tried using a wildcard to switch it to
module.developer_vms[*].google_compute_instance.default[0]:
    monthly_hrs: 258.0 # Monthly number of hours the instance ran for.
but it failed to pick up the change and is ignoring the monthly_hrs setting
2:59 PM
Failed to pick up the change as in, now all instances think they are running for the full amount of hours a month
Ali (Infracost)

Ali (Infracost)

08/30/2022, 3:00 PM
Hey @Christopher Avila! Would being able to set a default usage-value for a resource type help? Or would that mess-up the other ones you want to leave as running 730hrs?
google_compute_instance:
  monthly_hrs: 258
3:03 PM
Wildcard support for modules has an open PR from community member @Sina Bakhtiari but it needs some tweaks before it can be merged. So I’m wondering which of these two PRs solves your use-case?
c

Christopher Avila

08/30/2022, 3:33 PM
Wildcard support for modules would be the preferred approach for me because in this case I’m spinning up VMs I can predictably say should only be running during someones shift at work which I estimate out to around 258 hours. However we also run an sftp server at the moment that needs to be running 24/7 so a default wouldn’t necessarily make sense there.
Ali (Infracost)

Ali (Infracost)

08/30/2022, 3:34 PM
great, plz subscribe to that pull request for updates. @Alistair (Infracost) is the work on the module wildcard PR quite major or something we can knock-out in September?
3:35 PM
@Sina Bakhtiari I’m guessing you don’t have time to work on the module wildcard PR?
Alistair (Infracost)

Alistair (Infracost)

08/30/2022, 4:00 PM
I think there’s a lot of edge-cases we need to account for for when module wildcards are used with resource wildcards. My guess is it would take us around day of engineering effort.
s

Sina Bakhtiari

08/30/2022, 9:04 PM
@Ali (Infracost) Yes, I’m mostly busy with migration stuff whenever I find free time. On the other hand, I encountered many edge-cases when I was working on it and if we switch to using the usage schema structs that are defined in the new structure it would change the implementation of this feature as well.