Skip to content

Commit

Permalink
billingbudget: make threshold optional (GoogleCloudPlatform#6259)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 authored and geojaz committed Jul 21, 2022
1 parent 95c4f34 commit 16cfaca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mmv1/products/billingbudget/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ objects:
use the `specified_amount` block.
- !ruby/object:Api::Type::Array
name: thresholdRules
required: true
description: |
Rules that trigger alerts (notifications of thresholds being
crossed) when spend exceeds the specified percentages of the
Expand Down Expand Up @@ -336,6 +335,7 @@ objects:
https://cloud.google.com/billing/docs/how-to/budgets#notification_format.
- !ruby/object:Api::Type::Array
name: monitoringNotificationChannels
max_size: 5
at_least_one_of:
- all_updates_rule.0.pubsub_topic
- all_updates_rule.0.monitoring_notification_channels
Expand Down
9 changes: 9 additions & 0 deletions mmv1/products/billingbudget/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ overrides: !ruby/object:Overrides::ResourceOverrides
display_name: 'Example Billing Budget'
test_env_vars:
billing_acct: :BILLING_ACCT
- !ruby/object:Provider::Terraform::Examples
name: 'billing_budget_optional'
primary_resource_id: 'budget'
skip_docs: true
vars:
display_name: 'Example Billing Budget'
topic_name: "example-topic"
test_env_vars:
billing_acct: :BILLING_ACCT
properties:
name: !ruby/object:Overrides::Terraform::PropertyOverride
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
Expand Down
24 changes: 24 additions & 0 deletions mmv1/templates/terraform/examples/billing_budget_optional.tf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
data "google_billing_account" "account" {
billing_account = "<%= ctx[:test_env_vars]['billing_acct'] -%>"
}

resource "google_billing_budget" "<%= ctx[:primary_resource_id] %>" {
billing_account = data.google_billing_account.account.id
display_name = "<%= ctx[:vars]['display_name'] %>"

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

all_updates_rule {
disable_default_iam_recipients = true
pubsub_topic = google_pubsub_topic.<%= ctx[:primary_resource_id] %>.id
}
}

resource "google_pubsub_topic" "<%= ctx[:primary_resource_id] %>" {
name = "<%= ctx[:vars]['topic_name'] %>"
}

0 comments on commit 16cfaca

Please sign in to comment.