IBM Cloud Docs
Using services with classic infrastructure assets

Using services with classic infrastructure assets

You can easily use API-based public IBM Cloud® services with your classic infrastructure assets. All APIs are secure and encrypted so that your data is protected.

You can gain insights and cognitive knowledge by calling Watson APIs from your apps to make them more personalized. Or, use data and analytics services to tap into high-performance analytics for your apps. Or, choose database-as-a-service where you can leave the management to IBM Cloud.

Modernize your application development by using containers with services like Active Deploy and Delivery Pipeline. You can then use the IBM® VPN service to communicate and connect your container in a private network to the classic infrastructure private network. All of the usage charges of the compute resources and services are reflected in your IBM Cloud invoice.

Add a service to classic infrastructure assets

For example, do you want to add cognitive capabilities from Watson to your apps that are running on classic infrastructure bare metal servers? You can add a service such as Personality Insights to help understand your app's user by completing the following steps:

  1. In the IBM Cloud console, search for the service in the catalog.
  2. Create an instance of the service with just a few clicks.
  3. Set up the service to run with your existing code by copying the service credentials and adding them to your application.
  4. After the update to the app, deploy the new version to your classic infrastructure assets.

Add a service to classic infrastructure assets by using the API

For example, do you want to add cognitive capabilities from Watson to your apps that are running on classic infrastructure bare metal servers? You can add a service such as Personality Insights to help understand your app's user by completing the following steps:

  1. Create an instance of the service by calling Resource Controller API as shown in the following example request:

    curl -X POST https://resource-controller.cloud.ibm.com/v2/resource_instances -H 'Authorization: Bearer <>' -H 'Content-Type: application/json' -d '{
       "name": "my-instance",
       "target": "bluemix-global",
       "resource_group": "5g9f447903254bb58972a2f3f5a4c711",
       "resource_plan_id": "0be5ad401ae913d8ff665d92680664ed",
       "tags": [
         "my-tag"
       ]
     }'
    
    CreateResourceInstanceOptions createResourceInstanceOptions = new CreateResourceInstanceOptions.Builder()
     .name(resourceInstanceName)
     .target(targetRegion)
     .resourceGroup(resourceGroup)
     .resourcePlanId(resourcePlanId)
     .build();
    
    Response<ResourceInstance> response = service.createResourceInstance(createResourceInstanceOptions).execute();
    ResourceInstance resourceInstance = response.getResult();
    
    System.out.printf("createResourceInstance() response:\n%s\n", resourceInstance.toString());
    
    const params = {
     name: resourceInstanceName,
     target: targetRegion,
     resourceGroup: resourceGroupGuid,
     resourcePlanId: resourcePlanId,
    };
    
    resourceControllerService.createResourceInstance(params)
     .then(res => {
       instanceGuid = res.result.guid;
       console.log('createResourceInstance() response:\n' + JSON.stringify(res.result, null, 2));
     })
     .catch(err => {
       console.warn(err)
     });
    
    resource_instance = resource_controller_service.create_resource_instance(
       name=resource_instance_name,
       target=target_region,
       resource_group=resource_group,
       resource_plan_id=resource_plan_id
    ).get_result()
    
    print('\ncreate_resource_instance() response:\n',
         json.dumps(resource_instance, indent=2))
    
    createResourceInstanceOptions := resourceControllerService.NewCreateResourceInstanceOptions(
     resourceInstanceName,
     targetRegion,
     resourceGroup,
     resourcePlanID,
    )
    
    resourceInstance, response, err := resourceControllerService.CreateResourceInstance(createResourceInstanceOptions)
    if err != nil {
     panic(err)
    }
    
    b, _ := json.MarshalIndent(resourceInstance, "", "  ")
    fmt.Printf("\nCreateResourceInstance() response:\n%s\n", string(b))
    
  2. Retrieve the credentials (resource key). Call the Resource Controller API as shown in the following example request and pass the ID associated with the instance.

    curl -X GET https://resource-controller.cloud.ibm.com/v2/resource_keys/23693f48-aaa2-4079-b0c7-334846eff8d0 -H 'Authorization: Bearer <IAM_TOKEN>'
    
    GetResourceKeyOptions getResourceKeyOptions = new GetResourceKeyOptions.Builder()
     .id(instanceKeyGuid)
     .build();
    
    Response<ResourceKey> response = service.getResourceKey(getResourceKeyOptions).execute();
    ResourceKey resourceKey = response.getResult();
    
    System.out.printf("getResourceKey() response:\n%s\n", resourceKey.toString());
    
    const params = {
     id: instanceKeyGuid,
    };
    
    resourceControllerService.getResourceKey(params)
     .then(res => {
       console.log('getResourceKey() response:\n' + JSON.stringify(res.result, null, 2));
     })
     .catch(err => {
       console.warn(err)
     });
    
    resource_key = resource_controller_service.get_resource_key(
       id=instance_key_guid
    ).get_result()
    
    print('\nget_resource_key() response:\n',
         json.dumps(resource_key, indent=2))
    
    getResourceKeyOptions := resourceControllerService.NewGetResourceKeyOptions(
     instanceKeyGUID,
    )
    
    resourceKey, response, err := resourceControllerService.GetResourceKey(getResourceKeyOptions)
    if err != nil {
     panic(err)
    }
    b, _ := json.MarshalIndent(resourceKey, "", "  ")
    fmt.Printf("\nGetResourceKey() response:\n%s\n", string(b))
    
  3. Copy the service credentials and add them to your application.

  4. After the update to the app, deploy the new version to your classic infrastructure assets.