Skip to content

Latest commit

 

History

History
106 lines (83 loc) · 3.38 KB

File metadata and controls

106 lines (83 loc) · 3.38 KB

Sharing configuration values between apps

The MTA deployment descriptor allows for fixed or dynamically generated values to be shared between the described entities (modules & resources). For one module/resource to consume exposed variables from another, it has to declare its dependency to it in the requires element. As in MTAs apps are defined as modules, this mechanism can be used to share the url of one app in the environment of another:

modules:
  - name: providing-module
    type: application
    properties:
      my-generated-user: ${generated-user}
    provides:
      - name: module-1-provided
        properties:
          user: ${generated-user}  # the ${generated-user} parameter has an unique generated value for each module
          config: "static-string"
          url: ${default-url}
    #...
  - name: consuming-module
    type: application
    requires:
      - name: module-1-provided
    properties:
      m1-user: ~{module-1-provided/user}
      m1-config: '~{module-1-provided/config}-with-suffix'
      m1-url: ~{module-1-provided/url}
    #...
Note
See mta.yaml and mtad.yaml as references for working development and deployment descriptors.

Requirements

Official documentation in the Help SAP Portal

Try it out

Deploy

Deploy from directory

You can directly deploy the built app of this example from the current directory and the modeled mtad.yaml deployment descriptor:

$ cf deploy ./
Deploying multi-target app archive ********/sharing-values-between-apps/my-mta.mtar in org deploy-service / space ******** as ********...
Uploading 1 files...
  ********/sharing-values-between-apps/my-mta.mtar
OK
Deploying in org "deploy-service" and space "********"
...
Process finished.

Build and deploy from mta.yaml file

Alternatively, you can build & deploy the MTA from mta.yaml. To build and deploy an MTA from a mta.yaml development descriptor, run the commands described below.

First build & assemble the MTA archive:

$ mbt build
[2020-04-02 23:47:34]  INFO Cloud MTA Build Tool version 1.0.8
[2020-04-02 23:47:34]  INFO generating the "Makefile_20200402234734.mta" file...
...
[2020-04-02 23:47:34]  INFO the MTA archive generated at: ...

Then deploy the assembled package:

$ cf deploy mta_archives/my-mta_0.0.0-SNAPSHOT.mtar
...

Verify the result

Check the actual app url:

$ cf app providing-module | grep routes
routes:            deploy-service-********-providing-module.cfapps.sap.hana.ondemand.com

Let’s see the generated user value:

$ cf env providing-module | grep my-generated-user
my-generated-user: u]rPqDU-70y(-E0c

Finally, let’s see how the second app consumed the provided values:

$ cf env consuming-module | grep m1
m1-config: static-string-with-suffix
m1-url: https://deploy-service-********-providing-module.cfapps.sap.hana.ondemand.com
m1-user: u]rPqDU-70y(-E0c

Clean up resources

It is recommended to stop or undeploy your MTAs when they are no longer needed. In order to do so, run the following command:

$ cf undeploy <mta-id> -f --delete-services