Jump to Content
Serverless

Trigger Cloud Run with events from more than 60 Google Cloud sources

October 29, 2020
Prashant Gulati

Product Manager

Mete Atamel

Cloud Developer Advocate

Cloud Run (fully-managed) lets you create microservice-based applications that are scalable and extensible. But setting up event-based communication between decoupled microservices can be hard to implement, customize and maintain.

Today, we’re announcing Eventarc, new events functionality that allows you to trigger Cloud Run from more than 60 Google Cloud sources. Now in Preview, Eventarc helps you easily build event-driven applications and takes care of event ingestion, delivery, security, authorization, observability, and error handling.

With Eventarc, you can address key use cases such as video analysis, file conversion, new user signup, application monitoring, and hundreds of others by acting on events that originate from Cloud Storage, BigQuery, Firestore and more than 60 other Google Cloud sources. 

Eventarc lets you:

  • Receive events from 60+ Google Cloud sources (via Cloud Audit logs).

  • Receive events from custom sources by publishing to Pub/Sub - Your code can send events to signal between microservices 

  • Adhere to the CloudEvents standard for all your events, regardless of source, to ensure a consistent developer experience

  • Enjoy on-demand scalability and no minimum fees

The service is available in five Google Cloud locations, with more coming soon. It is accessible from its own API and CLI and also within Cloud Run’s UI.

Key use cases

Eventarc enables any number of use cases for applications running on Cloud Run, among them:

  • Use a Cloud Storage event (via Cloud Audit Logs) to trigger a data processing pipeline 

  • Use a BigQuery event (via Cloud Audit Logs) to initiate downstream processing in Cloud Run each time a job is completed

  • Use an event from custom sources (publishing to Cloud Pub/Sub) to signal between microservices, leveraging the same standardized infrastructure for any asynchronous coordination of services.

Eventarc in action

Cloud Run allows you to run workloads on a serverless platform. Used alongside Cloud Run, Eventarc offers standardized infrastructure to manage the flow of events, letting you focus on what you do best: building great applications.

Let’s see Eventarc in action. Our demo app (details on github) builds an image processing pipeline to connect Cloud Storage (via Cloud Audit Logs) events to various services. When you save images to the input bucket, the pipeline filters unsafe images, extracts labels from the images, resizes them and finally adds a watermark to them. In the end, there’s a resized, watermarked and labelled image in the output bucket.

https://storage.googleapis.com/gweb-cloudblog-publish/images/Eventarc_in_action.max-1300x1300.jpg

But because the services in the pipeline don’t communicate directly with one another, we use events to ‘wire up’ coordination between them.

https://storage.googleapis.com/gweb-cloudblog-publish/images/event_wrie_up.max-1100x1100.jpg

See the full list of actions and the order in which to take them on github. Here we’ll highlight a few key steps that pertain to events

Highlight 1: Creating a trigger for the Filter service to receive events from Cloud Storage (via Cloud Audit Logs)

https://storage.googleapis.com/gweb-cloudblog-publish/original_images/cloud_audit_logs.gif

Highlight 2: Handling the event in the Filter service’s code

In our example, we need the details provided in the event. These are delivered via the HTTP header and body of the request and can easily be “unmarshalled” (i.e., unpacked) using the CloudEvents SDK along with the Google Events library. We will use C# in this example.

Read the event using CloudEvents SDK:

Loading...

Highlight 3: Signaling the Resizer service by writing to Cloud Pub/Sub

Filter service signals to the Resizer service by writing to the Pub/Sub topic managed by Resizer’s trigger:

Loading...

There you have it—a complete image processing pipeline that connects a Cloud Storage bucket to various services using events, wired together using standard Google Cloud tools! 

What’s next?

Together, Eventarc and Cloud Run make it easy to build a standardized event-based architecture without having to manage the underlying infrastructure.But we're just getting started—stay tuned as we work to make Eventarc a full-featured events offering for Google Cloud. To learn more about Events with Cloud Run, check out this talk from Next 2020. And to get started, follow the quickstart guide.

Posted in