Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Run Jobs events to trigger Cloud Function with EventArc

I have a Cloud Run Job (apiVersion: run.googleapis.com/v1). When the job finishes successfully, I'd like to trigger a follow-up Cloud Function.

I set up a Terraform google_cloudfunctions2_function with the following trigger config:

 

 

event_trigger {
    trigger_region        = var.region
    event_type            = "google.cloud.audit.log.v1.written"
    retry_policy          = "RETRY_POLICY_RETRY"
    service_account_email = google_service_account.event.email

    event_filters {
      attribute = "serviceName"
      value     = "run.googleapis.com"
    }

    event_filters {
      attribute = "methodName"
      value     = "google.cloud.run.v1.Jobs.RunJob"
    }
...

 

 

If I query the Cloud Logs for:

 

 

protoPayload.serviceName="run.googleapis.com"
protoPayload.methodName="/Jobs.RunJob"

 

 

 I can see the events there, but they're not triggering my Cloud Function. Roles are all there and everything is in us-central1.

I tried various methodNamed (/Jobs.RunJob) etc. but I can't figure out why this isn't working?

Thanks

0 2 867
2 REPLIES 2

Hi @PatrickNeva,

Welcome to Google Cloud Community!

It seems you're trying to trigger a Cloud Function after a Cloud Run Job using EventArc and Terraform. The events show in Cloud Logs, but the `methodName` filter in your `event_trigger` config is likely blocking it.

Recommendations

  1. Update methodName: Modify the event_trigger to use "google.cloud.run.v1.JobExecutionSucceeded" as the methodName value, which more accurately filters for job completion events.
  2. Verify with Console Setup: If issues persist, set up an EventArc trigger through the Google Cloud Console as a test. Manually configure EventArc to listen for JobExecutionSucceeded and link it to the Cloud Function.
  3. Confirm Permissions: Ensure that the service account associated with EventArc has roles/eventarc.eventReceiver and roles/cloudfunctions.invoker for the required permissions.
  4. Redeploy Terraform Configurations: After making changes to filters or permissions, redeploy Terraform to apply the updates.

These adjustments might help your Cloud Function trigger reliably on Cloud Run Job completion.

I hope the above information is helpful.

Thanks, but there's no `JobExecutionSucceeded`.