When to route Google Cloud events with Eventarc and when to publish your own events to Pub/Sub, how the two relate, and how retries, filtering and delivery differ.

Eventarc and Pub/Sub both move events between services on Google Cloud, and one is built on the other. Pub/Sub is the messaging service: topics, subscriptions, push or pull delivery. Eventarc Standard routes events that Google Cloud services emit, such as a new object in a Cloud Storage bucket, to a destination, and uses Pub/Sub underneath to do it.
The practical question is where the event starts. An upload to a bucket, a BigQuery job finishing or an audit log entry are produced by Google Cloud, and Eventarc turns them into an HTTP request to your Cloud Run service with no publishing code. An order being placed is produced by your code, and publishing it to a Pub/Sub topic gives every consumer its own subscription and retry policy.
Eventarc is the shorter path when Google Cloud already knows the event happened. A Cloud Storage object.v1.finalized event reaches a Cloud Run service without a notification config, a topic or publishing code in your app. Audit log events extend that to most Google Cloud APIs, so "a Cloud SQL instance was created" or "an IAM policy changed" can trigger a remediation service. Every event arrives in the same CloudEvents format, with the type, source and subject in ce-* headers.
The constraints follow from being a router. Filters are exact matches, without wildcards. A trigger delivers to one destination, so two consumers need two triggers. The event body is capped at 512 KB in Eventarc Standard, and there is no ordering guarantee. Retries and dead letters exist, but you configure them on the Pub/Sub subscription that Eventarc created for the trigger.
Pub/Sub fits events your own code produces. A topic is a contract between services: the orders service publishes order-placed, and fulfillment, email and analytics each attach a subscription with their own acknowledgement deadline, retry backoff and dead-letter topic. A consumer that falls behind does not slow the others, and subscriptions keep unacknowledged messages for seven days by default.
Pull subscriptions let workers control their own rate, push subscriptions call an HTTPS endpoint, and features such as ordering keys, exactly-once delivery for pull subscribers and message filtering are configured per subscription. None of this needs Eventarc. The cost is the setup: topics, subscriptions, dead-letter topics and IAM for every publisher and subscriber, in every environment.
Encore is a backend framework with built-in infrastructure. A Pub/Sub topic and its subscriptions are declared in code next to the services that publish and consume them. encore run delivers messages locally, and a deploy to GCP provisions Pub/Sub topics and subscriptions with dead-letter topics in your own project. On AWS the same code runs on SNS and SQS.

Run in your terminal to get started locally.
The topic carries a typed message, so a publisher and a subscriber cannot disagree about its fields:
package orders
import "encore.dev/pubsub"
type OrderPlaced struct {
OrderID string `json:"order_id"`
CustomerID string `json:"customer_id"`
TotalCents int `json:"total_cents"`
}
// OrderPlaced is published once per order. Every subscribing service gets its own copy.
var OrderPlacedTopic = pubsub.NewTopic[*OrderPlaced]("order-placed", pubsub.TopicConfig{
DeliveryGuarantee: pubsub.AtLeastOnce,
})
// Service orders accepts orders and announces them.
package orders
import (
"context"
"fmt"
"time"
)
type PlaceParams struct {
CustomerID string `json:"customer_id"`
TotalCents int `json:"total_cents"`
}
type PlaceResponse struct {
OrderID string `json:"order_id"`
}
//encore:api public method=POST path=/orders
func Place(ctx context.Context, p *PlaceParams) (*PlaceResponse, error) {
id := fmt.Sprintf("ord_%d", time.Now().UnixNano())
// Save the order here, then publish.
if _, err := OrderPlacedTopic.Publish(ctx, &OrderPlaced{
OrderID: id, CustomerID: p.CustomerID, TotalCents: p.TotalCents,
}); err != nil {
return nil, err
}
return &PlaceResponse{OrderID: id}, nil
}
Each subscription has its own retry policy. A second service, such as email, adds its own pubsub.NewSubscription on the same topic and gets its own copy of every message:
// Service fulfillment reserves stock for new orders.
package fulfillment
import (
"context"
"time"
"encore.app/orders"
"encore.dev/pubsub"
"encore.dev/rlog"
)
var _ = pubsub.NewSubscription(orders.OrderPlacedTopic, "reserve-stock",
pubsub.SubscriptionConfig[*orders.OrderPlaced]{
Handler: reserveStock,
RetryPolicy: &pubsub.RetryPolicy{
MinBackoff: 5 * time.Second,
MaxBackoff: 10 * time.Minute,
MaxRetries: 20,
},
})
func reserveStock(ctx context.Context, e *orders.OrderPlaced) error {
// Returning an error retries the message with backoff.
rlog.Info("reserving stock", "order", e.OrderID)
return nil
}
We ran this app with encore run: one POST /orders produced one log line in fulfillment (reserving stock) and one in email (sending confirmation), each with its own trace.
For events that start in Google Cloud, Encore does not replace Eventarc. If a topic is already shared with systems outside your app, the Platform Dashboard can import an existing Pub/Sub topic so an Encore topic points at it instead of a new one.
Topics and subscriptions are code, so a coding agent that adds an analytics consumer writes one subscription and its handler, and the reviewer sees the new consumer and its retry policy in the diff rather than in a console.
Best fit: Services on GCP or AWS that publish their own domain events and want topics, subscriptions, dead letters and local delivery from the same code.
For a Cloud Storage upload, the Eventarc trigger needs the Cloud Storage service agent allowed to publish to Pub/Sub and a service account with roles/run.invoker on the destination service:
Eventarc sends each event as an HTTP POST to the service's root path, with metadata in ce-* headers and the object resource as the body:
// main.go: a Cloud Run service that receives Cloud Storage events from Eventarc.
package main
import (
"encoding/json"
"log"
"net/http"
"os"
)
// The fields used from the Cloud Storage object in the event body.
type storageObject struct {
Bucket string `json:"bucket"`
Name string `json:"name"`
ContentType string `json:"contentType"`
Size string `json:"size"` // int64 encoded as a string
}
func handleEvent(w http.ResponseWriter, r *http.Request) {
// Eventarc uses CloudEvents binary content mode: metadata in ce-* headers,
// the object resource as the JSON body.
if r.Header.Get("Ce-Type") != "google.cloud.storage.object.v1.finalized" {
w.WriteHeader(http.StatusNoContent)
return
}
var obj storageObject
if err := json.NewDecoder(r.Body).Decode(&obj); err != nil {
// A body that does not parse will not parse on a retry either, so acknowledge it.
log.Printf("bad event %s: %v", r.Header.Get("Ce-Id"), err)
w.WriteHeader(http.StatusNoContent)
return
}
log.Printf("new object gs://%s/%s (%s, %s bytes)", obj.Bucket, obj.Name, obj.ContentType, obj.Size)
// Make the thumbnail here. Returning a 5xx makes Eventarc redeliver,
// so the work has to be safe to repeat for the same Ce-Id.
w.WriteHeader(http.StatusNoContent)
}
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
http.HandleFunc("POST /", handleEvent)
log.Fatal(http.ListenAndServe(":"+port, nil))
}
For events your code produces, create the topic, a dead-letter topic and a subscription per consumer. The Pub/Sub service account also needs publisher rights on the dead-letter topic and subscriber rights on the subscription for dead lettering to work:
Every trigger, topic, subscription and IAM binding exists once per environment, and keeping staging and production in step is your job, usually in Terraform.
Best fit: GCP projects that react to Google Cloud events, and teams that already manage their Pub/Sub topics in Terraform.
Use Eventarc when the event comes from Google Cloud, such as an upload, an audit log entry or a BigQuery job, and one Cloud Run service or workflow should handle it. Use Pub/Sub directly for events your services produce, especially when several consumers need their own retries and pace. Pick Encore for those application events when you want topics and subscriptions declared in Go or TypeScript and provisioned as Pub/Sub on GCP or SNS and SQS on AWS in your own account.
Pub/Sub is a messaging service: you publish messages to a topic and each subscription receives a copy by push or pull. Eventarc is an event router built on top of it: a trigger filters events from Google Cloud sources, such as a Cloud Storage upload or an audit log entry, and delivers them in CloudEvents format to Cloud Run, Cloud Run functions, Workflows or GKE. Eventarc Standard uses Pub/Sub as its transport.
Yes. Google's Eventarc Standard documentation says events from Google providers use Pub/Sub as the transport layer, and retries are configured through the Pub/Sub subscription that belongs to the trigger. Dead lettering in Eventarc Standard is also a Pub/Sub dead-letter topic.
Pub/Sub, in most designs. Your services can publish directly to a topic, choose push or pull per consumer, use ordering keys and messages up to 10 MB, and keep each consumer's retry policy separate. Eventarc is the shorter path when the event comes from a Google Cloud service rather than your code.
Topics and subscriptions are declared in Go or TypeScript with a typed message and a retry policy. encore run delivers messages locally, and a deploy to GCP provisions Pub/Sub topics and subscriptions with dead-letter topics in your own project; on AWS the same code runs on SNS and SQS.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.