1

So I am switching from cloud functions to Cloud Run and I am trying to figure out how to run Event Arc locally. I know you can set up an emulator for Eventarc using Firebase Emulator but Im not sure to have it trigger one of my Cloud Run functions when I write to my local Firestore db. Can someone please let me know how this can be done?

I did see one vague answer here:

Emulation of event-driven design in Cloud Run while developing locally?

But to me this doesn't make sense given that if Im using the local DB and local functions how would a remote instance work with my local dev environment. If this is possible please let me know and how I can accomplish this. Thanks.

Joe Alvini
  • 306
  • 1
  • 3
  • 15

1 Answers1

1

It's not an easy task and the team is working to make the local tests easier. For now, I can share my hack.

First of all, you have to know that eventarc is roughtly a wrapper that create several resources behind the scene, especially a PubSub topic and Push subscription to your Cloud Run service. Because of that, an eventarc event is no more than a POST request with the event content as body.


For my hack, I have a Cloud Run service, on GCP, that log the headers and body of any incoming requests. I set up an eventarc with that service as target, and I trigger an event.

I go to the logs, copy the headers and the body of the received event, and I create a curl POST request with that.

Then, when I want to test my local service, I reuse my curl POST request, and submit it to my localhost server.

guillaume blaquiere
  • 66,369
  • 2
  • 47
  • 76
  • I started something similar before I abandoned them. I was just using the initial cloud function listeners locally. Then I realized that what I’m using event arc for, event arc is obviously not good at. I wanted to listen to Firestore record updates but it doesn’t seem like when I update, it’s ever shown in the logs as an update. I always shows as a creat or a commit. So I’m just gonna figure out another way to do this. – Joe Alvini Dec 28 '22 at 16:40