Expand my Community achievements bar.

SOLVED

How to store secret keys in AEM cloud and use them in Cloud configurations as $[env:SITE_KEY]

Avatar

Level 2

How to use secret keys/variables in Cloud configurations like Captcha.
Tried saving the property as $[env:SITE_KEY], but it didn't work. PFA screenshot.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

No, you cannot do that. 

View solution in original post

6 Replies

Avatar

Community Advisor

@Rohan0794 You can store these as configuration entries in the cloud manager and then use the same in the OSGI configs. More details here - 

https://medium.com/@toimrank/aem-as-a-cloud-service-osgi-configuration-secret-and-environment-variab...

 

Avatar

Community Advisor

Hello @Rohan0794 

 

1. We need to store the variable as a Secret in Cloud Manager for that specific environment.

aanchalsikka_0-1700793506299.png

 

2. We need to specifiy that its a secret, in OSGi config.

  • ${secret.VARIABLE_NAME}

3. Make sure that the OSGi configuration is picked up in the environment. Verify the active configuration via Developer console in CM.


Aanchal Sikka

Avatar

Level 2

I am aware that we can store in Cloud manager and retrieve in OSGI using the above syntax but can we access the environment variable or secret in JCR properties directly using $[env:<variable_name>]?



Avatar

Correct answer by
Employee Advisor

No, you cannot do that. 

Avatar

Level 2

Can we get OSGI values in JCR properties with some syntax?

Avatar

Employee Advisor

you cannot read OSGI properties via the JCR API. Also I am not aware that you can access OSGI properties directly in HTL.

You always have to go via an OSGI service, which can OSGI properties as service properties.