5.3 Event Routing and Service Orchestration: Eventarc & Cloud Workflows
Key Takeaways
Eventarc routes events using the CloudEvents 1.0 standard from supported Google Cloud sources to Cloud Run, Cloud Workflows, and GKE destinations.
Direct triggers (e.g., Cloud Storage) offer lower latency without audit logs, whereas Cloud Audit Log triggers capture operations across GCP APIs but require Data Access audit logs enabled in Cloud IAM.
Cloud Workflows orchestrates complex, multi-step business logic as declarative serverless state machines in YAML, featuring native parallel execution, connectors, and OIDC authentication.
Workflows provides granular error handling via try/except/retry blocks with customizable backoff multipliers, predicate conditions, and compensating transaction steps.
The choice between Choreography (Eventarc/Pub/Sub) and Orchestration (Cloud Workflows) balances autonomous event decoupling against centralized visibility, strict step sequencing, and automated sagas.
Event Routing and Service Orchestration: Eventarc & Cloud Workflows
Modern cloud-native architectures rely on two complementary architectural patterns to coordinate microservices: Event Routing (Choreography) and Service Orchestration. In Google Cloud, Eventarc provides the routing fabric that captures and normalizes events across Google Cloud services and delivers them to serverless consumers, while Cloud Workflows provides a stateful orchestration engine to coordinate multi-step, distributed business processes.
Eventarc Architecture & The CloudEvents Standard
Eventarc provides a unified, serverless event bus that transforms state changes across supported Google Cloud services into standardized CloudEvents v1.0 payloads. Instead of requiring applications to maintain bespoke event adapters, Eventarc standardizes event headers, delivery mechanisms, and filtering rules.
CloudEvents Format
Every event delivered by Eventarc adheres to the CNCF CloudEvents 1.0 specification:
id: Unique identifier for the event instance.source: URI identifying the context in which the event occurred (e.g.,//storage.googleapis.com/projects/_/buckets/my-bucket).specversion: Always1.0.type: Specific event type (e.g.,google.cloud.storage.object.v1.finalized,google.cloud.audit.log.v1.written).time: Timestamp of when the event occurred in RFC 3339 format.data: Service-specific JSON payload containing resource details.
Event Destinations
Eventarc delivers CloudEvents via HTTP POST requests to:
- Cloud Run services (fully managed container endpoints)
- Cloud Functions (2nd gen) (built on Cloud Run)
- Google Kubernetes Engine (GKE) services
- Cloud Workflows (initiating workflow executions)
Under the hood, Eventarc automatically manages an internal Cloud Pub/Sub transport topic and subscription to buffer and deliver events reliably.
Direct Triggers vs. Cloud Audit Log Triggers
Eventarc supports two distinct trigger mechanisms with different performance, scope, and configuration requirements.
| Trigger Type | Supported Sources | Latency & Performance | Configuration Requirements |
|---|---|---|---|
| Direct Triggers | Cloud Storage (finalized, deleted, archived, metadataUpdated), Pub/Sub | Avoids the audit-log delivery path; latency varies by source and load | No special logging configuration required; scoped directly to bucket or topic |
| Cloud Audit Log Triggers | Supported Google Cloud APIs (Compute Engine, BigQuery, IAM, Cloud SQL, etc.) | Slightly higher latency; relies on Cloud Logging ingestion pipeline | Requires Data Access audit logs to be explicitly enabled in IAM Audit Config for data operations |
The Audit Log Configuration Trap
Admin Activity, System Event and Policy Denied logs have their own default/always-written behavior; do not treat all audit logging as one switch. Data Access audit logs (which record data reads and writes) are disabled by default for many services; BigQuery is a notable default-enabled exception. Check the relevant service and operation rather than assuming every audit trigger needs the same logging category. Configure the needed data-operation logging explicitly and review its cost and access controls.
Caution
Exam Trap: Missing Data Access Audit Logs:
If you create an Eventarc trigger listening for google.cloud.audit.log.v1.written filtered by storage.googleapis.com or bigquery.googleapis.com data operations, verify that the matching audit entry is actually produced and the necessary Data Read/Data Write category is enabled. BigQuery Data Access logging is normally already enabled; exact method/type filters and trigger permissions still matter.
## Create a Direct Cloud Storage trigger targeting Cloud Run
gcloud eventarc triggers create gcs-direct-trigger \
--location=us-central1 \
--destination-run-service=document-processor \
--destination-run-region=us-central1 \
--event-filters="type=google.cloud.storage.object.v1.finalized" \
--event-filters="bucket=user-documents-bucket" \
--service-account=eventarc-invoker@my-project.iam.gserviceaccount.com
Cloud Workflows: Serverless Service Orchestration
While Eventarc excels at routing individual events, complex business workflows require coordinating multiple microservices in a deterministic sequence, managing state transitions, and handling failures. Cloud Workflows is a fully managed, serverless orchestration engine that executes state machines defined in declarative YAML or JSON.
Core Workflows Constructs
steps: An ordered list of steps executed sequentially unless altered by branching.call: Invoking an external HTTP endpoint (http.get,http.post) or a pre-built Google Cloud Connector (googleapis.bigquery.v2...,googleapis.pubsub.v1...).args: Arguments passed to the call, including URL, query parameters, JSON payload, and authentication.auth: Built-in credential management supportingtype: OIDCortype: OAuth2using dedicated service accounts.switch: Conditional branching logic based on variable evaluations.parallel: Executing multiple branches concurrently with optional concurrency throttling.try / except / retry: Granular exception handling and retry policies.
Declarative YAML Workflow Example
main:
params: [event]
steps:
- init:
assign:
- orderId: ${event.data.orderId}
- customerEmail: ${event.data.email}
- amount: ${event.data.amount}
- reserveInventory:
try:
call: http.post
args:
url: https://inventory-service-xyz.a.run.app/api/reserve
auth:
type: OIDC
body:
orderId: ${orderId}
result: inventoryResult
retry:
predicate: ${http.default_retry_predicate}
max_retries: 5
backoff:
initial_delay: 2
max_delay: 60
multiplier: 2
- processPayment:
try:
call: http.post
args:
url: https://payment-service-xyz.a.run.app/api/charge
auth:
type: OIDC
body:
orderId: ${orderId}
amount: ${amount}
result: paymentResult
except:
as: e
steps:
- compensateInventory:
call: http.post
args:
url: https://inventory-service-xyz.a.run.app/api/release
auth:
type: OIDC
body:
orderId: ${orderId}
- failWorkflow:
raise: ${e}
- notifyCustomer:
call: http.post
args:
url: https://notification-service-xyz.a.run.app/api/send
auth:
type: OIDC
body:
email: ${customerEmail}
status: "ORDER_CONFIRMED"
result: notificationResult
- returnSuccess:
return:
status: "COMPLETED"
orderId: ${orderId}
Retrying Business Operations Safely
max_retries: 5 allows five retries after the initial call, so up to six attempts. The retry policy is a sibling of try, not a field nested inside its HTTP arguments. A retry predicate must be defined or imported; use ${http.default_retry_predicate} for the documented idempotent HTTP status set. The reserve-inventory endpoint must deduplicate by orderId, or a retry could reserve the same stock twice. Compensating release and refund endpoints also need stable idempotency keys.
Choreography vs. Orchestration Decision Framework
Architecting distributed systems requires choosing between Choreography (Eventarc, Pub/Sub) and Orchestration (Cloud Workflows).
| Dimension | Event Choreography (Eventarc / Pub/Sub) | Service Orchestration (Cloud Workflows) |
|---|---|---|
| Coordination Model | Decentralized: Services react to published events independently | Centralized: A single coordinator executes defined steps sequentially |
| Coupling | Loose coupling: Publishers have zero knowledge of downstream listeners | Tighter coupling: The workflow coordinator defines step dependencies |
| State & Visibility | Implicit: Global business state is fragmented across multiple services | Explicit: Current execution state, variables, and history are centralized |
| Compensating Actions | Difficult: Requires publishing rollback events that every service must handle | Native: Handled cleanly in except blocks using the Saga pattern |
| Error Handling | Localized to individual subscribers; failures do not pause other flows | Global: Step retries, conditional fallbacks, and escalation policies |
| Debugging & Tracing | Requires distributed tracing (Cloud Trace) across all event consumers | Centrally visible in Cloud Console with step-by-step audit logs |
| Ideal Scenarios | High-throughput data ingestion, real-time analytics, decoupled notifications | Multi-step order checkout, payment authorization sagas, human approval chains |
The Saga Pattern in Cloud Workflows
In microservice architectures, distributed transactions across independent databases cannot use traditional ACID two-phase locking. The Saga Pattern manages distributed transactions by breaking them into a sequence of local transactions. If any step fails, Cloud Workflows coordinates compensating transactions in reverse order (as demonstrated in the YAML example above: releasing inventory if payment capture fails), restoring eventual data consistency across all microservice boundaries.
Official references checked October 18, 2026: Google Cloud 1.
A document processing pipeline needs to trigger a Cloud Run microservice whenever an end-user uploads a PDF file to a Cloud Storage bucket named user-documents-bucket. The solution must minimize invocation latency, avoid unnecessary logging costs, and require minimal administrative configuration. Which Eventarc trigger configuration should the developer implement?
Create an Eventarc trigger with type google.cloud.pubsub.topic.v1.messagePublished and configure a Cloud Storage object notification to publish to that topic.
Create an Eventarc trigger with type google.cloud.audit.log.v1.written filtering on storage.googleapis.com and method storage.objects.create, and enable Data Access audit logs for Cloud Storage.
Create an Eventarc trigger with direct event type google.cloud.storage.object.v1.finalized filtering on bucket user-documents-bucket.
Configure a Cloud Workflows polling loop that runs every 5 seconds to list bucket contents using the Cloud Storage API connector.
A developer is building a Cloud Workflows workflow that calls a secure downstream microservice hosted on Cloud Run. The target service occasionally encounters brief network blips and rate limits. The workflow must authenticate securely, catch HTTP 429 and 503 errors, and retry the call up to 5 times with exponential backoff. How should the HTTP call step in the workflow YAML be structured?
Invoke the Cloud Run URL using http.post with an API key query parameter, and configure a switch step to loop back to the invocation step after a static sys.sleep delay.
Invoke the Cloud Run URL using http.get, pass an OAuth 2.0 access token in the headers retrieved from Secret Manager, and define an except block that writes failures to a Cloud Tasks queue.
Invoke the Cloud Run URL using http.post with Basic Authentication, and set retry: ${http.default_retry} without custom error predicate handling.
Invoke http.post with OIDC, put retry beside try, and use max_retries: 5 with the documented http.default_retry_predicate and backoff; make the POST endpoint idempotent.
An online retail application processes customer orders involving three microservices: Inventory Reservation, Payment Capture, and Shipping Order Creation. If payment capture fails after inventory has been reserved, the system must release the reserved inventory. If shipping order creation fails, both payment must be refunded and inventory released. The development team needs centralized visibility, deterministic execution timing, and auditable transaction compensation. Which architectural approach should the developer choose?
Implement the Saga pattern using Cloud Workflows to orchestrate the services sequentially, executing explicit compensating steps in except blocks upon any failure.
Implement event choreography using Cloud Pub/Sub, where each microservice publishes domain events to topics and listens for failure events to trigger compensation independently.
Deploy an Envoy service mesh on GKE with outlier detection and traffic mirroring to duplicate requests across all three microservices in parallel.
Implement a distributed two-phase commit (2PC) protocol across the microservices using Cloud Tasks delayed scheduling to coordinate database locks.
Sections you finish are checked off in the contents.