Title
#general
g

Gurpal Singh

09/09/2022, 1:47 PM
running
infracost breakdown
locally with my terragrunt file, but it seems to be pulling prices for us-east-1 rather than the region i'm actually using, is this expected?
Tim (Infracost)

Tim (Infracost)

09/09/2022, 2:04 PM
we fallback to
us-east-1
if we can’t detect the region for some reason.
g

Gurpal Singh

09/09/2022, 2:11 PM
how do you detect the region? AWS_REGION and AWS_DEFAULT_REGION are both set in my shell
Tim (Infracost)

Tim (Infracost)

09/09/2022, 3:00 PM
We check if the region is set on the resource, then on the provider block, then use the default. There is an open issue with a proposal to change the default region with env variables. It would be good for you to 👍 that, that’s our way of gauging community interest
g

Gurpal Singh

09/09/2022, 3:07 PM
commented: we have an .envrc file that sets the AWS_REGION, based on the directory. it would be good if there was an option that looked for this AWS_REGION or AWS_DEFAULT_REGION value when determining the region.
4:57 PM
in a parent terragrunt file in path:
aws/accounts/nonprod/terragrunt.hcl
we have
generate "provider" {
  path      = "<http://provider.tf|provider.tf>"
  if_exists = "skip"

  contents = <<EOF
provider "aws" {
  assume_role {
    role_arn = "arn:aws:iam::${get_env("TF_VAR_account_id", "")}:role/redacted"
  }
  region = "${get_env("AWS_DEFAULT_REGION","")}"
  default_tags {
    tags = local.common_tags
  }
}
EOF
}
in the shell
AWS_DEFAULT_REGION=eu-west-1
but infracost still uses us-east-1 prices when running
infracost breakdown --path .
in the child hcl files directory:
aws/accounts/nonprod/eu-west-1/dev/eks/terragrunt.hcl
even hardcoding
region
to
eu-west-1
in the generate block doesn't work. infracost still uses us-east-1 prices.
Tim (Infracost)

Tim (Infracost)

09/09/2022, 5:09 PM
As work around maybe look at the steps here. The basic idea is to use terragrunt to generate plan jsons and pass them to infracost to get the estimates.