terraform-provider-google: google_billing_budget in v3.52 updating threshold rule -> 400 API error returned
Community Note
- Please vote on this issue by adding a ๐ reaction to the original issue to help the community and maintainers prioritize this request.
- Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
- If you are interested in working on this issue or have submitted a pull request, please leave a comment.
- If an issue is assigned to the
modular-magicianuser, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot, a community member has claimed the issue already.
Terraform Version
0.13.5
Affected Resource(s)
- google_billing_budget
Terraform Configuration Files
resource "google_billing_budget" "budget" {
provider = google
count = var.create_budget ? 1 : 0
billing_account = var.billing_account
display_name = local.display_name
budget_filter {
projects = local.project_numbers
credit_types_treatment = var.credit_types_treatment
services = local.services
}
amount {
specified_amount {
currency_code = "USD"
units = tostring(var.amount)
}
}
dynamic "threshold_rules" {
for_each = var.alert_spent_percents
content {
threshold_percent = threshold_rules.value
}
}
dynamic all_updates_rule {
for_each = length(local.alert_email_addresses) > 0 ? [1]: []
content {
monitoring_notification_channels = [
for k, v in local.alert_email_addresses:
google_monitoring_notification_channel.billing_notification_channel[k].id
]
disable_default_iam_recipients = true
}
}
}
variable "credit_types_treatment" {
description = "Specifies how credits should be treated when determining spend for threshold calculations"
type = string
default = "INCLUDE_ALL_CREDITS"
}
Expected Behavior
Following on from #8238, the config for my billing budgets was incorrect. So I set the correct values to be 0.8, 0.9 and 1. They used to be 80, 90 and 100. Trying to update the threshold is throwing a 400 API error. Iโve turned on debug logs and can see the patch request doesnโt add the key for creditTypesTreatment correctly. Iโve attached the debug log below.
Actual Behavior
400 error returned
Debug Log;
2021/01/19 10:51:55 [DEBUG] EvalApply: ProviderMeta config value set
2021/01/19 10:51:55 [DEBUG] module.project["example-chi"].module.project-factory["dev"].module.budget.google_billing_budget.budget[0]: applying the planned Update change
2021-01-19T10:51:55.461Z [INFO] plugin.terraform-provider-google_v3.52.0_x5: 2021/01/19 10:51:55 [DEBUG] Updating Budget "billingAccounts/011F09-ABC0EE-F0CB1D/budgets/0aa023fa-5dd1-4747-8f28-95f1bd8b93fa": map[string]interface {}{"amount":map[string]interface {}{"specifiedAmount":map[string]interface {}{"currencyCode":"USD", "units":"1000"}}, "budgetFilter":map[string]interface {}{"creditTypesTreatment":"INCLUDE_ALL_CREDITS", "projects":[]interface {}{"projects/424973061461"}}, "displayName":"Budget For bt-example-chi-dev", "thresholdRules":[]interface {}{map[string]interface {}{"spendBasis":"CURRENT_SPEND", "thresholdPercent":0.7}, map[string]interface {}{"spendBasis":"CURRENT_SPEND", "thresholdPercent":0.9}, map[string]interface {}{"spendBasis":"CURRENT_SPEND", "thresholdPercent":1}}}: timestamp=2021-01-19T10:51:55.461Z
2021-01-19T10:51:55.461Z [INFO] plugin.terraform-provider-google_v3.52.0_x5: 2021/01/19 10:51:55 [DEBUG] Waiting for state to become: [success]: timestamp=2021-01-19T10:51:55.461Z
2021-01-19T10:51:55.462Z [INFO] plugin.terraform-provider-google_v3.52.0_x5: 2021/01/19 10:51:55 [DEBUG] Retry Transport: starting RoundTrip retry loop: timestamp=2021-01-19T10:51:55.462Z
2021-01-19T10:51:55.462Z [INFO] plugin.terraform-provider-google_v3.52.0_x5: 2021/01/19 10:51:55 [DEBUG] Retry Transport: request attempt 0: timestamp=2021-01-19T10:51:55.462Z
2021-01-19T10:51:55.462Z [INFO] plugin.terraform-provider-google_v3.52.0_x5: 2021/01/19 10:51:55 [DEBUG] Google API Request Details:
---[ REQUEST ]---------------------------------------
PATCH /v1/billingAccounts/011F09-ABC0EE-F0CB1D/budgets/0aa023fa-5dd1-4747-8f28-95f1bd8b93fa?alt=json HTTP/1.1
Host: billingbudgets.googleapis.com
User-Agent: Terraform/0.13.5 (+https://www.terraform.io) Terraform-Plugin-SDK/2.4.0 terraform-provider-google/dev
Content-Length: 393
Content-Type: application/json
Accept-Encoding: gzip
{
"amount": {
"specifiedAmount": {
"currencyCode": "USD",
"units": "1000"
}
},
"budgetFilter": {
INCLUDE_ALL_CREDITS",
"projects": [
"projects/424973061461"
]
},
"displayName": "Budget For bt-example-chi-dev",
"thresholdRules": [
{
"spendBasis": "CURRENT_SPEND",
"thresholdPercent": 0.7
},
{
"spendBasis": "CURRENT_SPEND",
"thresholdPercent": 0.9
},
{
"spendBasis": "CURRENT_SPEND",
"thresholdPercent": 1
}
]
}
-----------------------------------------------------: timestamp=2021-01-19T10:51:55.462Z
[0m[1mmodule.project["example-chi"].module.project-factory["dev"].module.budget.google_billing_budget.budget[0]: Modifying... [id=billingAccounts/011F09-ABC0EE-F0CB1D/budgets/0aa023fa-5dd1-4747-8f28-95f1bd8b93fa][0m[0m
2021-01-19T10:51:57.182Z [INFO] plugin.terraform-provider-google_v3.52.0_x5: 2021/01/19 10:51:57 [DEBUG] Google API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 400 Bad Request
Connection: close
Transfer-Encoding: chunked
Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: private
Content-Type: application/json; charset=UTF-8
Date: Tue, 19 Jan 2021 10:51:57 GMT
Server: ESF
Vary: Origin
Vary: X-Origin
Vary: Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 0
7f
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
0
-----------------------------------------------------: timestamp=2021-01-19T10:51:57.181Z
Steps to Reproduce
- Create a billing_budget
terraform plan & apply- Change the value of one of the threshold rules
terraform plan & apply
Important Factoids
References
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 8
- Comments: 15 (6 by maintainers)
Issue https://issuetracker.google.com/issues/178109334 raised @rileykarson