# Issues with IBM Cloud - Event Streams Trigger creation After targeting a CloudFoundry based function namespace and creating an Event Streams instance and its service bindings using the following commands (Makefile section `create_kafka`) we have encountered a problem that has now been resolved. ```bash= ibmcloud resource service-instance-create evt-hub messagehub standard eu-de ibmcloud resource service-alias-create my-evt-hub --instance-name evt-hub ibmcloud cf create-service-key my-evt-hub evt-hub-creds -c '{"role":"Manager"}' ibmcloud fn package refresh ``` Rhe `ibmcloud cf service-key my-evt-hub evt-hub-creds | tail -n +5 | jq > kafka_creds.json` is excluded from the above listing, because it is not relevant for the reproduction of the issue Now the Event Streams instance is deployed. To configure the trigger a Topic is requried. The topics associated with the Event-Processing Use-case were generated using these commands (Makefile: `create_topics`): ```bash= ibmcloud es init ibmcloud es topic-create db-ingest ibmcloud es topic-create forecast ibmcloud es topic-create state-change ibmcloud es topic-create temperature ``` Now everything is set up to create a trigger by running one of the four commands in the `create_triggers` section. For example: ```bash ibmcloud fn trigger create forecast-trigger -f /kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds/messageHubFeed -p topic forecast -p isJSONData true ``` Before the fix this command has returned an Output looking simmilar to the one shown [here](#Trigger-Creation-Before-Fix). Scrolling through the output we can find the following Error message `Could not authenticate with Message Hub. Please check your credentials.`. This brings up the assumtion that the autoconfigured credentiasl might be incorrect. To verfiy them we first run `ibmcloud cf service-key my-evt-hub evt-hub-creds` the ouput of this program returns the credentials we expect to to see in the configuration of the package binding. Its output in my case can be found [here](#Created-Credentials). To check the validity of the credentials we ran `ibmcloud fn package get /kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds` to see its output see [here](#Package-binding-configuration). When comparing the `parameters` section of the output with the expected credentials we quickly find out that the credentials are correct. As a result i Have contacted IBM Support because the issue seemed to be in their implementation. Now approx. 1 week later the problem has been fixed and the afforementioned trigger creation command returns the expected result. The documentation followed can be found [here](https://cloud.ibm.com/docs/openwhisk?topic=cloud-functions-pkg_event_streams#eventstreams_pkg) ## Outputs ### Trigger Creation (Before Fix) ```= $ ibmcloud fn trigger create temp-trigger -f /kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds/messageHubFeed -p topic temperature -p isJSONData true { "activationId": "c237e171df24427eb7e171df24c27eb2", "annotations": [ { "key": "binding", "value": "kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds" }, { "key": "path", "value": "whisk.system/messaging/messageHubFeed" }, { "key": "waitTime", "value": 35 }, { "key": "kind", "value": "nodejs:10" }, { "key": "timeout", "value": false }, { "key": "limits", "value": { "concurrency": 1, "logs": 10, "memory": 256, "timeout": 60000 } } ], "duration": 464, "end": 1566320088906, "logs": [], "name": "messageHubFeed", "namespace": "kaffemuehle@posteo.de_dev", "publish": false, "response": { "result": { "error": "Could not authenticate with Message Hub. Please check your credentials." }, "status": "application error", "success": false }, "start": 1566320088442, "subject": "kaffemuehle@posteo.de", "version": "0.0.18" } { "activationId": "0d34ab13131b4541b4ab13131b05415f", "annotations": [ { "key": "binding", "value": "kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds" }, { "key": "path", "value": "whisk.system/messaging/messageHubFeed" }, { "key": "waitTime", "value": 3 }, { "key": "kind", "value": "nodejs:10" }, { "key": "timeout", "value": false }, { "key": "limits", "value": { "concurrency": 1, "logs": 10, "memory": 256, "timeout": 60000 } } ], "duration": 204, "end": 1566320089166, "logs": [], "name": "messageHubFeed", "namespace": "kaffemuehle@posteo.de_dev", "publish": false, "response": { "result": { "error": "Error: missing" }, "status": "application error", "success": false }, "start": 1566320088962, "subject": "kaffemuehle@posteo.de", "version": "0.0.18" } ok: deleted trigger temp-trigger ``` ### Created Credentials ```= $ ibmcloud cf service-key my-evt-hub evt-hub-creds Aufrufen von 'cf service-key my-evt-hub evt-hub-creds'... Abrufen des Schlüssels evt-hub-creds für Serviceinstanz my-evt-hub als kaffemuehle@posteo.de... { "api_key": "XhskmR-YIHxbFwPulJ3drJvr5pHVbY8ZsCIGDqxUAcU9", "apikey": "XhskmR-YIHxbFwPulJ3drJvr5pHVbY8ZsCIGDqxUAcU9", "iam_apikey_description": "Auto-generated for key 46c1cb5d-361e-4176-822b-bcde1cad5f2f", "iam_apikey_name": "Credentials-yg", "iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager", "iam_serviceid_crn": "crn:v1:bluemix:public:iam-identity::a/1be85e6e38f94f0f9f45b3995a747b7f::serviceid:ServiceId-c44138b3-1384-46c8-b534-58b0554b5aa7", "instance_id": "e7398c4d-3cb2-4b98-a860-9c925ab00b74", "kafka_admin_url": "https://rh0lt9m5mw1vtlpp.svc01.eu-de.eventstreams.cloud.ibm.com", "kafka_brokers_sasl": [ "broker-0-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093", "broker-1-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093", "broker-5-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093", "broker-3-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093", "broker-4-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093", "broker-2-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093" ], "kafka_http_url": "https://rh0lt9m5mw1vtlpp.svc01.eu-de.eventstreams.cloud.ibm.com", "password": "XhskmR-YIHxbFwPulJ3drJvr5pHVbY8ZsCIGDqxUAcU9", "user": "token" } ``` ### Package binding configuration ```= $ ibmcloud fn package get /kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds ok: got package Bluemix_my-evt-hub_evt-hub-creds { "namespace": "kaffemuehle@posteo.de_dev", "name": "Bluemix_my-evt-hub_evt-hub-creds", "version": "0.0.10", "publish": false, "annotations": [ { "key": "binding", "value": { "name": "messaging", "namespace": "whisk.system" } } ], "parameters": [ { "key": "bluemixServiceName", "value": "messagehub" }, { "key": "iam_role_crn", "value": "crn:v1:bluemix:public:iam::::serviceRole:Manager" }, { "key": "iam_apikey_description", "value": "Auto-generated for key 46c1cb5d-361e-4176-822b-bcde1cad5f2f" }, { "key": "apikey", "value": "XhskmR-YIHxbFwPulJ3drJvr5pHVbY8ZsCIGDqxUAcU9" }, { "key": "kafka_brokers_sasl", "value": "broker-0-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093,broker-1-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093,broker-5-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093,broker-3-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093,broker-4-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093,broker-2-rh0lt9m5mw1vtlpp.kafka.svc01.eu-de.eventstreams.cloud.ibm.com:9093" }, { "key": "kafka_admin_url", "value": "https://rh0lt9m5mw1vtlpp.svc01.eu-de.eventstreams.cloud.ibm.com" }, { "key": "api_key", "value": "XhskmR-YIHxbFwPulJ3drJvr5pHVbY8ZsCIGDqxUAcU9" }, { "key": "origin", "value": "a0b35d5f-5bfa-4f9b-85db-0b01dd808544" }, { "key": "iam_apikey_name", "value": "Credentials-yg" }, { "key": "endpoint", "value": "openwhisk.eu-de.bluemix.net" }, { "key": "kafka_http_url", "value": "https://rh0lt9m5mw1vtlpp.svc01.eu-de.eventstreams.cloud.ibm.com" }, { "key": "iam_serviceid_crn", "value": "crn:v1:bluemix:public:iam-identity::a/1be85e6e38f94f0f9f45b3995a747b7f::serviceid:ServiceId-c44138b3-1384-46c8-b534-58b0554b5aa7" }, { "key": "instance_id", "value": "e7398c4d-3cb2-4b98-a860-9c925ab00b74" }, { "key": "user", "value": "token" }, { "key": "password", "value": "XhskmR-YIHxbFwPulJ3drJvr5pHVbY8ZsCIGDqxUAcU9" } ], "binding": { "namespace": "whisk.system", "name": "messaging" }, "actions": [ { "name": "messageHubProduce", "version": "0.0.18", "annotations": [ { "key": "description", "value": "Deprecated - Produce a message to Message Hub" }, { "key": "deprecated", "value": true }, { "key": "sampleInput", "value": { "kafka_brokers_sasl": "[\"kafka01-prod01.messagehub.services.us-south.bluemix.net:9093\"]", "password": "somePassword", "topic": "mytopic", "username": "someUsername", "value": "This is my message" } }, { "key": "exec", "value": "python:3" }, { "key": "parameters", "value": [ { "description": "Array of Message Hub brokers", "name": "kafka_brokers_sasl", "required": true }, { "description": "Message Hub username", "name": "user", "required": true }, { "description": "Message Hub password", "name": "password", "required": true, "type": "password" }, { "description": "Topic that you wish to produce a message to", "name": "topic", "required": true }, { "description": "The value for the message you want to produce", "name": "value", "required": true }, { "description": "The key for the message you want to produce", "name": "key", "required": false }, { "description": "If true, the message will be produced with a Base64 decoded version of the value parameter", "name": "base64DecodeValue", "required": false }, { "description": "If true, the message will be produced with a Base64 decoded version of the key parameter", "name": "base64DecodeKey", "required": false } ] } ] } ], "feeds": [ { "name": "messageHubFeed", "version": "0.0.18", "annotations": [ { "key": "description", "value": "Feed to list to Message Hub messages" }, { "key": "provide-api-key", "value": true }, { "key": "feed", "value": true }, { "key": "sampleInput", "value": { "endpoint": "openwhisk.ng.bluemix.net", "isJSONData": "false", "kafka_admin_url": "https://kafka-admin-prod01.messagehub.services.us-south.bluemix.net:443", "kafka_brokers_sasl": "[\"kafka01-prod01.messagehub.services.us-south.bluemix.net:9093\"]", "password": "somePassword", "topic": "mytopic", "username": "someUsername" } }, { "key": "exec", "value": "nodejs:10" }, { "key": "parameters", "value": [ { "description": "Array of Message Hub brokers", "name": "kafka_brokers_sasl", "required": true }, { "description": "Message Hub username", "name": "user", "required": true }, { "description": "Message Hub password", "name": "password", "required": true, "type": "password" }, { "description": "Topic to subscribe to", "name": "topic", "required": true }, { "description": "Attempt to parse message value as JSON", "name": "isJSONData", "required": false }, { "description": "Encode key as Base64", "name": "isBinaryKey", "required": false }, { "description": "Encode message value as Base64", "name": "isBinaryValue", "required": false }, { "description": "Hostname and port of OpenWhisk deployment", "name": "endpoint", "required": true }, { "description": "Your Message Hub admin REST URL", "name": "kafka_admin_url", "required": true } ] } ] } ] } ``` ### Expected output of trigger creation ```= $ ibmcloud fn trigger create my-forecast-trigger -f /kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds/messageHubFeed -p topic forecast -p isJSONData true ok: invoked /kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds/messageHubFeed with id 3aab0ab6adaf4e0fab0ab6adafae0fe2 { "activationId": "3aab0ab6adaf4e0fab0ab6adafae0fe2", "annotations": [ { "key": "binding", "value": "kaffemuehle@posteo.de_dev/Bluemix_my-evt-hub_evt-hub-creds" }, { "key": "path", "value": "whisk.system/messaging/messageHubFeed" }, { "key": "waitTime", "value": 50 }, { "key": "kind", "value": "nodejs:10" }, { "key": "timeout", "value": false }, { "key": "limits", "value": { "concurrency": 1, "logs": 10, "memory": 256, "timeout": 60000 } }, { "key": "initTime", "value": 349 } ], "duration": 1215, "end": 1566926566669, "logs": [], "name": "messageHubFeed", "namespace": "kaffemuehle@posteo.de_dev", "publish": false, "response": { "result": { "uuid": "b2102cb4-252c-46fd-8450-d0b4995f0c90" }, "status": "success", "success": true }, "start": 1566926565454, "subject": "kaffemuehle@posteo.de", "version": "0.0.20" } ok: created trigger my-forecast-trigger ```