跳到主要内容

Use Cloud Functions

Vanus supports sending direct events to Cloud Functions. The following page will teach you how to use Cloud Functions with vsctl commands in Vanus.

Vanus only support Cloud Functions(2nd gen) HTTP triggers.

Prerequisites

Before using Cloud Functions, you must meet the following prerequisites.

  1. Have a running Vanus cluster.
  2. Have vsctl .
  3. Have a Cloud account and create a service account.
  4. Have a Cloud Function.
  5. The "cloudfunctions.functions.invoke" permission grant for your gcloud account

Create a Subscription to Use with Cloud Functions

When you create a subscription setting the protocol flag as "gcloud-functions", Vanus will send all available events to your Google Cloud function.

Use the command below to create your Subscription:

vsctl subscription create \
--name test-function \
--eventbus=test-function \
--sink "https://function-1-tvm6jmwz6a-uc.a.run.app" \
--protocol gcloud-functions \
--credential-type gcloud \
--credential-file ./gcloud_credentail.json

The following params are also required:

  1. sink: your Cloud Function URL.
  2. credential-type is must be "gcloud".
  3. credential is a file which save your gcloud service account.