Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quota_manager doesn't support dimensions map argument #665

Closed
vrvaderom opened this issue Dec 14, 2021 · 1 comment · Fixed by #683
Closed

quota_manager doesn't support dimensions map argument #665

vrvaderom opened this issue Dec 14, 2021 · 1 comment · Fixed by #683
Labels
enhancement New feature or request P2 high priority issues triaged Scoped and ready for work

Comments

@vrvaderom
Copy link

vrvaderom commented Dec 14, 2021

TL;DR

The terraform resource google_service_usage_consumer_quota_override provides a dimensions map argument that allows configuring the quota to a subset of the available dimensions (for example, specific regions)

The quota manager does not expose this argument, and therefore does not allow setting specific dimentions of a quota override

Terraform Resources

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_usage_consumer_quota_override

Detailed design

The terraform resource for service_usage_consumer_quota_override defaults to no-dimension when the dimensions object argument is empty. 

variables.tf

variable "consumer_quotas" {
  description = "The quotas configuration you want to override for the project."
  type = list(object({
    service = string,
    metric  = string,
    dimensions = object({}),
    limit   = string,
    value   = string,
  }))
}

main.tf

locals {
  consumer_quotas = { for index, quota in var.consumer_quotas : "${quota.service}-${quota.metric}" => quota }
}

resource "google_service_usage_consumer_quota_override" "override" {
  provider = google-beta
  for_each = local.consumer_quotas

  project        = var.project_id
  service        = each.value.service
  metric         = each.value.metric
  limit          = each.value.limit
  dimensions     = each.value.dimensions
  override_value = each.value.value
  force          = true
}

Additional information

This will break backwards compatibility, unless used together with
terraform { experiments = [module_variable_optional_attrs] }

and defined thus -

variable "consumer_quotas" {
  description = "The quotas configuration you want to override for the project."
  type = list(object({
    service = string,
    metric  = string,
    dimensions = optional(object({})),
    limit   = string,
    value   = string,
  }))
}

However, optional arguments are an experimental feature of terraform which cannot be relied upon as of this moment, so it's a risky move.

@vrvaderom vrvaderom added the enhancement New feature or request label Dec 14, 2021
@morgante
Copy link
Contributor

We'd be happy to look at a PR adding this. It can be included in the next breaking release.

@morgante morgante added P2 high priority issues triaged Scoped and ready for work labels Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P2 high priority issues triaged Scoped and ready for work
Projects
None yet
2 participants