From b46b061972cdcf8a871cc64a36a65ec99650897c Mon Sep 17 00:00:00 2001 From: The Magician Date: Wed, 30 Jun 2021 15:33:43 -0500 Subject: [PATCH] Made google_billing_budget.all_updates_rule subfields get updated (#4933) (#9473) This is a follow-up for https://github.com/GoogleCloudPlatform/magic-modules/pull/4929, which fixed this issue for `amount` and its subfields Signed-off-by: Modular Magician --- .changelog/4933.txt | 3 +++ google/resource_billing_budget.go | 5 +++- google/resource_billing_budget_test.go | 35 ++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .changelog/4933.txt diff --git a/.changelog/4933.txt b/.changelog/4933.txt new file mode 100644 index 00000000000..fe5d0dde99e --- /dev/null +++ b/.changelog/4933.txt @@ -0,0 +1,3 @@ +```release-note:bug +billing: made `all_updates_rule.*` fields updatable on `google_billing_budget` +``` diff --git a/google/resource_billing_budget.go b/google/resource_billing_budget.go index 5510fd58556..c8c04d86e1e 100644 --- a/google/resource_billing_budget.go +++ b/google/resource_billing_budget.go @@ -481,7 +481,10 @@ func resourceBillingBudgetUpdate(d *schema.ResourceData, meta interface{}) error } if d.HasChange("all_updates_rule") { - updateMask = append(updateMask, "notificationsRule") + updateMask = append(updateMask, "notificationsRule.pubsubTopic", + "notificationsRule.schemaVersion", + "notificationsRule.monitoringNotificationChannels", + "notificationsRule.disableDefaultIamRecipients") } // updateMask is a URL parameter but not present in the schema, so replaceVars // won't set it diff --git a/google/resource_billing_budget_test.go b/google/resource_billing_budget_test.go index 12958bbce66..8150216374a 100644 --- a/google/resource_billing_budget_test.go +++ b/google/resource_billing_budget_test.go @@ -92,7 +92,7 @@ func TestAccBillingBudget_billingBudgetUpdate(t *testing.T) { ImportStateVerify: true, }, { - Config: testAccBillingBudget_billingBudgetUpdateChangeAmount(context), + Config: testAccBillingBudget_billingBudgetUpdate(context), }, { ResourceName: "google_billing_budget.budget", @@ -105,6 +105,13 @@ func TestAccBillingBudget_billingBudgetUpdate(t *testing.T) { func testAccBillingBudget_billingBudgetUpdateStart(context map[string]interface{}) string { return Nprintf(` +resource "google_pubsub_topic" "topic1" { + name = "tf-test-billing-budget1-%{random_suffix}" +} +resource "google_pubsub_topic" "topic2" { + name = "tf-test-billing-budget2-%{random_suffix}" +} + data "google_billing_account" "account" { billing_account = "%{billing_acct}" } @@ -134,12 +141,22 @@ resource "google_billing_budget" "budget" { threshold_percent = 0.9 spend_basis = "FORECASTED_SPEND" } + + all_updates_rule { + pubsub_topic = google_pubsub_topic.topic1.id + } } `, context) } func testAccBillingBudget_billingBudgetUpdateRemoveFilter(context map[string]interface{}) string { return Nprintf(` +resource "google_pubsub_topic" "topic1" { + name = "tf-test-billing-budget1-%{random_suffix}" +} +resource "google_pubsub_topic" "topic2" { + name = "tf-test-billing-budget2-%{random_suffix}" +} data "google_billing_account" "account" { billing_account = "%{billing_acct}" } @@ -169,12 +186,22 @@ resource "google_billing_budget" "budget" { threshold_percent = 0.9 spend_basis = "FORECASTED_SPEND" } + + all_updates_rule { + pubsub_topic = google_pubsub_topic.topic1.id + } } `, context) } -func testAccBillingBudget_billingBudgetUpdateChangeAmount(context map[string]interface{}) string { +func testAccBillingBudget_billingBudgetUpdate(context map[string]interface{}) string { return Nprintf(` +resource "google_pubsub_topic" "topic1" { + name = "tf-test-billing-budget1-%{random_suffix}" +} +resource "google_pubsub_topic" "topic2" { + name = "tf-test-billing-budget2-%{random_suffix}" +} data "google_billing_account" "account" { billing_account = "%{billing_acct}" } @@ -204,6 +231,10 @@ resource "google_billing_budget" "budget" { threshold_percent = 0.9 spend_basis = "FORECASTED_SPEND" } + + all_updates_rule { + pubsub_topic = google_pubsub_topic.topic2.id + } } `, context) }