Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Team,
I Have a java code which brings env variables from secrets manager (AWS) and places them into global map objects .
I am presently loading this values to context explicitly as below ...
context.project_name =((com.fasterxml.jackson.databind.JsonNode) globalMap.get("project_name")).asText();
but for future we want to avoid loading context variables like above and load them using some automated way .
I tried using below code but it is not loading context variables ...
log.info(context.keySet().size())
for(Object o : keys){
log.info(o+" -> "+context.get(o));
}
Adding more info below guys ,
FYI... below is the code I am using for reading the data from AWS secrets manager after completing authentication from multiple URL's .
I receive data in an object and using for looping I can read them .... I have only issue in loading same into context variables (I want this step to be automated).
while(propertySources.hasNext()) {
JsonNode propertySource = propertySources.next().get("source");
Iterator<String> properties = propertySource.fieldNames();
while(properties.hasNext()) {
String field = properties.next();
String value = propertySource.get(field).asText();
log.info(field+" | "+propertySource.get(field));
if(value.startsWith("arn:aws:secretsmanager")) {
getSecretValueRequest.setSecretId(value);
String secret = secretsManager.getSecretValue(getSecretValueRequest).getSecretString();
context.put(field, secret); --- > this seems to be not working as my context variables declared in the job are not loaded with the desired values .
globalMap.put(field, secret); ---> this I am able to access values using globalMap.get() but we need to manually assign them using below commented value (I want the below to be automated instead of calling it manually ...)
//context.EMCS_URL=((com.fasterxml.jackson.databind.JsonNode)globalMap.get("EMCS_URL")).asText();
}else {
context.put(field, propertySource.get(field));
globalMap.put(field, propertySource.get(field));
}
}
please let me know if anyone has a solution to the above ...
the above code just puts the values to log info , using same objects how can I load context variables ...
please suggest an solution to this to load context variables without explicitly mentioning .....