Setting process.env variable

Hi, is it possible (and with what snippet) to change environment variable while the server is running?

I have currently a hard coded IP address of an ElasticSearch server in my Cloud Code function and I would like to be able to change the address through other cloud code function with master key. An alternative came to my mind, where the IP address would be an entry in the database it feels more reasonably to have it in environment variables.

BTW, is it secure to keep login credentials to that ElasticSearch service including password inside environment variables? I guess it is better than keeping it in database of hard coded in cloud code…

Thank you!
Lukas

From the example here I see that it is possible to read the environment variable with simple line:

Parse.Cloud.define("getEnvironmentVariable", (request) => {
  const ELASTICSEARCH_IP = process.env.ELASTICSEARCH_IP;  
  return `ELASTICSEARCH_IP = ${ELASTICSEARCH_IP}`
});

But I have not found if I can actually set it via cloud code, for example:

Parse.Cloud.define("setEnvironmentVariable", (request) => {
  process.env.ELASTICSEARCH_IP = "myNewStringIpValue";  
});

Does anyone has an experience with that? Thank you!

EDIT:
It seems to set the new IP to process.env. This is nevertheless not persisted upon server restart. Is there a way how to persist it, or should I simply save such configuration in database?

Than you

it seems that config is what I need to achieve the functionality. :+1: