add support for custom periods in factory budgets (#3674)
This commit is contained in:
committed by
GitHub
parent
447420f173
commit
91973aca23
@@ -247,7 +247,7 @@ module "billing-account" {
|
||||
budgets_data_path = "data/billing-budgets"
|
||||
}
|
||||
}
|
||||
# tftest modules=1 resources=2 files=test-1 inventory=budget-monitoring-channel.yaml
|
||||
# tftest modules=1 resources=2 files=test-1 inventory=budget-factory.yaml
|
||||
```
|
||||
|
||||
```yaml
|
||||
@@ -256,7 +256,11 @@ amount:
|
||||
units: 100
|
||||
filter:
|
||||
period:
|
||||
calendar: MONTH
|
||||
custom:
|
||||
start_date:
|
||||
day: 1
|
||||
month: 1
|
||||
year: 2026
|
||||
resource_ancestors:
|
||||
- folders/1234567890
|
||||
threshold_rules:
|
||||
|
||||
@@ -54,10 +54,6 @@ resource "google_monitoring_notification_channel" "default" {
|
||||
# condition = local.factory_budgets == null
|
||||
# error_message = yamlencode(local.factory_budgets)
|
||||
# }
|
||||
# precondition {
|
||||
# condition = local.factory_budgets == null
|
||||
# error_message = yamlencode(local.ctx.project_sets)
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
|
||||
|
||||
@@ -44,7 +44,11 @@ locals {
|
||||
v.filter.credit_types_treatment
|
||||
)
|
||||
)
|
||||
label = try(v.filter.label, null)
|
||||
label = try(v.filter.label, null)
|
||||
period = try(v.filter.period, null) == null ? null : merge(
|
||||
{ calendar = null, end_date = null, start_date = null },
|
||||
v.filter.period
|
||||
)
|
||||
projects = try(v.filter.projects, [])
|
||||
resource_ancestors = try(v.filter.resource_ancestors, [])
|
||||
services = try(v.filter.services, null)
|
||||
|
||||
64
tests/modules/billing_account/examples/budget-factory.yaml
Normal file
64
tests/modules/billing_account/examples/budget-factory.yaml
Normal file
@@ -0,0 +1,64 @@
|
||||
# Copyright 2023 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
values:
|
||||
module.billing-account.google_billing_budget.default["folder-net-month-current-100"]:
|
||||
all_updates_rule:
|
||||
- disable_default_iam_recipients: true
|
||||
pubsub_topic: null
|
||||
schema_version: '1.0'
|
||||
amount:
|
||||
- last_period_amount: null
|
||||
specified_amount:
|
||||
- nanos: null
|
||||
units: '100'
|
||||
billing_account: 012345-ABCDEF-012345
|
||||
budget_filter:
|
||||
- credit_types_treatment: INCLUDE_ALL_CREDITS
|
||||
custom_period:
|
||||
- end_date: []
|
||||
start_date:
|
||||
- day: 1
|
||||
month: 1
|
||||
year: 2026
|
||||
projects: null
|
||||
resource_ancestors:
|
||||
- folders/1234567890
|
||||
display_name: 100 dollars in current spend
|
||||
threshold_rules:
|
||||
- spend_basis: CURRENT_SPEND
|
||||
threshold_percent: 0.5
|
||||
- spend_basis: CURRENT_SPEND
|
||||
threshold_percent: 0.75
|
||||
timeouts: null
|
||||
module.billing-account.google_monitoring_notification_channel.default["billing-default"]:
|
||||
description: null
|
||||
display_name: Budget email notification billing-default.
|
||||
enabled: true
|
||||
force_delete: false
|
||||
labels:
|
||||
email_address: gcp-billing-admins@example.com
|
||||
project: tf-playground-simple
|
||||
sensitive_labels: []
|
||||
timeouts: null
|
||||
type: email
|
||||
user_labels: null
|
||||
|
||||
counts:
|
||||
google_billing_budget: 1
|
||||
google_monitoring_notification_channel: 1
|
||||
modules: 1
|
||||
resources: 2
|
||||
|
||||
outputs: {}
|
||||
Reference in New Issue
Block a user