Google Cloud Function allows you to create a stand-alone function, which responds to Cloud events.

Procedure

  1. In the Google Cloud console, search for cloud function, and select it from the related drop-down menu.
    The Cloud Function page displays.
  2. Click Create Function.
  3. Enter a name for the function and click Add Trigger > Pub/Sub trigger.
  4. In the Eventarc trigger panel, select the Cloud Pub/Sub topic, and click Save trigger.
  5. Select Go 1.19 from the Runtime drop-down menu.
  6. To retrieve the code for the function.go and go.mod functions, copy the below URL that relates to each of the functions and paste in a browser.
    • The URL for the Go function: https://prod.cwp.carbonblack.io/public-cloud/${DEPLOYMENT_ENV}/gcp/event-stream-setup/event-stream-function-source-go/CBCDeltaSyncEventFunction.go
    • The URL for the Go Mod function: https://prod.cwp.carbonblack.io/public-cloud/${DEPLOYMENT_ENV}/gcp/event-stream-setup/event-stream-function-source-go/go.mod
    Where DEPLOYMENT_ENV can be either of the following values depending on the region: us, eu, ap, au, prd1ew2, int1usw2.
    For example, https://prod.cwp.carbonblack.io/public-cloud/us/gcp/event-stream-setup/event-stream-function-source-go/CBCDeltaSyncEventFunction.go
    The file, related to the specified function's URL, downloads automatically.
  7. Open the file in a text editor of your choice, copy the content and paste it in the text box that relates to the function.
    Make sure you enter the code for both of the functions.
  8. In the Entry point text box, enter gcpEventConsumer.
  9. Click Deploy.