Skip to content

Latest commit

 

History

History

eventarc-workflows

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Terraform with Eventarc and Workflows

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.

Terraform

You can see main.tf for Terraform and [workflow.yaml](workflow.yaml] for Workflows definitions.

  1. Initialize terraform:

    terraform init
  2. See the planned changes:

    terraform plan -var="project_id=YOUR-PROJECT-ID" -var="region=YOUR-GCP-REGION"
  3. Apply changes:

    terraform apply -var="project_id=YOUR-PROJECT-ID" -var="region=YOUR-GCP-REGION"
  4. You can see the created workflow in the list:

    gcloud workflows list --location YOUR-GCP-REGION
  5. You can also see the created trigger:

    gcloud eventarc triggers list --location YOUR-GCP-REGION
  6. Cleanup:

    terraform destroy -var="project_id=YOUR-PROJECT-ID" -var="region=YOUR-GCP-REGION"

Execute

You can execute the workflow using gcloud:

  1. 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"
  2. After sending the message, you can check Workflows output and logs to see the received Hello World message.