diff --git a/modules/cloudevent-recorder/README.md b/modules/cloudevent-recorder/README.md index c1911636..f8bc774e 100644 --- a/modules/cloudevent-recorder/README.md +++ b/modules/cloudevent-recorder/README.md @@ -107,6 +107,7 @@ No requirements. | [google_bigquery_table.types](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_table) | resource | | [google_bigquery_table_iam_binding.import-writes-to-tables](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/bigquery_table_iam_binding) | resource | | [google_monitoring_alert_policy.bq_dts](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy) | resource | +| [google_monitoring_alert_policy.bucket-access](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_alert_policy) | resource | | [google_pubsub_subscription.dead-letter-pull-sub](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource | | [google_pubsub_subscription.this](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource | | [google_pubsub_subscription_iam_binding.allow-pubsub-to-ack](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription_iam_binding) | resource | diff --git a/modules/cloudevent-recorder/main.tf b/modules/cloudevent-recorder/main.tf index 4dbf9938..ed7a1237 100644 --- a/modules/cloudevent-recorder/main.tf +++ b/modules/cloudevent-recorder/main.tf @@ -50,3 +50,68 @@ resource "google_storage_bucket" "recorder" { // What identity is deploying this? data "google_client_openid_userinfo" "me" {} +resource "google_monitoring_alert_policy" "bucket-access" { + # In the absence of data, incident will auto-close after an hour + alert_strategy { + auto_close = "3600s" + + notification_rate_limit { + period = "3600s" // re-alert hourly if condition still valid. + } + } + + display_name = "Abnormal Event Bucket Access: ${var.name}" + combiner = "OR" + + conditions { + display_name = "Bucket Access" + + condition_matched_log { + filter = <