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

feat(billingbudget): support project level recicipients on budgets #10926

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
17 changes: 17 additions & 0 deletions mmv1/products/billingbudget/Budget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ examples:
channel_name: 'Example Notification Channel'
test_env_vars:
billing_acct: :MASTER_BILLING_ACCT
- !ruby/object:Provider::Terraform::Examples
name: 'billing_budget_notify_project_recipient'
primary_resource_id: 'budget'
vars:
budget_name: 'Example Billing Budget'
test_env_vars:
billing_acct: :MASTER_BILLING_ACCT
- !ruby/object:Provider::Terraform::Examples
name: 'billing_budget_customperiod'
primary_resource_id: 'budget'
Expand Down Expand Up @@ -440,6 +447,7 @@ properties:
- 'notificationsRule.schemaVersion'
- 'notificationsRule.monitoringNotificationChannels'
- 'notificationsRule.disableDefaultIamRecipients'
- 'notificationsRule.enableProjectLevelRecipients'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

properties:
- !ruby/object:Api::Type::String
name: pubsubTopic
Expand Down Expand Up @@ -479,6 +487,15 @@ properties:
when a threshold is exceeded. Default recipients are
those with Billing Account Administrators and Billing
Account Users IAM roles for the target account.
- !ruby/object:Api::Type::Boolean
name: enableProjectLevelRecipients
default_value: false
description: |
When set to true, and when the budget has a single project configured,
notifications will be sent to project level recipients of that project.
This field will be ignored if the budget has multiple or no project configured.

Currently, project level recipients are the users with Owner role on a cloud project.
- !ruby/object:Api::Type::Enum
name: ownershipScope
description: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
data "google_billing_account" "account" {
billing_account = "<%= ctx[:test_env_vars]['billing_acct'] -%>"
}

data "google_project" "project" {
}

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

budget_filter {
projects = ["projects/${data.google_project.project.number}"]
}

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

all_updates_rule {
monitoring_notification_channels = []
enable_project_level_recipients = true
}
}