Auto Provisioning
Overview¶
In many scenarios, just deploying an application isn't sufficient for the application to be functional, and additional software elements needs to be provisioned.
For example APIs need to be configured in API Manager, client applications created and access to other APIs requested, or anypoint mq queues might need to be configured, and client created, etc
Provisioning all those dependencies manually is not only time consuming but also error prone, so in order to address this issue, EMT has the ability to provision certain dependencies and inject any relevant properties (ie API id) into the application.
The following dependencies are currently supported by EMT:
Those dependencies are defined in anypoint.json, and are automatically provisioned when an application is deployed.
Variables¶
When running the deployment or provisioning, you will be able to specify variables that will be automatically inserted using the expression ${varname}
For example example if your API URL varies and want to be able to specify it when you deploy you just could specify the
variable apiUrl=http://myapp
, and in the anypoint descriptor just set:
A number of variables are also pre-defined and available for you to use:
app.id
: Application idenvironment.id
: Environment Idenvironment.name
: Environment nameenvironment.lname
: Environment name in lower case and with any spaces converted to underscoresorganization.name
: Organization nameorganization.lname
: Organization name in lower case and with any spaces converted to underscores
Additionally you can also use some functions. So for example let's say the you've assigned the variable 'myvar' to 'littleDog'
-
Upper case:
${u:myvar}
This will convert varname to upper case (ie: `littledog`)
-
Lower case:
${l:varname}
This will convert varname to lower case (ie: `LITTLEDOG`)
-
Capitalize:
${c:varname}
This will capitalize varname (ie: `LittleDog`)
-
Base 64 Encode:
${eb64:varname}
This will base 64 encode the variable (ie: `bGl0dGxlRG9n`)
-
Base 64 Decode:
${db64:varname}
This will base 64 decode the variable
-
Add prefix if variable is not empty:
${p:-:varname}
This will add a prefix ( a dash in example above ) to the string value only if the variable value is not empty. If you wish to use `:` a separator you will need to specify it twice (see example below) For example: varname='dog' and an expression `${p:-:varname}black` will result in: `dog-black` varname='' (or variable not set) and an expression `${p:-:varname}black` will result in: `black` varname='dog' and an expression `${p:_:varname}black` will result in: `dog_black` varname='dog' and an expression `${p::::varname}black` will result in: `dog:black`
-
Add suffix if variable is not empty:
${s:-:varname}
This will add a suffix ( a dash in example above ) to the string value only if the variable value is not empty. If you wish to use `:` a separator you will need to specify it twice (see example below) For example: varname='dog' and an expression `my${s:-:varname}` will result in: `my-dog` varname='' (or variable not set) and an expression `my${s:-:varname}` will result in: `my` varname='dog' and an expression `my${s:_:varname}` will result in: `my_dog` varname='dog' and an expression `my${s::::varname}` will result in: `my:dog`
You can also nest variable expressions, for example let's say you defined the variables myvar=varname
and
varname=dog
. You could then write ${${myvar}}
which would result in dog