terraform-google-modules / terraform-google-project-factory

Creates an opinionated Google Cloud project by using Shared VPC, IAM, and Google Cloud APIs
https://registry.terraform.io/modules/terraform-google-modules/project-factory/google
Apache License 2.0
837 stars 539 forks source link

Budget module triggers update in-place and 400 error #537

Closed chiokejjones closed 3 years ago

chiokejjones commented 3 years ago

Community Note

Terraform Version

0.13.5

Affected Resource(s)

terraform-google-modules/project-factory/google//modules/budget

Terraform Configuration Files

module "budget" {
  source                 = "terraform-google-modules/project-factory/google//modules/budget"
  version                = "~> 9.2"
  billing_account        = var.billing_account_id
  projects               = [module.project_factory.project_number]
  display_name           = "${module.project_factory.project_name}-budget-${var.billing_budget}"
  amount                 = var.billing_budget
  alert_spent_percents   = var.billing_thresholds
  credit_types_treatment = var.billing_include_credits ? "INCLUDE_ALL_CREDITS" : "EXCLUDE_ALL_CREDITS"
  alert_pubsub_topic     = var.consumer_org_name == "org_name" ? local.backup_budget_topic : local.prod_budget_topic
}

Debug Output

Panic Output

Expected Behavior

There should be no changes to the billing resources.

Actual Behavior

Plan wants to add all_upates_rule and remove currency_code. Neither of which are set in the module or are available parameters.

# module.budget.google_billing_budget.budget[0] will be updated in-place
  ~ resource "google_billing_budget" "budget" {
        billing_account = "<some_numbers>"
        display_name    = "chioke-budget-500"
        id              = "billingAccounts/<some_numbers>/budgets/<some_numbers>"
        name            = "billingAccounts/<some_numbers>/budgets/<some_numbers>"

      + all_updates_rule {
          + disable_default_iam_recipients   = false
          + monitoring_notification_channels = []
          + schema_version                   = "1.0"
        }

      ~ amount {
            last_period_amount = false

          ~ specified_amount {
              - currency_code = "USD" -> null
                nanos         = 0
                units         = "500"
            }
        }

        budget_filter {
            credit_types           = []
            credit_types_treatment = "EXCLUDE_ALL_CREDITS"
            labels                 = {}
            projects               = [
                "projects/<some_numbers>",
            ]
            services               = []
            subaccounts            = []
        }

        threshold_rules {
            spend_basis       = "CURRENT_SPEND"
            threshold_percent = 0.5
        }
        threshold_rules {
            spend_basis       = "CURRENT_SPEND"
            threshold_percent = 0.75
        }
        threshold_rules {
            spend_basis       = "CURRENT_SPEND"
            threshold_percent = 0.9
        }
        threshold_rules {
            spend_basis       = "CURRENT_SPEND"
            threshold_percent = 1
        }
    }

TF run errors with:

Error: Error updating Budget "billingAccounts/<some-numbers>/budgets/<some-numbers>": googleapi: Error 400: Request contains an invalid argument.

Steps to Reproduce

  1. terraform plan
  2. See update in place for google_billing_budget
  3. terraform apply
  4. Fails with above error.

Important Factoids

References

morgante commented 3 years ago

This looks like a provider issue. Tracking there: https://github.com/hashicorp/terraform-provider-google/issues/8228