Google Cloud Function allows you to create a stand-alone function, which responds to Cloud events.
Procedure
- In the Google Cloud console, search for cloud function, and select it from the related drop-down menu.
The Cloud Function page displays.
- Click Create Function.
- Enter a name for the function and click Add Trigger > Pub/Sub trigger.
- In the Eventarc trigger panel, select the Cloud Pub/Sub topic, and click Save trigger.
- Select Go 1.19 from the Runtime drop-down menu.
- 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.goThe file, related to the specified function's URL, downloads automatically. - 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.
- In the Entry point text box, enter gcpEventConsumer.
- Click Deploy.