Skip to content

Commit

Permalink
Made google_billing_budget.all_updates_rule subfields get updated (ha…
Browse files Browse the repository at this point in the history
…shicorp#4933)

This is a follow-up for GoogleCloudPlatform/magic-modules#4929, which fixed this issue for `amount` and its subfields

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Jun 30, 2021
1 parent 1c4c8c6 commit 5c01d0f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/4933.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
billing: made `all_updates_rule.*` fields updatable on `google_billing_budget`
```
5 changes: 4 additions & 1 deletion google/resource_billing_budget.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 33 additions & 2 deletions google/resource_billing_budget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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}"
}
Expand Down Expand Up @@ -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}"
}
Expand Down Expand Up @@ -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}"
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 5c01d0f

Please sign in to comment.