Hi, in the infracost.yml file, can we override the...
# help
m
Hi, in the infracost.yml file, can we override the location property per project? To remove the warning
Using eastus for resource module.network.azurerm_virtual_network_peering.vnet_hub_adm as its 'location' property could not be found.
as infracost is not picking up the region
b
Hello! It is possible to set an env var
INFRACOST_AZURE_OVERRIDE_REGION
to override the region, however it will be applied to all resources, not just one. https://www.infracost.io/docs/features/environment_variables/#environment-variables-to-override-cloud-provider-region
m
I had seen that but ideally, want it on a per-project level as we are doing a project = environment.
b
Yeah, you can define this env var in the config for one project in
env
Ah, wait, sorry, I'm wrong. these are global
m
This is what I am trying to do.
Copy code
- path: env
    include_all_paths: true
    name: POD - CASH - SG
    env:
      INFRACOST_AZURE_OVERRIDE_REGION: southeastasia
    terraform_vars:
      environment: cash
      geo: sg
      purpose: devqa

  - path: env
    include_all_paths: true
    name: POD - DELP - US
    env:
      INFRACOST_AZURE_OVERRIDE_REGION: centralus
    terraform_vars:
      environment: delp
      geo: us
      purpose: devqa
b
Unfortunately, this won't work per project, all
INFRACOST_
env vars are global
Is
virtual_network_name
defined on the resource?
I wonder why Infracost doesn't pick up the value
m
We are doing this with our variables:
Copy code
locals {
  settings = local.regions[var.geo]
  regions = {

    ## AE
    ## -----------------------------
    "ae" = {
      primary_region = {
        name     = "ae1"
        location = "uaenorth"
      }
      secondary_region = {
        name     = "ae2"
        location = "uaecentral"
      }
and then passing that into the various modules
region      = local.settings.primary_region.name
b
I see. Is it possible to share some of this code with us (in DM), so we can try to reproduce the issue?
w
@millions-plumber-38090 I googled this but couldn’t find a way so asking in case you know… Azure’s CLI or the TF Azure provider doesn’t have an equivalent of the
AWS_REGION
env variable that is also read by Terraform, right? AWS users can set AWS_REGION on a per-project basis in their Infracost config file, and since our CLI passes those env vars to the parser, that works ok for them.