This example shows how to preserve manually set app environment variables during MTA deployment. This strategy may be useful, for instance, when an operator modifies an app configuration. The modifications should remain even if the configuration isn’t maintained in a particular *.mtaext
extension descriptor, which is provided during deployment.
It is modeled via a module level parameter keep-existing:…
modules:
- name:...
parameters:
keep-existing:
env:true
-
SAP Help Portal: Module-Specific Parameters
You can deploy it directly from an mtad.yaml
file:
$ cf deploy ./ -f ;
Or build an MTAR archive from an mta.yaml
:
$ mbt build -p cf -t . ;
And then deploy the built MTAR archive:
$ cf deploy a.cf.app_0.0.0.mtar -f ;
$ cf env cf-app-keeping-env-changes
...
User-Provided:
...
managed-env-variable: original-env-var-val
$ cf env cf-app-resetting-env
...
User-Provided:
...
managed-env-variable: original-env-var-val
$ cf set-env cf-app-keeping-env-changes new-env-variable new-env-var-val
$ cf set-env cf-app-keeping-env-changes managed-env-variable changed-env-var-val
$ cf set-env cf-app-resetting-env new-env-variable new-env-var-val
$ cf set-env cf-app-resetting-env managed-env-variable changed-env-var-val
$ cf env cf-app-keeping-env-changes
...
User-Provided:
...
managed-env-variable: changed-env-var-val
new-env-variable: new-env-var-val
$ cf env cf-app-resetting-env
...
User-Provided:
...
managed-env-variable: changed-env-var-val
new-env-variable: new-env-var-val
$ cf env cf-app-keeping-env-changes
...
User-Provided:
...
managed-env-variable: original-env-var-val
new-env-variable: new-env-var-val
$ cf env cf-app-resetting-env
...
User-Provided:
...
managed-env-variable: original-env-var-val
Note that app cf-app-keeping-env-changes
has the new-env-variable
var kept, but has the value of managed-env-variable
reset as defined in the mtad.yaml
.
App cf-app-resetting-env
has lost the custom env variable and also has the managed-env-variable
value reset.