Execute a Cloud Run job that processes event data saved in Cloud Storage

Use Workflows to execute a Cloud Run job as part of a workflow that processes event data saved in Cloud Storage.

Explore further

For detailed documentation that includes this code sample, see the following:

Code sample

YAML

  main 
 : 
  
 params 
 : 
  
 [ 
 event 
 ] 
  
 steps 
 : 
  
 - 
  
 init 
 : 
  
 assign 
 : 
  
 - 
  
 project_id 
 : 
  
 ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} 
  
 - 
  
 event_bucket 
 : 
  
 message-payload-UNIQUE_ID 
  
 - 
  
 event_file 
 : 
  
 ${event.id + ".data.json"} 
  
 - 
  
 job_name 
 : 
  
 message-payload-job 
  
 - 
  
 job_location 
 : 
  
 us-central1 
  
 - 
  
 log_event 
 : 
  
 call 
 : 
  
 sys.log 
  
 args 
 : 
  
 data 
 : 
  
 ${event} 
  
 - 
  
 write_payload_to_gcs 
 : 
  
 call 
 : 
  
 http.post 
  
 args 
 : 
  
 url 
 : 
  
 ${"https://storage.googleapis.com/upload/storage/v1/b/" + event_bucket + "/o"} 
  
 auth 
 : 
  
 type 
 : 
  
 OAuth2 
  
 query 
 : 
  
 name 
 : 
  
 ${event_file} 
  
 body 
 : 
  
 ${event.data} 
  
 - 
  
 run_job_to_process_payload 
 : 
  
 call 
 : 
  
 googleapis.run.v1.namespaces.jobs.run 
  
 args 
 : 
  
 name 
 : 
  
 ${"namespaces/" + project_id + "/jobs/" + job_name} 
  
 location 
 : 
  
 ${job_location} 
  
 body 
 : 
  
 overrides 
 : 
  
 containerOverrides 
 : 
  
 env 
 : 
  
 - 
  
 name 
 : 
  
 INPUT_BUCKET 
  
 value 
 : 
  
 ${event_bucket} 
  
 - 
  
 name 
 : 
  
 INPUT_FILE 
  
 value 
 : 
  
 ${event_file} 
  
 result 
 : 
  
 job_execution 
  
 - 
  
 finish 
 : 
  
 return 
 : 
  
 ${job_execution} 
 

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser .

Create a Mobile Website
View Site in Mobile | Classic
Share by: