GoogleCloudPlatform/terraform-google-cloud-workflows

Payload restrictions when triggering a Workflow with Scheduler

alexdequevedo opened this issue · 1 comments

I am attempting to trigger a Workflow with Cloud Scheduler but it appears only certain payloads are allowed. When I manually input {"argument": "{\"firstName\":\"Sherlock\", \"lastName\":\"Holmes\"}"}, as the body (this was the given example in the documentation) it works fine. However if argument is misspelled or any other payload is used, I get a 400 INVALID_ARGUMENT error. Even if the working payload is provided through terraform, the escaping \ are stripped out and the scheduler fails. Below is the relevant Terraform

resource "google_workflows_workflow" "workflow" {
name = "workflow"
project = var.project_id
region = "us-east1"
description = "Test"
service_account = google_service_account.backup_scheduler_service_account.id
source_contents = file("workflow.yaml")}

resource "google_cloud_scheduler_job" "export_trigger" {
  name = "csa-backup-job"
  project = var.project_id
  region = var.locations.primary.region
  description = "Triggers a Workflow"
  schedule = "0 2 * * *"
  time_zone = "America/New_York"
  attempt_deadline = "320s"
  http_target {
      http_method = "POST"
      uri =    "https://workflowexecutions.googleapis.com/v1/${google_workflows_workflow.workflow.id}/executions"
      body = base64encode(jsonencode(yamldecode(file("project-list.yaml"))))
      oidc_token {
          service_account_email = google_service_account.backup_scheduler_service_account.email
      }
    }
}

Any help or insight is appreciated, curious if there are any payload restrictions on calling workflows from cloud scheduler.

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days