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.
- Have a running Vanus cluster.
- Have vsctl .
- Have a Cloud account and create a service account.
- Have a Cloud Function.
- 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:
sink
: your Cloud Function URL.credential-type
is must be "gcloud".credential
is a file which save your gcloud service account.