Monday 1 April 2024

Sharing SAP HANA Cloud instance to multiple subaccounts and creating HDI containers

Overview


This article is telling you how to share single SAP HANA Cloud instance to multiple subaccounts and create HDI container from each subaccount. I am using SAP Cloud Application Programming Model (CAP) Node.js for this article.

Background


When I am planning SAP BTP project system architecture, I am following account model and preparing three subaccounts (development, test, production). At that time, I feel how can I reduce cost of subscription to each subaccount, especially for development environment.

Normally, persistence service is expensive than others. In my use cases, SAP HANA Cloud is the one. And I seldom use minimum data volume in development environment, because development environment is just for checking deployment to Cloud Foundry environment. I am developing CAP app locally with SQLite database e.g.

I think if I can share SAP HANA Cloud instance in test subaccount with development subaccount, I can save some money. I would like to share this tips, and it is helpful for early stage users like me.

Key points


Setup in HANA Cloud central (Instance Mapping)

As prerequisite, I already subscribed to SAP HANA Cloud `hana-cloud-tools` plan in my test environment.

I go to SAP HANA Cloud Central from cockpit, and find my HANA Cloud database instance. Click three dots (...) button and select `Manage Configuration` menu. In configuration page, click Instance Mapping tab.

Click add mapping button and input Cloud Foundry org and space ID (space is optional). Instance mapping is only available for instances hosted in the same BTP region. In my use case, test subaccount (first entry) and development subaccount (second entry).

Sharing SAP HANA Cloud instance to multiple subaccounts and creating HDI containers
Add Cloud Foundry Org/Space

Configuration of deployment of HDI container 

In the SAP HANA Cloud Central, copy Instance ID of database (for example 584fxxxx-xxxx-xxxx-xxxx-xxxxxxxx482b). This is used at next step.

Sharing SAP HANA Cloud instance to multiple subaccounts and creating HDI containers
Get HANA Cloud database ID
 
Assume I am implementing some CAP OData service and would like to deploy to development Cloud Foundry environment, that does not have SAP HANA Cloud instance. 

In the `mta.yaml` file, set above database instance ID to `database_id` under HDI container config as below. That is all for connecting to HANA Cloud database in test environment. I can deploy to Cloud Foundry development environment as usual.

resources
  - type: org.cloudfoundry.managed-service
    name: MyProject-service-db
    parameters:
      service: hana
      service-plan: hdi-shared
      config:
        database_id: 584fxxxx-xxxx-xxxx-xxxx-xxxxxxxx482b
 
Actually, it is better to split this config to MTA extension file (hdi.mtaext for example) as below. This extension file should be excluded from source repository (Git) and locally managed. When combining extension, run command `mbt build -e hdi.matext`. For example, this strategy is effective in SAP Cloud Transport Management.

ID: MyProject.hdi
_schema-version: 3.2.0
version: 1.0.0
extends: MyProject

resources:
  - name: MyProject-service-db
    parameters:
      config:
        database_id: 584fxxxx-xxxx-xxxx-xxxx-xxxxxxxx482b

No comments:

Post a Comment