0
0
GCPcloud~10 mins

Eventarc for event routing in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Eventarc for event routing
Event Source emits event
Eventarc receives event
Eventarc matches event to trigger
Eventarc routes event to destination
Destination processes event
Events are sent from a source, Eventarc receives and matches them to triggers, then routes them to the right destination for processing.
Execution Sample
GCP
gcloud eventarc triggers create my-trigger \
  --destination-run-service=my-service \
  --destination-run-region=us-central1 \
  --event-filters="type=google.cloud.storage.object.v1.finalized"
This command creates an Eventarc trigger that routes storage object finalized events to a Cloud Run service.
Process Table
StepActionEvent DataTrigger MatchRouting DestinationResult
1Event Source emits event{"type":"google.cloud.storage.object.v1.finalized","bucket":"my-bucket"}N/AN/AEvent sent to Eventarc
2Eventarc receives event{"type":"google.cloud.storage.object.v1.finalized","bucket":"my-bucket"}Checking triggersN/AEvent received
3Eventarc matches event to trigger{"type":"google.cloud.storage.object.v1.finalized"}Trigger 'my-trigger' matchesN/AMatch found
4Eventarc routes eventEvent data passedN/ACloud Run service 'my-service' in us-central1Event routed
5Destination processes eventEvent data receivedN/ACloud Run service 'my-service'Event processed successfully
6No more eventsN/AN/AN/AWaiting for next event
💡 No more events to process, Eventarc waits for new events.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5Final
Event DataNone{"type":"google.cloud.storage.object.v1.finalized","bucket":"my-bucket"}{"type":"google.cloud.storage.object.v1.finalized","bucket":"my-bucket"}{"type":"google.cloud.storage.object.v1.finalized"}Passed to destinationReceived by destinationProcessed
Trigger MatchNoneN/AChecking triggersTrigger 'my-trigger' matchedN/AN/AN/A
Routing DestinationNoneN/AN/AN/ACloud Run service 'my-service'Cloud Run service 'my-service'Cloud Run service 'my-service'
Key Moments - 3 Insights
How does Eventarc know which destination to send the event to?
Eventarc uses triggers that match event attributes like type. In the execution_table row 3, the event type matches the trigger 'my-trigger', so Eventarc routes the event accordingly.
What happens if no trigger matches the event?
If no trigger matches, Eventarc does not route the event to any destination. This is implied by the matching step in execution_table row 3 where no match would mean no routing.
Can Eventarc process multiple event types with one trigger?
No, each trigger filters specific event types. To handle multiple types, you create multiple triggers. This is shown in the event-filters in the execution_sample.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does Eventarc decide where to send the event?
AStep 3
BStep 2
CStep 4
DStep 5
💡 Hint
Check the 'Trigger Match' column in execution_table row 3 where the match is found.
According to variable_tracker, what is the state of 'Event Data' after step 4?
ANone
BMatched trigger data
CPassed to destination
DProcessed
💡 Hint
Look at the 'Event Data' row under 'After Step 4' in variable_tracker.
If the event type changed to one not matching any trigger, what would happen in the execution_table?
AEventarc routes event to destination anyway
BNo trigger match found, event not routed
CEventarc matches a different trigger
DEventarc processes event itself
💡 Hint
Refer to key_moments about what happens if no trigger matches.
Concept Snapshot
Eventarc routes events from sources to destinations using triggers.
Triggers filter events by attributes like type.
When an event matches a trigger, Eventarc routes it to the destination.
Destinations can be Cloud Run, Pub/Sub, or others.
Eventarc waits for events and routes them automatically.
Full Transcript
Eventarc is a service that listens for events from various sources. When an event happens, it sends the event data to Eventarc. Eventarc checks its triggers to find one that matches the event type or other filters. If a trigger matches, Eventarc routes the event to the destination specified in the trigger, such as a Cloud Run service. The destination then processes the event. If no trigger matches, the event is not routed. This process repeats for every event received.