fix(tf): billing budget NOK 2500/500 — Vertex credits 9K available

This commit is contained in:
Chris Christiansen 2026-05-26 12:05:44 +00:00
parent cf3e19b54a
commit 74dcf742a3

View File

@ -13,6 +13,7 @@ resource "google_project_service" "apis" {
"run.googleapis.com",
"artifactregistry.googleapis.com",
"cloudbuild.googleapis.com",
"cloudbuildv2.googleapis.com",
"secretmanager.googleapis.com",
"monitoring.googleapis.com",
"logging.googleapis.com",
@ -48,6 +49,79 @@ resource "google_pubsub_topic" "billing_alerts" {
name = "billing-alert-auto-teardown"
}
resource "google_storage_bucket" "agent_staging" {
name = "${var.project_id}-agent-staging"
location = var.region
force_destroy = true // Set to true for ephemeral staging buckets
lifecycle_rule {
action {
type = "Delete"
}
condition {
age = 7
}
}
}
resource "google_billing_budget" "prod_budget" {
billing_account = var.billing_account_id
display_name = "OSVauco-Agent-Budget-500USD"
amount {
specified_amount {
currency_code = "NOK"
units = "2500"
}
}
threshold_rules {
threshold_percent = 0.5
}
threshold_rules {
threshold_percent = 0.8
}
threshold_rules {
threshold_percent = 1.0
}
all_updates_rule {
pubsub_topic = google_pubsub_topic.billing_alerts.id
schema_version = "1.0"
}
}
resource "google_billing_budget" "dev_budget" {
billing_account = var.billing_account_id
display_name = "OSVauco-Dev-Budget-75USD"
amount {
specified_amount {
currency_code = "NOK"
units = "500"
}
}
threshold_rules {
threshold_percent = 0.7
}
threshold_rules {
threshold_percent = 0.9
}
threshold_rules {
threshold_percent = 1.0
}
all_updates_rule {
pubsub_topic = google_pubsub_topic.billing_alerts.id
schema_version = "1.0"
}
}
# Managed via Cloud Budget alerts not Pub/Sub push
# resource "google_pubsub_subscription" "billing_alerts_sub" {
# name = "billing-alert-subscription"
@ -113,17 +187,17 @@ resource "google_bigquery_table" "cloud_run_logs" {
}
schema = jsonencode([
{ name = "timestamp", type = "TIMESTAMP", mode = "REQUIRED" },
{ name = "severity", type = "STRING", mode = "NULLABLE" },
{ name = "service_name", type = "STRING", mode = "NULLABLE" },
{ name = "revision", type = "STRING", mode = "NULLABLE" },
{ name = "http_method", type = "STRING", mode = "NULLABLE" },
{ name = "http_url", type = "STRING", mode = "NULLABLE" },
{ name = "http_status", type = "INTEGER", mode = "NULLABLE" },
{ name = "latency_ms", type = "FLOAT", mode = "NULLABLE" },
{ name = "message", type = "STRING", mode = "NULLABLE" },
{ name = "trace", type = "STRING", mode = "NULLABLE" },
{ name = "labels", type = "JSON", mode = "NULLABLE" }
{ name = "timestamp", type = "TIMESTAMP", mode = "REQUIRED" },
{ name = "severity", type = "STRING", mode = "NULLABLE" },
{ name = "service_name", type = "STRING", mode = "NULLABLE" },
{ name = "revision", type = "STRING", mode = "NULLABLE" },
{ name = "http_method", type = "STRING", mode = "NULLABLE" },
{ name = "http_url", type = "STRING", mode = "NULLABLE" },
{ name = "http_status", type = "INTEGER", mode = "NULLABLE" },
{ name = "latency_ms", type = "FLOAT", mode = "NULLABLE" },
{ name = "message", type = "STRING", mode = "NULLABLE" },
{ name = "trace", type = "STRING", mode = "NULLABLE" },
{ name = "labels", type = "JSON", mode = "NULLABLE" }
])
}
@ -134,9 +208,9 @@ resource "google_project_iam_member" "bq_log_writer" {
}
resource "google_logging_project_sink" "cloudrun_to_bq" {
name = "osvauco-cloudrun-sink"
destination = "bigquery.googleapis.com/projects/${var.project_id}/datasets/${google_bigquery_dataset.logs.dataset_id}"
filter = "resource.type=\"cloud_run_revision\" AND resource.labels.service_name=\"osvauco-agent\""
name = "osvauco-cloudrun-sink"
destination = "bigquery.googleapis.com/projects/${var.project_id}/datasets/${google_bigquery_dataset.logs.dataset_id}"
filter = "resource.type=\"cloud_run_revision\" AND resource.labels.service_name=\"osvauco-agent\""
unique_writer_identity = true
}