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

Made billing budget amount updatable #4929

Merged
merged 2 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions mmv1/products/billingbudget/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
allUpdatesRule.schemaVersion: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: templates/terraform/custom_flatten/default_if_empty.erb
amount: !ruby/object:Overrides::Terraform::PropertyOverride
update_mask_fields:
- "amount.specifiedAmount.currencyCode"
- "amount.specifiedAmount.units"
- "amount.specifiedAmount.nanos"
amount.lastPeriodAmount: !ruby/object:Overrides::Terraform::PropertyOverride
custom_expand: 'templates/terraform/custom_expand/bool_to_object.go.erb'
custom_flatten: 'templates/terraform/custom_flatten/object_to_bool.go.erb'
amount.specifiedAmount.currencyCode: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
budgetFilter.creditTypes: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
budgetFilter: !ruby/object:Overrides::Terraform::PropertyOverride
Expand All @@ -71,11 +81,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
default_from_api: true
budgetFilter.labels: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
amount.lastPeriodAmount: !ruby/object:Overrides::Terraform::PropertyOverride
custom_expand: 'templates/terraform/custom_expand/bool_to_object.go.erb'
custom_flatten: 'templates/terraform/custom_flatten/object_to_bool.go.erb'
amount.specifiedAmount.currencyCode: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true

# This is for copying files over
files: !ruby/object:Provider::Config::Files
Expand Down
53 changes: 48 additions & 5 deletions mmv1/third_party/terraform/tests/resource_billing_budget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "google_billing_budget" "budget" {
`, context)
}

func TestAccBillingBudget_billingBudgetUpdateRemoveFilter(t *testing.T) {
func TestAccBillingBudget_billingBudgetUpdate(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
Expand All @@ -76,15 +76,23 @@ func TestAccBillingBudget_billingBudgetUpdateRemoveFilter(t *testing.T) {
CheckDestroy: testAccCheckBillingBudgetDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccBillingBudget_billingBudgetUpdateRemoveFilterStart(context),
Config: testAccBillingBudget_billingBudgetUpdateStart(context),
},
{
ResourceName: "google_billing_budget.budget",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccBillingBudget_billingBudgetUpdateRemoveFilterEnd(context),
Config: testAccBillingBudget_billingBudgetUpdateRemoveFilter(context),
},
{
ResourceName: "google_billing_budget.budget",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccBillingBudget_billingBudgetUpdateChangeAmount(context),
},
{
ResourceName: "google_billing_budget.budget",
Expand All @@ -95,7 +103,7 @@ func TestAccBillingBudget_billingBudgetUpdateRemoveFilter(t *testing.T) {
})
}

func testAccBillingBudget_billingBudgetUpdateRemoveFilterStart(context map[string]interface{}) string {
func testAccBillingBudget_billingBudgetUpdateStart(context map[string]interface{}) string {
return Nprintf(`
data "google_billing_account" "account" {
billing_account = "%{billing_acct}"
Expand Down Expand Up @@ -130,7 +138,7 @@ resource "google_billing_budget" "budget" {
`, context)
}

func testAccBillingBudget_billingBudgetUpdateRemoveFilterEnd(context map[string]interface{}) string {
func testAccBillingBudget_billingBudgetUpdateRemoveFilter(context map[string]interface{}) string {
return Nprintf(`
data "google_billing_account" "account" {
billing_account = "%{billing_acct}"
Expand Down Expand Up @@ -165,6 +173,41 @@ resource "google_billing_budget" "budget" {
`, context)
}

func testAccBillingBudget_billingBudgetUpdateChangeAmount(context map[string]interface{}) string {
return Nprintf(`
data "google_billing_account" "account" {
billing_account = "%{billing_acct}"
}

data "google_project" "project" {
}

resource "google_billing_budget" "budget" {
billing_account = data.google_billing_account.account.id
display_name = "Example Billing Budget%{random_suffix}"

budget_filter {
projects = []
}

amount {
specified_amount {
currency_code = "USD"
units = "2000"
}
}

threshold_rules {
threshold_percent = 0.5
}
threshold_rules {
threshold_percent = 0.9
spend_basis = "FORECASTED_SPEND"
}
}
`, context)
}

func TestBillingBudgetStateUpgradeV0(t *testing.T) {
t.Parallel()

Expand Down