This enables Cloud Scheduler to trigger Cloud Run endpoints when they are not public.

cr_run_schedule_http(uri, email, http_method = "GET", body = NULL)

Arguments

uri

The URI of your Cloud Run application

email

The service email that has invoke access to the Cloud Run application. If using cr_run and derivatives to make the email this will include (name)-cloudrun-invoker@(project-id).iam.gserviceaccount.com - see cr_run_email to help make the email.

http_method

The HTTP verb you have set up your Cloud Run application to receive

body

(optional) An R list object that will be turned into JSON via toJSON and turned into a base64-encoded string if you are doing a POST, PUT or PATCH request.

Value

A HttpTarget object for use in cr_schedule

Details

Ensure you have a service email with cr_email_set of format service-{project-number}@gcp-sa-cloudscheduler.iam.gserviceaccount.com with Cloud Scheduler Service Agent role as per https://cloud.google.com/scheduler/docs/http-target-auth#add

See also

https://cloud.google.com/run/docs/triggering/using-scheduler

cr_schedule_http and cr_run and cr_deploy_run

Other Cloud Scheduler functions: HttpTarget(), Job(), PubsubTarget(), cr_build_schedule_http(), cr_schedule_delete(), cr_schedule_get(), cr_schedule_list(), cr_schedule_pause(), cr_schedule_run()

Other Cloud Run functions: cr_jwt_create(), cr_plumber_pubsub(), cr_run_email(), cr_run_get(), cr_run_list(), cr_run()

Examples

if (FALSE) {
# for unauthenticated apps create a HttpTarget
run_me <- HttpTarget(
  uri = "https://public-ewjogewawq-ew.a.run.app/echo?msg=blah",
  http_method = "GET"
)
cr_schedule("cloud-run-scheduled",
  schedule = "16 4 * * *",
  httpTarget = run_me
)

# for authenticated Cloud Run apps - create with allowUnauthenticated=FALSE
cr_deploy_run("my-app", allowUnauthenticated = TRUE)
}

# deploying via R will help create a service email called my-app-cloudrun-invoker
cr_run_email("my-app")
#> [1] "my-app-invoker@my-project.iam.gserviceaccount.com"
if (FALSE) {
# use that email to schedule the Cloud Run private micro-service

# schedule the endpoint
my_run_name <- "my-app"
my_app <- cr_run_get(my_run_name)
email <- cr_run_email(my_run_name)
endpoint <- paste0(my_app$status$url, "/fetch_stuff")

app_sched <- cr_run_schedule_http(endpoint,
  http_method = "GET",
  email = email
)

cr_schedule("cloud-run-scheduled-1",
  schedule = "4 16 * * *",
  httpTarget = app_sched
)
}