IBM Cloud: How to bind Db2 Warehouse to Code Engine app? - db2

I have an existing instance of Db2 Warehouse on Cloud which is deployed to an org and space. Now, I would like to bind that service to an app for deployment with IBM Cloud Code Engine.
ibmcloud ce application bind --name henriks-app --service-instance myDb2
myDb2 does not exist as IAM resource because it is a CF resource. How would I bind the two together? It seems that I would need to create some form of custom wrapper.

The best way to manually connect services to your Code Engine application is to add service credentials to a Code Engine secret, and then attach that secret to your application using environment variables or volume mounting.
While you're correct that Db2 Warehouse isn't a typical IAM-Enabled service type, based on the IBM Cloud Db2 Warehouse docs, it's possible to create a client connection with Db2 Warehouse using an IAM Service ID & API Key.
Here's how I'd "bind" the Db2 instance to a Code Engine app:
Create a new service ID from the IAM Service IDs page
Under "Assign Access" > "Access service ID additional access" > "IAM Service", you'll find "Db2 Warehouse" as an option, and you can configure exact permissions from there (e.g. which instance(s) to grant permissions to, which roles, etc)
Finish the configuration by clicking "Assign access"
Using the CLI, log in to your account and generate a new API Key, e.g. ibmcloud iam service-api-key-create mydb2key SERVICE_ID_NAME --output JSON > mydb2.json where SERVICE_ID_NAME is the name of the service ID created in Step 1
Target your Code Engine project, then create a new secret using the API Key JSON, e.g. ibmcloud ce secret create --name mydb2 --from-file MYDB2=mydb2.json
Attach the secret to your application as an environment variable, e.g. ibmcloud ce app update --name myapp --env-from-secret mydb2
After the app update goes through, your application will have access to an environment variable named MYDB2, which will have the value of a JSON object string containing your API Key.
You'll find more information about creating secrets and using secrets with applications in the Code Engine docs.

Related

IBM Cloud API key could not be created

To configure my Terraform to use my IBM cloud I need to generate an API key and Classic infrastructure key. This gives the error "API key could not be created".
What settings needs to be changed in order for this to work?
Your cloud administrator needs to add the IAM Identity Service - Service ID creator rights

Where to set API KEY to deploy on IBM Bluemix Cloud Foundry

I'm deploying via Delivery Pipeline on IBM Bluemix Cloud Foundry.
On logs I have this message:
WARNING: Deploying to Cloud Foundry without specifying an API KEY is DEPRECATED. Press the [CONFIGURE] button above to include an API KEY for this job.
What is API KEY and where I have to set it?
The API key can be set in the Deploy configuration, around the middle of the panel:
From the drop-down, select 'Add an existing API key' and then paste in a key.
(The key can be created on the command line using ibmcloud iam api-key-create MyKey -d "this is my API key" --file key_file if there isn't already one for the user whose identity the deploy should be done under.)

Service broker error: delete your existing Lite plan instance

I have received this message:
Service broker error: You can only have one instance of a Lite plan per service. To create a new instance, either delete your existing Lite plan instance or select a paid plan.
I do not know how to delete the previous Lite plan instance, can someone help please?
This error comes if you have already lite plan instance, so you needs to delete existing to create a new one.
Go to the below address, You would found your existing lite instance list.
IBM service Resources https://cloud.ibm.com/resources
You need to remove all existing service's, because in LITE plan you can have one lite instance at a time only.
You can use the IBM Cloud dashboard (UI) or the command line interface (CLI) to check for instances of that service.
In the UI, there is a context menu on each service. Use it to delete the service instance.
With the CLI and within a space, you can use ibmcloud cf services to list service. For services in resource groups use ibmcloud resource service-instances. Then use either ibmcloud cf delete-service or ibmcloud resource service-instance-delete to remove that instance.

how external app can access ibm cloud object storage

I have IBM COS service and able to use Curl command via cli to retrieve objects. I used IAM tokens to retrieve. But how do I let an external web app ex., node access this service?
what value should be there in authorization for external app access?
External apps will come in the form of something like the AWS CLI or any other app that uses either an HTTP library coupled with IBM Cloud Object Storage API or even an SDK for languages like Python, Java or Node.Js
All of the above will ask you for access key and secret key.
You can get both of them from the IBM Cloud console by generating new HMAC Credentials [1]:
Navigate to your Cloud Object storage account
Click on right under Service credentials
Click New credentials button on right
For the "Add Inline Configuration Parameters (Optional)" text box enter the following JSON:
{"HMAC":true}
[1] https://console.bluemix.net/docs/services/cloud-object-storage/iam/service-credentials.html#service-credentials
We'll you could use the ibm-cos-sdk Node library https://www.npmjs.com/package/ibm-cos-sdk. You'll need to use your HMAC credentials.
var config = {
endpoint: '<endpoint>',
ibmAuthEndpoint: 'https://iam.ng.bluemix.net/oidc/token',
serviceInstanceId: '<resource-instance-id>',
accessKeyId: '<HMAC access_key>',
secretAccessKey: '<HMAC secret access key>'
};

How to get VCAP_SERVICES environment variables WITHOUT binding to an application?

Frequently, I'm create standalone services in Bluemix. For example, Analytics for Apache Hadoop, Cloudant and DashDB.
I don't need an application to work with these services, but it seems I have to bind to an application just to get access to the VCAP_SERVICES environment variables with urls, usernames, passwords, etc.
Question: How to get VCAP_SERVICES environment variables WITHOUT binding to an application?
For many services, you will have to bind them to an app in order to get the VCAP_SERVICES credentials.
There is a service key capability which some services are starting to adopt which allows you to create and access credentials without binding to an app. Using the cf command line tool, the commands below are available to use if a service supports them:
SERVICES:
create-service-key, csk Create key for a service instance
service-keys, sk List keys for a service instance
service-key Show service key info
delete-service-key, dsk Delete a service key
The CloudFoundry docs at https://docs.cloudfoundry.org/devguide/services/service-keys.html provide more detail.
In the Bluemix UI, you would see a 'Service Credentials' option in the panel when viewing a service dashboard when a service supports this capability. Selecting this option allows you to see credentials that have been created as well as an "Add Credentials" button to create new ones.