Can we cron schedule local_exec
to execute the bash file that having the multiple commands in Terraform? I tried the [google_cloud_scheduler_job][1]
resource "google_cloud_scheduler_job" "job" {
name = "test-job"
description = "test job"
schedule = "*/2 * * * *"
provisioner "local-exec" {
command = "${path.module}/bash_file.sh"
}
}
But I am getting an error
Error: ExactlyOne
on main.tf line 366, in resource "google_cloud_scheduler_job" "job":
366: resource "google_cloud_scheduler_job" "job" {
"app_engine_http_target": one of
`app_engine_http_target,http_target,pubsub_target` must be specified
Error: ExactlyOne
on main.tf line 366, in resource "google_cloud_scheduler_job" "job":
366: resource "google_cloud_scheduler_job" "job" {
"pubsub_target": one of `app_engine_http_target,http_target,pubsub_target`
must be specified
Error: ExactlyOne
on main.tf line 366, in resource "google_cloud_scheduler_job" "job":
366: resource "google_cloud_scheduler_job" "job" {
"http_target": one of `app_engine_http_target,http_target,pubsub_target` must
be specified
Any suggestions will be appreciated. Thank you.
You can't schedule
local-exec
at all, and certainly not with a Google cloud scheduler. This is not howlocal-exec
works at all, or what it is intended to do. How would the Google scheduler be able to reach into your computer to locally execute a bash script?You probably want to build whatever your bash script is doing into a Google Cloud Function, and provision that function via Terraform.