This repository allows you to deploy a Cloud Object Storage Package for IBM Functions. The package contains a set of simple functions to get your started composing IBM Functions Applications.
This package is available in Node.js 12 and Python 3.9
ibmcloud login
if not already logged inibmcloud plugin install cloud-functions
Make sure you are authenticated with IBM Functions and can list entities without errors
ibmcloud fn list
Use ibmcloud fn deploy
to deploy using manifest.yml
. You can deploy either the
Node.js or Python version of the cloud-object-storage
package.
pushd runtimes/nodejs/
ibmcloud fn deploy
popd
This will create a new package cloud-object-storage
with the following actions:
You will need to bind your Cloud Object Storage service to the cloud-object-storage
package, so that the Actions will have access to the service credentials.
ibmcloud fn service bind cloud-object-storage cloud-object-storage
Write a file data.txt
into bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/object-write -b -p bucket myBucket -p key data.txt -p body "Hello World"
Read a file data.txt
from bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/object-read -b -p bucket myBucket -p key data.txt
Delete a file data.txt
from bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/object-delete -b -p bucket myBucket -p key data.txt
Get a signed URL to GET a file data.txt
from bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/client-get-signed-url -b -p bucket myBucket -p key data.txt -p operation getObject
Add CORS to a bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/bucket-cors-put -b -p bucket myBucket -p corsConfig "{\"CORSRules\":[{\"AllowedHeaders\":[\"*\"], \"AllowedMethods\":[\"POST\",\"GET\",\"DELETE\"], \"AllowedOrigins\":[\"*\"]}]}"
Read CORS on a bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/bucket-cors-get -b -p bucket myBucket
Delete CORS from a bucket myBucket
:
ibmcloud fn action invoke cloud-object-storage/bucket-cors-delete -b -p bucket myBucket
Use helper script deploy.sh
deploy.sh
In the Cloud Functions console, go to the Create page.
Using the Cloud Foundry Org and Cloud Foundry Space lists, select the namespace that you want to install the Object Storage package into. Namespaces are formed from the combined org and space names.
Click Install Packages.
Click on the IBM Cloud Object Storage Package group, and then click on the IBM Cloud Object Storage Package.
In the Available Runtimes section, select either NodeJS or Python from the drop-down list and then click Install.
Once the Package has been installed you will be redirected to the Actions page and can search for your new Package, which is named cloud-object-storage.
To use the actions in the cloud-object-storage package, you must bind service credentials to the actions. Note: You must complete the following steps for each action that you want to use.
__bx_creds
. For the value, paste in the service credentials JSON object from the service instance that you created earlier.Upon a successful deployment you will notice that you now have the Package cloud-object-storage present in your namespace. You can use these Actions as you would any other Actions as well as edit their code to suit any specific behavior you may need from the IBM Cloud Object Storage package.
Apache-2.0