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: expose spend_basis for budget alerts #681

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ determining that location is as follows:
| bucket\_ula | Enable Uniform Bucket Level Access | `bool` | `true` | no |
| bucket\_versioning | Enable versioning for a GCS bucket to create (optional) | `bool` | `false` | no |
| budget\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` | `string` | `null` | no |
| budget\_alert\_spend\_basis | The type of basis used to determine if spend has passed the threshold | `string` | `"CURRENT_SPEND"` | no |
| budget\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded | `list(number)` | <pre>[<br> 0.5,<br> 0.7,<br> 1<br>]</pre> | no |
| budget\_amount | The amount to use for a budget alert | `number` | `null` | no |
| budget\_display\_name | The display name of the budget. If not set defaults to `Budget For <projects[0]|All Projects>` | `string` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ module "budget" {
billing_account = var.billing_account
amount = var.budget_amount
alert_spent_percents = var.budget_alert_spent_percents
alert_spend_basis = var.budget_alert_spend_basis
alert_pubsub_topic = var.budget_alert_pubsub_topic
monitoring_notification_channels = var.budget_monitoring_notification_channels
display_name = var.budget_display_name != null ? var.budget_display_name : null
Expand Down
1 change: 1 addition & 0 deletions modules/budget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module "project_myproject" {
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` | `string` | `null` | no |
| alert\_spend\_basis | The type of basis used to determine if spend has passed the threshold | `string` | `"CURRENT_SPEND"` | no |
| alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded | `list(number)` | <pre>[<br> 0.5,<br> 0.7,<br> 1<br>]</pre> | no |
| amount | The amount to use as the budget | `number` | n/a | yes |
| billing\_account | ID of the billing account to set a budget on | `string` | n/a | yes |
Expand Down
1 change: 1 addition & 0 deletions modules/budget/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ resource "google_billing_budget" "budget" {
for_each = var.alert_spent_percents
content {
threshold_percent = threshold_rules.value
spend_basis = var.alert_spend_basis
}
}

Expand Down
6 changes: 6 additions & 0 deletions modules/budget/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ variable "alert_spent_percents" {
default = [0.5, 0.7, 1.0]
}

variable "alert_spend_basis" {
description = "The type of basis used to determine if spend has passed the threshold"
type = string
default = "CURRENT_SPEND"
}

variable "alert_pubsub_topic" {
description = "The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}`"
type = string
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ variable "budget_alert_spent_percents" {
default = [0.5, 0.7, 1.0]
}

variable "budget_alert_spend_basis" {
description = "The type of basis used to determine if spend has passed the threshold"
type = string
default = "CURRENT_SPEND"
}

variable "budget_labels" {
description = "A single label and value pair specifying that usage from only this set of labeled resources should be included in the budget."
type = map(string)
Expand Down