This module provisions a regionalizied Broker abstraction akin to the Knative
"Broker" concept. The dual "Trigger" concept is captured by the sibling
cloudevent-trigger module. The intended usage of this module for publishing
events is something like this:
// Create a network with several regional subnets
module "networking" {
source = "chainguard-dev/common/infra//modules/networking"
name = "my-networking"
project_id = var.project_id
regions = [...]
}
// Create the Broker abstraction.
module "cloudevent-broker" {
source = "chainguard-dev/common/infra//modules/cloudevent-broker"
name = "my-broker"
project_id = var.project_id
regions = module.networking.regional-networks
}
// Authorize the "foo" service account to publish events.
module "foo-emits-events" {
for_each = module.networking.regional-networks
source = "chainguard-dev/common/infra//modules/authorize-private-service"
project_id = var.project_id
region = each.key
name = module.cloudevent-broker.ingress.name
service-account = google_service_account.foo.email
}
// Run a cloud run service as the "foo" service account, and pass in the address
// of the regional ingress endpoint.
module "foo-service" {
source = "chainguard-dev/common/infra//modules/regional-go-service"
project_id = var.project_id
name = "foo"
regions = module.networking.regional-networks
service_account = google_service_account.foo.email
containers = {
"foo" = {
source = {
working_dir = path.module
importpath = "./cmd/foo"
}
ports = [{ container_port = 8080 }]
regional-env = [{
name = "EVENT_INGRESS_URI"
value = { for k, v in module.foo-emits-events : k => v.uri }
}]
}
}
}
A map from region names to a network and subnetwork. A pub/sub topic and ingress service (publishing to the respective topic) will be created in each region, with the ingress service configured to egress all traffic via the specified subnetwork.
A map from each of the input region names to the name of the Broker topic in each region. These broker names are intended for use with the cloudevent-trigger module's broker input.