diff --git a/terraform/README.md b/terraform/README.md index c0c4b4953..607032d3c 100644 --- a/terraform/README.md +++ b/terraform/README.md @@ -139,7 +139,7 @@ Terraform module. # Enable optional alerting. module "en-alerting" { source = "github.com/google/exposure-notifications-verification-server/terraform/alerting" - project = "example" + monitoring-host-project = "example" adminapi-host = "adminapi.example.org" apiserver-host = "apiserver.example.org" diff --git a/terraform/alerting/monitoring.tf b/terraform/alerting/monitoring.tf index fefc9c88b..d621eee84 100644 --- a/terraform/alerting/monitoring.tf +++ b/terraform/alerting/monitoring.tf @@ -13,7 +13,7 @@ # limitations under the License. resource "google_monitoring_dashboard" "verification-server" { - project = var.project + project = var.monitoring-host-project dashboard_json = jsonencode(yamldecode(file("${path.module}/dashboards/verification-server.yaml"))) depends_on = [ null_resource.manual-step-to-enable-workspace @@ -21,7 +21,7 @@ resource "google_monitoring_dashboard" "verification-server" { } resource "google_monitoring_dashboard" "e2e" { - project = var.project + project = var.monitoring-host-project dashboard_json = jsonencode(yamldecode(file("${path.module}/dashboards/e2e.yaml"))) depends_on = [ null_resource.manual-step-to-enable-workspace @@ -29,7 +29,7 @@ resource "google_monitoring_dashboard" "e2e" { } resource "google_monitoring_alert_policy" "five_xx" { - project = var.project + project = var.monitoring-host-project display_name = "Elevated 5xx" combiner = "OR" conditions { @@ -75,7 +75,7 @@ EOT } resource "google_monitoring_alert_policy" "rate_limited_count" { - project = var.project + project = var.monitoring-host-project display_name = "ElevatedRateLimitedCount" combiner = "OR" conditions { @@ -111,7 +111,7 @@ client app, or a potential DoS attack. View the metric here -https://console.cloud.google.com/monitoring/dashboards/custom/${basename(google_monitoring_dashboard.verification-server.id)}?project=${var.project} +https://console.cloud.google.com/monitoring/dashboards/custom/${basename(google_monitoring_dashboard.verification-server.id)}?project=${var.monitoring-host-project} EOT mime_type = "text/markdown" } diff --git a/terraform/alerting/notifications.tf b/terraform/alerting/notifications.tf index 74f14cc78..b9bfbb1d9 100644 --- a/terraform/alerting/notifications.tf +++ b/terraform/alerting/notifications.tf @@ -1,6 +1,6 @@ resource "google_monitoring_notification_channel" "email" { provider = google-beta - project = var.project + project = var.monitoring-host-project display_name = "Email Notification Channel" type = "email" labels = { diff --git a/terraform/alerting/probers.tf b/terraform/alerting/probers.tf index 34a177647..4e79add13 100644 --- a/terraform/alerting/probers.tf +++ b/terraform/alerting/probers.tf @@ -3,7 +3,7 @@ resource "google_monitoring_uptime_check_config" "https" { display_name = each.key timeout = "3s" - project = var.project + project = var.monitoring-host-project period = "60s" http_check { @@ -16,7 +16,7 @@ resource "google_monitoring_uptime_check_config" "https" { monitored_resource { type = "uptime_url" labels = { - project_id = var.project + project_id = var.monitoring-host-project host = each.key } } @@ -26,7 +26,7 @@ resource "google_monitoring_uptime_check_config" "https" { } resource "google_monitoring_alert_policy" "probers" { - project = var.project + project = var.monitoring-host-project display_name = "Host Down" combiner = "OR" conditions { diff --git a/terraform/alerting/variables.tf b/terraform/alerting/variables.tf index 2f3fde4ad..383b1a027 100644 --- a/terraform/alerting/variables.tf +++ b/terraform/alerting/variables.tf @@ -1,5 +1,6 @@ -variable "project" { - type = string +variable "monitoring-host-project" { + type = string + description = "The host project for multi-project workspace. See also: http://cloud/monitoring/workspaces/create#first-multi-project-workspace" } variable "notification-email" { diff --git a/terraform/alerting/workspace.tf b/terraform/alerting/workspace.tf index 29c418d31..af3444926 100644 --- a/terraform/alerting/workspace.tf +++ b/terraform/alerting/workspace.tf @@ -19,7 +19,7 @@ resource "null_resource" "manual-step-to-enable-workspace" { provisioner "local-exec" { command = <>>> WARNING WARNING WARNING!' - echo -e '>>>> Please use https://console.cloud.google.com/monitoring/signup?project=${var.project}&nextPath=monitoring to create the first workspace.' + echo -e '>>>> Please use https://console.cloud.google.com/monitoring/signup?project=${var.monitoring-host-project}&nextPath=monitoring to create the first workspace.' echo -e '>>>> Terraform cannot create workspace yet, you can only create workspace via the Google Cloud Console.' echo -e '>>>> Related doc: https://cloud.google.com/monitoring/workspaces/create#single-project-workspace' EOF