top of page

Cloudhub 2.0 Deployment using mule maven plugin (Part 2)

Updated: Apr 26, 2023

In previous blog, you have seen that how you can easily deloy mule application on cloudHub 2.0 using mule maven plugin and no of parameters explained.

In this blog, I am going to take this example to near real world project structure and deploy on cloudhub 2.0

Section 1 - add properties files and load as per environment

In this section we will add configuration properties element to read configuration files and structure of properties files

Lets add common.yaml and dev.yaml files on main/resources/configs/ folder location as below

lets add below property-


version: Cloudhub2.0

on local.yaml and on dev.yaml


version: DevCloudhub2.0

Update DataWeave for welcome message as below

"message": "welcome to " ++ p('cloudhub.version')

So now it will read cloudhub.version value from properties file which will be loaded using configuration properties element

<global-property doc:name="Global Property"doc:id="24103b02-cc17-4444-8e0d-214072e75aca" name="env" value="local" />
<configuration-properties doc:name="environmenal-properties" doc:id="39358297-e5d3-4e3d-9d3c-1e247ded0134" file="configs/${env}.yaml" />

So this will make sure local file will be always loaded if there is no "env" argument is passed.In case if you need to load dev.yaml file then you need pass -Denv=dev argument while running application

At this moment you can run application on anypoint studio either passing -Denv=dev argument as well as without sending any argument. Application should be up and running .

In case dev argument is passed then you will see message as below

  "message": "welcome to CloudHub2.0"

Section 2- Secure Properties Now lets move to next practical thing in which we need to secure passwords/token and keep it in encrypted state on properties file.

Let's use AES encryption here.How to encrypt and how secure properties work is provided on below document-

So we will jump to encrypt a value using key - AEsKeySotken1242

You can use below website to encrypt and decrypt key using secrets

Now lets add this encrypted value for cloudhub2.0 on common.yaml file and Devcloudhub2.0 encrypted value on dev.yaml

Next thing is we need to get secure properties global element so go to mule pallet -> click on add module and add mule 4 secure properties module.

Now click on global element and click add secure properties config

Add below code on which will read encKey from command argument and local properties file on the basis of env argument variable.

<global-property doc:name="Global Property" doc:id="33bff223-05d9-4f66-ba7c-4990959a844c" name="encKey" value="${encKey}" />
<secure-properties:configname="secure-properties-config" doc:name="Secure Properties Config" doc:id="9ab92174-9b48-4cf9-9c12-af077a45b5c3" file="configs/${env}.yaml" key="${encKey}" />

Now let's deploy this application on cloudhub with dev.yaml properties loaded

Run below command on project folder on command prompt

> mvn clean deploy. --this will upload updated code on exchange

>mvn clean deploy -DmuleDeploy -Denv=dev -DencKey=AEsKeySotken1242

this will pull application from exhcange and deploy on cloudhub 2.0 with dev.yaml file loaded

Now application up and running you can check if application is reading encrypted value and that too from dev.yaml file

Happy Coding !!

Reference :-

bottom of page