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!: Add support for custom time periods in budget module #738

Merged
merged 9 commits into from
Aug 18, 2022
Prev Previous commit
Next Next commit
Add support for custom time periods in budget module
  • Loading branch information
Abhisek Purwar committed Aug 8, 2022
commit 857b139ea9ce275d62d1b33fb769ed5e39413dbb
2 changes: 1 addition & 1 deletion modules/budget/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module "project_myproject" {
| 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 |
| calendar\_period | Specifies the calendar period for the budget. Possible values are MONTH, QUARTER, YEAR, CUSTOM, CALENDAR\_PERIOD\_UNSPECIFIED | `string` | n/a | yes |
| calendar\_period | Specifies the calendar period for the budget. Possible values are MONTH, QUARTER, YEAR, CUSTOM, CALENDAR\_PERIOD\_UNSPECIFIED | `string` | `null` | no |
| create\_budget | If the budget should be created | `bool` | `true` | no |
| credit\_types\_treatment | Specifies how credits should be treated when determining spend for threshold calculations | `string` | `"INCLUDE_ALL_CREDITS"` | no |
| custom\_period\_end\_date | Specifies the end date for the calendar\_period CUSTOM | <pre>object(<br> {<br> year = number<br> month = number<br> day = number<br> }<br> )</pre> | <pre>{<br> "day": 1,<br> "month": 1,<br> "year": 1<br>}</pre> | no |
Expand Down
22 changes: 11 additions & 11 deletions modules/budget/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ resource "google_billing_budget" "budget" {

dynamic "custom_period" {

for_each = var.calendar_period == "CUSTOM" ? [1] : []
content {
for_each = var.calendar_period == "CUSTOM" ? [1] : []
content {

start_date {
year = var.custom_period_start_date.year
year = var.custom_period_start_date.year
month = var.custom_period_start_date.month
day = var.custom_period_start_date.day
day = var.custom_period_start_date.day
}
end_date {
year = var.custom_period_end_date.year
year = var.custom_period_end_date.year
month = var.custom_period_end_date.month
day = var.custom_period_end_date.day
day = var.custom_period_end_date.day
}
}

}

}


}

amount {
Expand Down
20 changes: 10 additions & 10 deletions modules/budget/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,31 @@ variable "custom_period_start_date" {
description = "Specifies the start date for the calendar_period CUSTOM"
type = object(
{
year = number
month = number
day = number
year = number
month = number
day = number
}
)
default = {
day = 1
day = 1
month = 1
year = 1
year = 1
}
}

variable "custom_period_end_date" {
description = "Specifies the end date for the calendar_period CUSTOM"
type = object(
{
year = number
month = number
day = number
year = number
month = number
day = number
}
)
default = {
day = 1
day = 1
month = 1
year = 1
year = 1
}
}

Expand Down