running `infracost breakdown` locally with my terr...
# general
w
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?
c
we fallback to
us-east-1
if we can’t detect the region for some reason.
w
how do you detect the region? AWS_REGION and AWS_DEFAULT_REGION are both set in my shell
c
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
w
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.
in a parent terragrunt file in path:
aws/accounts/nonprod/terragrunt.hcl
we have
Copy code
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.
c
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.