hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.34k stars 1.74k forks source link

Can't set disable_default_iam_recipients to true if monitoring_notification_channels are not set or threshold_rules are set #17808

Open krisztiansala opened 7 months ago

krisztiansala commented 7 months ago

Community Note

Terraform Version

1.6.3

Affected Resource(s)

google_billing_budget

Terraform Configuration

resource "google_billing_budget" "budget" {
  billing_account = var.billing_account
  display_name    = "Billing Budget ${var.project_id}"

  budget_filter {
    projects = ["projects/${var.project_number}"]
  }

  amount {
    specified_amount {
      currency_code = var.currency
      units         = var.amount
    }
  }

  threshold_rules {
    threshold_percent = 1.0
    spend_basis       = "FORECASTED_SPEND"
  }

  all_updates_rule {
    disable_default_iam_recipients   = true
    pubsub_topic                     = var.pubsub_topic
  }
}

Debug Output

Error updating Budget "billingAccounts/123/budgets/12345": googleapi: Error 400: Request contains an invalid argument.

Expected Behavior

We should be able to set disable_default_iam_recipients as true in all cases.

Actual Behavior

If I mark disable_default_iam_recipients as true, when the monitoring_notification_channels are not set (only pubsub), or when threshold_rules are set (which is normal), we get that generic "Request contains an invalid argument" error.

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

No response

b/335295571

melinath commented 6 months ago

I can reproduce this with the following config:

Reproduction config ```hcl data "google_project" "project" { } resource "google_pubsub_topic" "example" { name = "example-topic" labels = { foo = "bar" } message_retention_duration = "86600s" } resource "google_billing_budget" "budget" { billing_account = data.google_project.project.billing_account display_name = "Billing Budget Test" budget_filter { projects = ["projects/${data.google_project.project.number}"] } amount { specified_amount { currency_code = "USD" units = "100000" } } threshold_rules { threshold_percent = 1.0 spend_basis = "FORECASTED_SPEND" } all_updates_rule { disable_default_iam_recipients = true pubsub_topic = google_pubsub_topic.example.id } } ```

Removing the all_updates_rule block allows the config to be applied successfully.