Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion deployment/modules/gcp/loadbalancer/external/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ module "gce-lb-http" {
}
}

locals {
cdn_logs = {
for name, v in var.logs : name => v if v.enable_cdn
}
}

resource "google_compute_backend_bucket" "log_buckets" {
for_each = local.cdn_logs

name = "${each.key}-bucket-backend"
project = var.project_id
description = "Backend bucket for ${each.key} monitoring endpoints"
bucket_name = coalesce(each.value.bucket_name, "${each.key}.${each.value.submission_host_suffix}")
enable_cdn = true

cdn_policy {
cache_mode = "USE_ORIGIN_HEADERS"
request_coalescing = true
}

lifecycle {
create_before_destroy = true
}
}

resource "google_compute_url_map" "url_map" {
name = "tesseract-url-map"
description = "URL map of static-ct-staging logs"
Expand Down Expand Up @@ -122,6 +147,18 @@ resource "google_compute_url_map" "url_map" {
]
service = module.gce-lb-http.backend_services["${log.key}-backend"].self_link
}

dynamic "path_rule" {
for_each = log.value.enable_cdn ? [1] : []
content {
paths = [
"/checkpoint",
"/tile/*",
"/issuer/*",
]
service = google_compute_backend_bucket.log_buckets[log.key].self_link
}
}
}
}
}
Expand All @@ -145,7 +182,10 @@ resource "random_id" "suffix" {
byte_length = 4

keepers = {
logs = jsonencode(each.value)
logs = jsonencode({
region = each.value.region
submission_host_suffix = each.value.submission_host_suffix
})
}
}

Expand Down
4 changes: 4 additions & 0 deletions deployment/modules/gcp/loadbalancer/external/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ variable "logs" {
region = string
// origin = [basename].[submission_host_suffix]
submission_host_suffix = string
// Whether to serve monitoring endpoints (/checkpoint, /tile/*, /issuer/*) via a Cloud CDN-backed GCS backend bucket.
enable_cdn = optional(bool, false)
// Optional GCS bucket name override if the bucket is not named [basename].[submission_host_suffix].
bucket_name = optional(string)
}))

validation {
Expand Down
Loading