Working with the Mta.yaml File


After completing this lesson, you will be able to:

  • Define the information in the mta.yaml file for the MTA build and deploy processes.

Introducing the mta.yaml file

Introducing the mta.yaml File

Watch this video to know more about the mta.yaml file.

The following video explains the basic elements about the content and usage of the mta.yaml file.

Defining dependencies

Defining Dependencies

The modules in the multi-target application can depend one on the other, as well they can depend on external services that are required to be instantiated in the Cloud Foundry environment. For example, a UI module could require the existence of a back-end application module, and a back-end application could require to be bound to a database service instance.

Use the requires statement to define dependencies:

  • Between module and module: the statement influences the deployment order during the execution of the cf deploy command. The required module is deployed before, the requiring module is deployed after.
  • Between module and resource: when executing cf deploy, in Cloud Foundry a service binding is created between the module application and the service instance (for example my-res). In case the service instance is not yet existing in Cloud Foundry, you will have different behaviors based on the service type: in some cases a new service instance is automatically created, in other cases a deployment error is generated.

Defining configuration parameters for modules

Within the mta.yaml file, on module definition, you can include a parameters: statement followed by a list of name: value pairs.

Defining environment variables

In the mta.yaml file, you can use the properties statement to define a list key: value pairs. On application deployment to Cloud Foundry, such pairs determine the creation of values in the User-Provided Variablestab. Such variables are accessible by the running application as OS level environment variables.

Exchanging properties between modules

Within the mta.yaml file, you can define and exchange configuration variables between modules. Such variables are calculated and exchanged at deploy time. They are mostly used for the following purposes:

  • To distribute the overall configuration variables to all the interested modules in the MTA
  • To exchange information between modules that are available at deploy time only, for example, the application URL of a module

Watch this video to learn how to use the provides and requires statements o exchange configuration variables between modules.

Reading environment variables with Node.js

Reading environment variables with Java

In Java, local environment variables can be read using the System.getenv(…) method.

Log in to track your progress & complete quizzes