In this section, you will configure a Serverless Application Module (SAM) with credentials to access the Watson Machine Learning model deployed in previous section. This SAM will be used as a backend server on AWS that will talk to IBM Cloud Pak for Data Watson Machine Learning service to get predictions from the deployed model.
In AWS Console, Navigate to Services -> Compute -> Lambda.
Select the Lambda function with the description Invoke WML model endpoint.
You will see the Lambda function overview as shown.
You can take a look at the code source below function overview. There are two main functions in the server:
GetToken()
: This function makes an API call to IBM Cloud Pak for Data-Auth Validation and generates a bearer token that will be used invoke Watson Machine Learning Model deployed on Cloud Pak for Data.
InvokeModel()
: This function makes an API call to IBM Cloud Pak for Data-Watson Machine Learning with scoring payload, and gets the model prediction and probability result.
To generate the Token and Invoke the model, you need to provide Cloud Pak for Data credentials to the Lambda function.
Select the Configuration tab below function overview.
You will see a left panel with different options, select Environment variables. You will see 3 environment variables listed.
Click on Edit and enter the following details:
As part of Infra Provisioning Lab, you will have created CP4D users. Enter the same user credentials for CPD_USERNAME and CPD_PASSWORD.
Click on Save to update the environment variables.
At this point you have successfully configured the Serverless Application Module(SAM) backend.