OpenWhisk with Serverless Framework

To set up a deployment with Serverless Framework, we need to have a few things in place first. So, considering that you are already signed up, we need to retrieve the Bluemix endpoint and keys through the Bluemix CLI, and so first we need to set up and configure the Bluemix CLI, which can be done at https://console.bluemix.net/openwhisk/learn/cli.

Once the CLI is set up, we will then install the Cloud Function plugin through the Bluemix CLI, then log into Bluemix Cloud and deploy the action. Go through the following steps to do this:

  1. First, we get the endpoint and authentication keys from the Bluemix portal using the following command:
$ bx wsk property get --auth whisk auth 
00700a7f-2b1a-4831-bf323a566263ed44:4TBcM7f8g0gj5UPgSVHXwNmMkfpbX36OdWximngOwqZYAJrDSkZwPjeSPjQ45Wm1
  1. Once we get the authentication details through the preceding command, we can set --apihost and --auth through the wsk command line, as follows:
$ wsk property set --apihost OpenWhisk.ng.bluemix.net --auth 00700a7f-2b1a-4831-bf32-3a566263ed44:4TBcM7f8g0gj5UPgSVHXwNmMkfpbX36OdWximngOwqZYAJrDSkZwPjeSPjQ45Wm1

ok: whisk auth set. Run 'wsk property get --auth' to see the new value.
ok: whisk API host set to OpenWhisk.ng.bluemix.net

Another way to get and set the keys would be through the portal. We can also configure the credentials through bashrc for the framework to use it. To do this, log into the Bluemix portal through the browser and go to the API Key section the retrieve and then export them. So, let's log into the Bluemix portal at https://console.bluemix.net/openwhisk/, then select the API Key menu on the left-hand side bar to get the authentication keys, as shown in the following screenshot:

  1. Let's go to the Linux or macOS Terminal and add the authentication details to the user profile using the following code:
$ vi ~/.bashrc
  1. Copy the following export with the correct auth and apihost from the Bluemix portal:
export OW_AUTH=00700a7f-2b1a-4831-bf32-3a566263ed44:4TBcM7f8g0gj5UPgSVHXwNmMkfpbX36OdWximngOwqZYAJrDSkZwPjeSPjQ45Wm1
export OW_APIHOST=OpenWhisk.eu-gb.bluemix.net
  1. The next step is to install Serverless Framework and the respective dependencies with the provider plugin, as shown in the following code:
$ npm install --global serverless serverless-openwhisk
The plugin has to be installed as a global module to work.