Use of Environment Variables in AEMaaCS

03 / Aug / 2023 by Rahul Pandey 0 comments

Benefits of Environment Variables

Environment variables (EV) offer a host of benefits to users of AEM as a Cloud Service:

  1. EVs are only required to be configured once and can be updated and deleted when required.
  2. The value of an EV can be updated at any point in time and take effect immediately without any code changes or deployments.
  3. The use of EV is the way to separate code from configuration and remove the need to include sensitive information in version control.
  4. EVs can improve the security of the AEM as a Cloud Service application since they live outside of the code.

Configuring Environment Variable on AEMaaCS

  1. log-in into the Adobe Cloud Manager.
  2. Select the Environments tab for the chosen program then select the environment for which you want to create an environment variable in the left navigation panel.
  3. Select the Configuration tab then select Add to open the Environment Configuration dialog.
  4. Enter the variable name, value and type. For storing passwords use secret as the type.
  5. Save the configuration.

Use of EVs in OSGI Configuration 

  1. To use environment variables in your OSGi configuration, the config file should be in .cfg.json format.
  2. Variables should be written as $[env:<environment variable name>]  
  3. To use secret variables syntax will be as $[secret:server-api-key]
  4. Default values for EVs can be used, In case of the EV is not found in particular environments. $[env:<environment variable name>;default=<default value>]

 

Testing EVs in AEM Local Instance

  1. For testing EVs in the local environment, the code will remain the same.
  2. Only we need to add environment variables in the local AEM instance running session.
  3. To add EV in local export the variable just before starting the AEM instance.
  4. The use of shell script is recommended to start the AEM instance in the local environment.
  5. Example shell script can be as below –

 

start.sh

 

Explore our blogs for an in-depth understanding of various trending topics.

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *