IBM Cloud Functions Adds Support for Cloud Object Storage Triggers
5 min read
By: Mark Deuser
What’s new with IBM Cloud Functions and Cloud Object Storage triggers?
Starting today in the US-South region, IBM Cloud Functions allows you to create triggers based on Cloud Object Storage bucket changes. With the new /whisk.system/cos-experimental package, you can create triggers and rules to fire actions when bucket objects are created, modified, or deleted. This package is currently an experimental offering. You can try out this new feature and provide feedback related to desired feature enhancements or problems you encounter.
A new Cloud Object Storage package
The existing /whisk.system/cloud-object-storage package is joined by the /whisk.system/cos-experimental package. The former package continues to provide convenient actions you can use to access your Cloud Object Storage instance, while the cos-experimental package introduces a
feed action that is used during trigger creation to configure bucket-specific events.
Let’s put this to work
Before starting, you must have a Cloud Object Storage service instance created and running in the IBM Cloud. This instance should have at least one bucket as well as a service credential containing the API key used to access your storage. You should also know the endpoint that was used to create the bucket; Cloud Functions will use this endpoint to determine bucket changes.
- Create a package binding:
ibmcloud fn package bind /whisk.system/cos-experimental myCosPkg
- Bind your Cloud Object Storage credentials to your package binding:
ibmcloud fn service bind cloud-object-storage myCosPkg
- Create a trigger. Replace
myBucketwith your bucket name, and use your bucket’s endpoint value:
- Create a rule to run your action when the trigger fires. Replace
myCosChangeActionwith one of your actions:
ibmcloud fn trigger create myCosTrigger --feed myCosPkg/changes -p bucket myBucket -p endpoint s3.us-south.cloud-object-storage.appdomain.cloud
In your Cloud Object Storage dashboard, either modify an existing object or create a new one.
Observe the trigger being fired. Run the following command a few times over the span of about one minute (the default bucket polling interval):
ibmcloud fn activation list
The cos-experimental event provider also easily integrates with the existing actions defined in the cloud-object-storage package; you can create rules that run those actions when a bucket is updated. For more information about this feature, refer to the IBM Cloud Functions Documentation.
For an overview of object storage, see "Object Storage: A Complete Guide."