OSGi variable references with and without default values in AEM as a Cloud Service
This article explains the behavior of OSGi configuration variable references in Adobe Experience Manager (AEM) when a default value is specified and when it is not, and provides guidance for predictable configuration management.
Description description
Environment
- Adobe Experience Manager as a Cloud Service
- Cloud Manager environment variables and secrets
- OSGi configurations
Issue/Symptoms
-
An OSGi configuration references a secret without a default value. For example:
code language-none "smtp.password": "$[ secret:EMAIL_PASSWORD] " -
An OSGi configuration references an environment variable with a default value. For example:
code language-none "smtp.user": "$[ env:EMAIL_USERNAME;default=myApiKey] " -
You need to determine how AEM resolves these placeholders when the referenced environment variable or secret is not configured.
-
You need to determine how to manage OSGi configuration references when the associated environment variables or secrets aren’t always present.
Cause
OSGi configuration variable resolution depends on whether the reference includes a default value. When a referenced variable is missing and no default value is specified, the placeholder remains unresolved. When an environment variable reference includes a default value, the placeholder resolves to that value if the environment variable is not configured. The ;default= syntax is not officially supported for secret references, so remove the reference if the associated secret is deleted.
Resolution resolution
Follow the steps below to manage OSGi configuration variable references:
-
When an environment variable isn’t always present, add a
;default=clause to its OSGi configuration reference. For example:code language-none $[ env:EMAIL_USERNAME;default=myApiKey]This configuration resolves the placeholder to the specified default value when the environment variable is not configured.
-
When referencing secrets, don’t rely on the
;default=syntax because it isn’t officially supported. -
If a secret isn’t always present or will be deleted, remove its reference from the OSGi configuration to prevent an unresolved placeholder.
-
If you don’t want to use a default value and the referenced environment variable or secret won’t always be present, remove the reference from the OSGi configuration.
-
Before deleting an environment variable or secret, update the OSGi configuration to remove or modify all references to it.
-
Deploy the updated OSGi configuration before deleting the environment variable or secret. This sequence helps prevent deployment errors caused by unresolved references.
-
For features that require secrets, such as sending email, verify that valid secret values remain configured while the functionality is required.