Environment variables in Cloud Manager environment-variables
Standard environment variables can be configured and managed via Cloud Manager. They are provided to the run time environment and can be used in OSGi configurations.
Environment variables can be either environment-specific values or environment secrets, based on what is being changed.
About environment variables overview
Environment variables provide several benefits for AEM as a Cloud Service users, including the following:
- They allow the behavior of your code and application to vary based on context and environment. For example, they can be used to enable different configurations in the development environment compared to the production or stage environments to avoid costly mistakes.
- They only need to be configured and set up once and can be updated and deleted when necessary.
- Their values can be updated at any time and take effect immediately without requiring code changes or deployments.
- They can separate code from configuration and remove the need to include sensitive information in version control.
- They improve AEM as a Cloud Service application security because they exist outside the codebase.
Typical use cases for using environment variables include the following:
- Connecting your AEM application with different external endpoints.
- Using a reference when storing passwords instead of storing them directly in the code base.
- Multiple development environments exist in a program, and some configurations differ from one environment to another.
Add an environment variable add-variables
If you want to add multiple variables, Adobe recommends that you add the first variable, then use
To add, update, or delete environment variables, you must be a member of the Deployment Manager role.
To add an environment variable:
-
Log into Cloud Manager at my.cloudmanager.adobe.com and select the appropriate organization.
-
On the My Programs console, select the one you want to manage.
-
From the side menu, click Environments.
-
On the Environments page, select a row in the table that has the environment for which you want to add an environment variable.
-
On the environment’s detail page, click the Configuration tab.
-
Click
Add / Update.
If you are adding an environment variable for the first time, click Add Configuration in the center of the page.
-
In the Environment Configuration dialog box, enter the details in the first row of the table.
table 0-row-2 1-row-2 2-row-2 3-row-2 4-row-2 Field Description Name A unique name of the configuration variable. It identifies the specific variable that is used in the environment. It must adhere to the following naming conventions:
- Variables can only contain alphanumeric characters and the underscore (
_). - There is a limit of 200 variables per environment.
- Each name must be 100 characters or less.
Value The value that the variable holds. Step Applied Select the service to which the variable applies. Select All to have the variable applied to all services.
- All
- Author
- Publish
- Preview
Type Select if the variable is normal or a secret.
- Variables can only contain alphanumeric characters and the underscore (
-
Click
Add.Add additional variables as needed.
-
Click Save.
A spinner with the status Updating is shown in the upper-right corner of the table. A spinner also appears to the left of any newly added variables. These statuses indicate that the environment is being updated with the configuration. After completion, the new environment variable is visible in the table.
Update an environment variable update-variables
After you have created environment variables, you can update them using
If you want to update multiple variables, Adobe recommends that you use the Environment Configuration dialog box to update all necessary variables at once before clicking Save. This approach lets you update them with a single environment update.
To update an environment variable:
-
Log into Cloud Manager at my.cloudmanager.adobe.com and select the appropriate organization.
-
On the My Programs console, select the one you want to manage.
-
From the side menu, click Environments.
-
On the Environments page, select a row in the table that has the environment for which you want to update a variable.
-
On the environment’s detail page, click the Configuration tab.
-
Click
Add / Update. -
In the Environment Configuration dialog box, click
in the last column of the row of the variable you want to change. -
In the drop-down menu, click Edit.
-
Update the value of the environment variable as necessary.
When editing a secret, the value can only be updated, not viewed.
-
Do one of the following:
- Click
to apply the change. - Click
to undo the change.
- Click
-
Click Save.
A spinner with the status Updating is shown in the upper-right corner of the table. A spinner also appears to the left of any updated variables. These statuses indicate that the environment is being updated with the configuration. After completion, the updated environment variable is visible in the table.
Delete an environment variable delete-env-variable
- Log into Cloud Manager at my.cloudmanager.adobe.com and select the appropriate organization.
- On the My Programs console, select the one you want to manage.
- From the side menu, click Environments.
- On the Environments page, select a row in the table that has the environment for which you want to update a variable.
- On the environment’s detail page, click the Configuration tab.
- Click
Add / Update. - In the Environment Configuration dialog box, click
in the last column of the row of the variable you want to change. - In the drop-down menu, click Delete to remove the variable immediately.
- Click Save.
Use of environment variables using
Environment variables can make your pom.xml configurations more secure and flexible. For example, passwords do not need hard-coded values, and your configuration can adapt to environment variable values.
You can access environment variables and secrets through XML as follows:
${env.VARIABLE_NAME}
See Setting Up Project for an example of how to use both types of variables in a pom.xml file.
See also the official Maven documentation for more details.
Availability of environment variables availability
Environment variables can be used in several places, as follows:
Only regular environment variables can be used with the Dispatcher.
- Secrets cannot be used.
- Environment variables cannot be used in
IfDefinedirectives. - Validate your use of environment variables with the Dispatcher locally before deploying.