Cloud Run Job with arguments
Contents
Cloud Run Jobs allows to run containers as jobs, i.e. as short-lived tasks that spin up a container every time that they’re invoked. As with every container you can use environment variables to pass context. But what if we want to pass arguments to the container?
In this case, the GCP API specifies containerOverrides. When using terraform, we can pass those with the google_cloud_scheduler_jobresource by customizing the http_target body like so:
| |
In order for this to work though, we need the run.jobs.runWithOverrides permission. If you don’t want to create a custom role with this permission, you can use the run.developer permission, which is quite powerful, so give it to a custom service account:
| |
Et voilà, the job will now run with the arguments provided as input. I hope this can help someone.
