This sample shows how to use Terraform's eventarc_trigger and google_workflows_workflow to deploy a workflow and create an Eventarc trigger to invoke it with a Pub/Sub event.
You can see main.tf for Terraform and [workflow.yaml](workflow.yaml] for Workflows definitions.
-
Initialize terraform:
terraform init
-
See the planned changes:
terraform plan -var="project_id=YOUR-PROJECT-ID" -var="region=YOUR-GCP-REGION"
-
Apply changes:
terraform apply -var="project_id=YOUR-PROJECT-ID" -var="region=YOUR-GCP-REGION"
-
You can see the created workflow in the list:
gcloud workflows list --location YOUR-GCP-REGION
-
You can also see the created trigger:
gcloud eventarc triggers list --location YOUR-GCP-REGION
-
Cleanup:
terraform destroy -var="project_id=YOUR-PROJECT-ID" -var="region=YOUR-GCP-REGION"
You can execute the workflow using gcloud:
-
Find the topic of the trigger and send a message:
TOPIC_ID=$(gcloud eventarc triggers describe trigger-pubsub-workflow-tf --location=YOUR-GCP-REGION --format='value(transport.pubsub.topic)') gcloud pubsub topics publish $TOPIC_ID --message="Hello World"
-
After sending the message, you can check Workflows output and logs to see the received
Hello World
message.