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

Promote Billing Budgets to GA #4273

Merged
Merged
Show file tree
Hide file tree
Changes from 8 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
40 changes: 33 additions & 7 deletions products/billingbudget/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ name: Billing
display_name: Cloud Billing
versions:
- !ruby/object:Api::Product::Version
name: beta
base_url: https://billingbudgets.googleapis.com/v1beta1/
name: ga
base_url: https://billingbudgets.googleapis.com/v1/
scopes:
- https://www.googleapis.com/auth/cloud-platform
apis_required:
Expand Down Expand Up @@ -96,6 +96,7 @@ objects:
values:
- :INCLUDE_ALL_CREDITS
- :EXCLUDE_ALL_CREDITS
- :INCLUDE_SPECIFIED_CREDITS
- !ruby/object:Api::Type::Array
name: services
description: |
Expand All @@ -106,6 +107,31 @@ objects:
through the Catalog API:
https://cloud.google.com/billing/v1/how-tos/catalog-api.
item_type: Api::Type::String
- !ruby/object:Api::Type::Array
name: creditTypes
description: |
A set of subaccounts of the form billingAccounts/{account_id},
specifying that usage from only this set of subaccounts should
be included in the budget. If a subaccount is set to the name of
the parent account, usage from the parent account will be included.
If the field is omitted, the report will include usage from the parent
account and all subaccounts, if they exist.
item_type: Api::Type::String
- !ruby/object:Api::Type::Array
name: subaccounts
description: |
A set of subaccounts of the form billingAccounts/{account_id},
specifying that usage from only this set of subaccounts should
be included in the budget. If a subaccount is set to the name of
the parent account, usage from the parent account will be included.
If the field is omitted, the report will include usage from the parent
account and all subaccounts, if they exist.
item_type: Api::Type::String
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
description: |
A single label and value pair specifying that usage from only
this set of labeled resources should be included in the budget.
- !ruby/object:Api::Type::NestedObject
name: amount
required: true
Expand Down Expand Up @@ -177,7 +203,7 @@ objects:
- :CURRENT_SPEND
- :FORECASTED_SPEND
- !ruby/object:Api::Type::NestedObject
name: allUpdatesRule
rileykarson marked this conversation as resolved.
Show resolved Hide resolved
name: notificationsRule
description: |
Defines notifications that are sent on every update to the
billing account's spend, regardless of the thresholds defined
Expand All @@ -186,8 +212,8 @@ objects:
- !ruby/object:Api::Type::String
name: pubsubTopic
at_least_one_of:
- budget.0.all_updates_rule.0.pubsub_topic
- budget.0.all_updates_rule.0.monitoring_notification_channels
- budget.0.notifications_rule.0.pubsub_topic
- budget.0.notifications_rule.0.monitoring_notification_channels
description: |
The name of the Cloud Pub/Sub topic where budget related
messages will be published, in the form
Expand All @@ -203,8 +229,8 @@ objects:
- !ruby/object:Api::Type::Array
name: monitoringNotificationChannels
at_least_one_of:
- budget.0.all_updates_rule.0.pubsub_topic
- budget.0.all_updates_rule.0.monitoring_notification_channels
- budget.0.notifications_rule.0.pubsub_topic
- budget.0.notifications_rule.0.monitoring_notification_channels
description: |
The full resource name of a monitoring notification
channel in the form
Expand Down
8 changes: 8 additions & 0 deletions products/billingbudget/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
--- !ruby/object:Provider::Terraform::Config
overrides: !ruby/object:Overrides::ResourceOverrides
Budget: !ruby/object:Overrides::Terraform::ResourceOverride
docs: !ruby/object:Provider::Terraform::Docs
warning: |
If you are using User ADCs (Application Default Credentials) with this resource,
you must specify a `billing_project` and set `user_project_override` to true
in the provider configuration. Otherwise the Billing Budgets API will return a 403 error.
Your account must have the `serviceusage.services.use` permission on the
`billing_project` you defined.
id_format: '{{name}}'
import_format: ['{{name}}']
examples:
Expand Down Expand Up @@ -56,6 +63,7 @@ overrides: !ruby/object:Overrides::ResourceOverrides
custom_code: !ruby/object:Provider::Terraform::CustomCode
custom_import: templates/terraform/custom_import/self_link_as_name.erb
post_create: templates/terraform/post_create/set_computed_name.erb
extra_schema_entry: templates/terraform/extra_schema_entry/billing_budget.erb
properties:
budget: !ruby/object:Overrides::Terraform::PropertyOverride
flatten_object: true
Expand Down
2 changes: 1 addition & 1 deletion templates/terraform/examples/billing_budget_notify.tf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ resource "google_billing_budget" "<%= ctx[:primary_resource_id] %>" {
spend_basis = "FORECASTED_SPEND"
}

all_updates_rule {
notifications_rule {
monitoring_notification_channels = [
google_monitoring_notification_channel.notification_channel.id,
]
Expand Down
55 changes: 55 additions & 0 deletions templates/terraform/extra_schema_entry/billing_budget.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"all_updates_rule": {
Type: schema.TypeList,
Optional: true,
Deprecated: `The parent field has been renamed by Google to notifications_rule and you must set the correct field.`,
Description: `Defines notifications that are sent on every update to the
billing account's spend, regardless of the thresholds defined
using threshold rules.`,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"disable_default_iam_recipients": {
Type: schema.TypeBool,
Optional: true,
Deprecated: `The parent field has been renamed by Google to notifications_rule and you must set the correct parent field.`,
Description: `Boolean. When set to true, disables default notifications sent
when a threshold is exceeded. Default recipients are
those with Billing Account Administrators and Billing
Account Users IAM roles for the target account.`,
Default: false,
},
"monitoring_notification_channels": {
Type: schema.TypeList,
Optional: true,
Deprecated: `The parent field has been renamed by Google to notifications_rule and you must set the correct parent field.`,
Description: `The full resource name of a monitoring notification
channel in the form
projects/{project_id}/notificationChannels/{channel_id}.
A maximum of 5 channels are allowed.`,
Elem: &schema.Schema{
Type: schema.TypeString,
},
AtLeastOneOf: []string{"all_updates_rule.0.pubsub_topic", "all_updates_rule.0.monitoring_notification_channels"},
},
"pubsub_topic": {
Type: schema.TypeString,
Optional: true,
Deprecated: `The parent field has been renamed by Google to notifications_rule and you must set the correct parent field.`,
Description: `The name of the Cloud Pub/Sub topic where budget related
messages will be published, in the form
projects/{project_id}/topics/{topic_id}. Updates are sent
at regular intervals to the topic.`,
AtLeastOneOf: []string{"all_updates_rule.0.pubsub_topic", "all_updates_rule.0.monitoring_notification_channels"},
},
"schema_version": {
Type: schema.TypeString,
Optional: true,
Deprecated: `The parent field has been renamed by Google to notifications_rule and you must set the correct parent field.`,
Description: `The schema version of the notification. Only "1.0" is
accepted. It represents the JSON schema as defined in
https://cloud.google.com/billing/docs/how-to/budgets#notification_format.`,
Default: "1.0",
},
},
},
},