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

billingbudget: make threshold optional #6259

Merged
merged 1 commit into from
Jul 13, 2022
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
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'] %>"
}