Oct 19, 2023
Integrating Adobe Experience Manager as a Cloud Service (AEMaacS) has made Cloud Manager an integral part of our workflow. This connection has introduced numerous benefits, including the capability to establish variables within Cloud Manager.
The concept of "Variables" was introduced in Cloud Manager a while ago, and even though we all have a general understanding of what they are, there are instances where we may need some assistance in knowing how, when, or why to use them.
In this blog, we will strive to address these fundamental questions and also highlight the best practices associated with their implementation.
What Are Cloud Manager Variables (And What Types Are Available)?
In broad terms, these are symbolic names (variables) that represent values stored within Cloud Manager at different stages of the application's lifecycle.
Cloud Manager offers two categories of variables: Pipeline and Environment-Specific variables. The main difference between these two lies in their availability.
Pipeline Variables are accessible during the build phase of a pipeline execution, while Environment-Specific variables are accessible within the "environment" where the application will be launched (runtime). Both Pipeline and Environment-Specific variables can fall into one of these flavors:
-
Common Variables.
-
Secrets (For sensitive information)
How Can I Create a Cloud Manager Variable?
There are three interfaces available to create them:
-
Using Cloud Manager API
-
Using Cloud Manager CLI
-
Using the Cloud Manager UI
Please note that you must be a member of the Deployment Manager role in order to manage variables.
When Should You Use Them?
Use cases for Cloud Manager variables primarily fall into one of these three categories:
-
OSGI Configurations: This is perhaps the most useful and common use case. By combining Environment Variables with Run modes, you can extract the utmost value from these features. For instance, if you require setting a password, API keys, integration URLs, etc., you could employ a Variable of the secret type.
-
Dispatcher Configurations: The AEM project archetype is replete with such examples. However, there is a caveat regarding using secret variables, as these are not intended for dispatcher configs. . However, regular environment variables also serve as an excellent choice for configuring the dispatcher.
-
Specific Build Operations: Pipeline variables are often overlooked, yet they are a valuable resource to consider when customizing build operations. For instance, if you wish to automatically deploy content when operating in a specific environment (like a local setup), a pipeline variable can enable a profile tailored for such a task.
Why Should You Use Them?
The same reasons for using any variable instead of hardcoded values apply here. However, let’s emphasize the top 5 reasons:
-
Security. Variables of the "secret" type offer a more secure and convenient method to manage and store sensitive data.
-
Separation of Concerns. By using environment variables, you will separate configuration data from your application logic.
-
Scalability and Deployment. When using environment variables, you can configure different values for each environment (development, stage, production) without changing the application code.
-
Flexibility. Environment variables allow you to quickly adapt and reconfigure your application without a code deployment.
What About Best Practices?
What we have learned so far is all you need to know about environment variables in Cloud Manager, let's talk now about some best practices when using them:
-
Select the Appropriate Type: To determine whether to use environment variables, consider these questions:
-
Is the information needed in every environment?
-
Will the information differ across environments?
-
How sensitive is the information? Should it be protected?
-
How frequently will the information change?
-
If changes are needed, can you afford a complete code deployment before making those changes?
-
-
Follow the Naming Convention: Maintain consistency by adhering to Adobe's naming conventions
-
Note that different conventions exist for Pipelines Variables and Environment Specific variables
-
-
Automate Variable Creation: If your application requires specific variables to function properly, consider automating their creation. For example, you could employ a shell script using the CloudManager CLI.
-
Consider Overall Environment Impact: Reflect on how variable usage will influence all environments, including local development.
-
OSGI Config Usage: Always employ default values when using variables in OSGI configurations. . These defaults come into play when no variable is detected during runtime. Also, keep in mind Adobe's recommendations for working with OSGI Configurations.
-
Utilize the "Service Applied" Scope: Opt for the "service applied" scope when working with variables.
-
Document Usage: While the variable's name should hint at its purpose, it's advisable to document these application dependencies in a clear and accessible location for those responsible for managing your application.
Wrapping Up
Cloud Manager variables offer several advantages, primarily related to security, configuration management, and portability. Using them correctly can lead to unlocking their full potential.
Related Insights
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.