Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

Adding OSGi Configurations via Environment Variables in AMS.

Avatar

Level 1

Hi

I want to add some OSGi configurations through environment variables in Adobe Managed Services (AMS). While I see an option to add environment variables in Adobe Cloud Service, I couldn’t find a similar feature in AMS. Could you suggest the best way to achieve this in AMS?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi @ayetkur,

I believe pipeline variables are only available during the build process, and OSGi configurations cannot reuse them.

View solution in original post

6 Replies

Avatar

Level 2

Hi @ayetukur ,

As far as I know, there is no such option with AMS and you can only use the pipeline variables. I will be happy to be wrong, because we miss this feature as well.

Avatar

Level 1

Thank you for the reply @user62746 ,
If i use the pipeline variables can those values add to the osgi configs?,
I see the pipeline variable will apply for pom xml .
Please suggest 

Avatar

Correct answer by
Level 2

Hi @ayetkur,

I believe pipeline variables are only available during the build process, and OSGi configurations cannot reuse them.

Avatar

Community Advisor

AMS is built on traditional virtualized infrastructure (AEM instances on VMs in Adobe's managed cloud env like AWS or Azure). OSGi configurations here are part of deployment package which remain static until the deployments.


You can try a workaround for AMS by using CAConfigs (Context-Aware Configurations). You can use the CAConfig API to retrieve the configuration dynamically.

Please refer Apache Sling Context-Aware Configuration for more details.

Hope this helps!

Rohan Garg

Avatar

Community Advisor

Hi @ayetukur 

Before Environment variables, we used CryptoSupport to protect secrets https://sling.apache.org/documentation/bundles/commons-crypto.html  

 

Another approach could be you can use pipeline variables or other secret manager and integrated with pipeline

https://medium.com/@arunpatidar26/secrets-manager-aem-configs-1c2a23124f7a

 



Arun Patidar

Avatar

Level 5

In Adobe Managed Services (AMS), the process of managing OSGi configurations via environment variables is slightly different compared to Adobe Cloud Services, but there are ways to achieve this.

Approach for AMS:

  1. Environment Variables in AMS:
    AMS allows environment variables to be configured at the infrastructure level, but they are not directly tied to OSGi configurations in the same way they are in Adobe Cloud Services. However, you can still use environment variables in AMS to dynamically configure certain settings.

  2. Use the OSGi Configuration API:

    • To configure OSGi settings dynamically based on environment variables, you can use the OSGi Configuration API in your custom bundles or services.
    • You can retrieve the environment variables programmatically (via Java's System.getenv()) and then apply them to OSGi configurations at runtime using the ConfigurationAdmin service.
  3. Custom Solution with Sling or Servlet:

    • If you need to read environment variables and inject them into OSGi configurations, you can create a Servlet or a Sling Post Processor that:
      • Reads the environment variables.
      • Programmatically updates the corresponding OSGi configurations using the ConfigurationAdmin service.
  4. Deployment Process:

    • When deploying on AMS, you may need to configure environment variables on the server level (in the crx-quickstart configuration or system settings) via AMS support or using custom startup scripts if AMS allows access to this level of configuration.
    • Alternatively, you can set the environment variables via Vault or JCR configuration repositories and reference them in your OSGi configuration files.

Steps:

  • Create a custom bundle that retrieves the environment variables and updates the OSGi configuration.
  • Deploy the bundle via AMS deployment pipeline.
  • Use AMS deployment tools to inject values into the system environment or custom scripts as needed.

Summary:

While AMS doesn’t directly support adding OSGi configurations through environment variables like in Adobe Cloud Services, you can achieve this by creating a custom Java bundle that reads the environment variables and dynamically updates the OSGi configurations via the ConfigurationAdmin API.