Skip to content

Latest commit

 

History

History
86 lines (72 loc) · 3.11 KB

File metadata and controls

86 lines (72 loc) · 3.11 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 it’s dependency to ti in the requires element. As in MTAs apps are defined as modules, this mechanism can be used to e.g. 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

Oficial documemtation in Help SAP Portal

Try out

Deploy

You can directly deploy the built app of this example from the current directory and the modelled 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.

Alternatively build & deploy the mta from mta.yaml

To build and deploy an MTA from a link:mta.yaml[mta.yaml development descriptor], instead of `cf deploy ./` run the following commands
#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

```bash
#let's see the actuall 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

# and 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

#consumed as expected :)