What is the recommended way to manage environment-specific configurations (like API endpoints or feature flags) in AEM as a Cloud Service?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @AryaBa1,
Managing environment-specific configurations should be done using Context-Aware Configuration (CAC) in combination with runmode-specific OSGi configs. Here's a breakdown of the recommended approach:
CAC allows you to store config values in the content structure (e.g., /conf/my-site
) and access them dynamically based on the page context.
Example: Store a config.json
under /conf/my-site/settings/cloudconfigs/my-api-config
.
{
"apiUrl": "https://dev.api.example.com",
"featureFlag": true
}
Access in Sling Models using @ValueMapValue
or via ConfigurationBuilder
.
Define environment-specific values in /apps/myproject/osgiconfig/config.<runmode>....cfg.json
.
For example:
/apps/myproject/osgiconfig/config.dev/com.myproject.core.services.MyApiConfig.cfg.json
{
"api.endpoint": "https://dev.api.example.com"
}
The correct config is automatically picked based on the Cloud Manager environment's runmode (dev
, stage
, prod
).
Never use if(runmode == "dev")
logic in code.
Instead, inject configuration using OSGi or CAC, and keep code environment-agnostic.
For non-code configuration like secrets or toggles, use Adobe Cloud Manager pipeline variables.
Inject them via OSGi or environment variable bridge patterns.
Hope that helps!
Hi @AryaBa1,
Managing environment-specific configurations should be done using Context-Aware Configuration (CAC) in combination with runmode-specific OSGi configs. Here's a breakdown of the recommended approach:
CAC allows you to store config values in the content structure (e.g., /conf/my-site
) and access them dynamically based on the page context.
Example: Store a config.json
under /conf/my-site/settings/cloudconfigs/my-api-config
.
{
"apiUrl": "https://dev.api.example.com",
"featureFlag": true
}
Access in Sling Models using @ValueMapValue
or via ConfigurationBuilder
.
Define environment-specific values in /apps/myproject/osgiconfig/config.<runmode>....cfg.json
.
For example:
/apps/myproject/osgiconfig/config.dev/com.myproject.core.services.MyApiConfig.cfg.json
{
"api.endpoint": "https://dev.api.example.com"
}
The correct config is automatically picked based on the Cloud Manager environment's runmode (dev
, stage
, prod
).
Never use if(runmode == "dev")
logic in code.
Instead, inject configuration using OSGi or CAC, and keep code environment-agnostic.
For non-code configuration like secrets or toggles, use Adobe Cloud Manager pipeline variables.
Inject them via OSGi or environment variable bridge patterns.
Hope that helps!
Hi @AryaBa1 ,
In AEMaaCS, the recommended approach for managing environment-specific configurations - like API endpoints, feature flags, and authentication keys—is to use Adobe's structured configuration methods. These include Context-Aware Configurations (CAConfig), OSGi runmode-specific configurations, and secure secrets management.
Use the /conf folder to store values like API endpoints and feature flags.
Supports inheritance and environment-specific overrides (e.g., /conf/mysite/settings/dev).
Access via Sling Models using the ConfigurationBuilder API.
Best for:- Frontend configuration, feature toggles, and dynamic values.
Define OSGi settings directly in the codebase with environment-specific folders:
These are deployed with the application code, ensuring consistency across environments.
ui.config/src/.../config.dev/com.example.MyServiceImpl.cfg.json
ui.config/src/.../config.prod/com.example.MyServiceImpl.cfg.json
Best for: Backend settings like service URLs, timeouts, and integration parameters.
Do not store secrets (like API keys) in OSGi configs or CAConfig.
Instead, use Adobe I/O Runtime Secrets or external vaults (e.g., HashiCorp Vault, Azure Key Vault).
Best for: Secure handling of sensitive credentials and tokens.
Try these and let me know if you need more explanation about them.
Thanks.
Views
Replies
Total Likes
Hi,
Cloud Manager variables are the preferred option for environment-specific configurations. However, if you need to separate configurations based on "path," such as in a multi-tenant setup, then Context-Aware configurations are the appropriate choice
You can learn more here:
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/usi...
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/dep...
Hope this helps
Views
Likes
Replies
Views
Likes
Replies