Skip to content

Conversation

@rtb-major
Copy link

This is a breaking change as it changes the way TF sees it's resources.

The reason of this change is simple, currently when you create a config of consumer_quotas like this:

    {
      service = "bigquery.googleapis.com"
      metric  = urlencode("bigquery.googleapis.com/quota/query/usage")
      limit   = urlencode("/d/project")
      dimensions = {}
      value = "100000"
    },    {
      service = "bigquery.googleapis.com"
      metric  = urlencode("bigquery.googleapis.com/quota/query/usage")
      limit   = urlencode("/d/project/user")
      dimensions = {}
      value = "100000"
    }
    ]

So you want to override quota both for project and project/user limit, then after you run terrafrom plan you get an error:

  │ Error: Duplicate object key
  │ 
  │   on .terraform/modules/projects/modules/quota_manager/main.tf line 18, in locals:
  │   18:   consumer_quotas = { for index, quota in var.consumer_quotas : "${quota.service}-${quota.metric}" => quota }
  │     ├────────────────
  │     │ quota.metric is "bigquery.googleapis.com%2Fquota%2Fquery%2Fusage"
  │     │ quota.service is "bigquery.googleapis.com"
  │ 
  │ Two different items produced the key
  │ "bigquery.googleapis.com-bigquery.googleapis.com%2Fquota%2Fquery%2Fusage"
  │ in this 'for' expression. If duplicates are expected, use the ellipsis
  │ (...) after the value expression to enable grouping by key.

This change fixes this issue and potentially other similar when you want to set up different limit for same quota/metric.

Proposed change is to change variable name from "quota-metric" value to "metric-limit" not for "qouta-metric-limit" as metric always consists of quota value plus quota name, ie:
quota = "bigquery.googleapis.com"
metric = "bigquery.googleapis.com%2Fquota%2Fquery%2Fusage"

@rtb-major rtb-major requested review from a team and imrannayer as code owners October 27, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant