I have a Node JS Project which is having handler, service and model. As part of the application we used to read the env variables from the config js file which varies each environment. Recently we try to move those config js information into AWS Secret Manager. Now we were able to get all the values from Secret Manager in the common module. We have nearly 15 modules , each module have their own environment variables. (each module is a micro service). How can I implement to get all the secret values for each environment (kind of load on start up from the common module. Right now I am using the below approach in my handler.
Have used the below approach to get the values from the common module to working module.(handler)
const utils = require('common-module');
((err, response) => {
utils.getAllEnvValues({ secretValue: 'SEARCH-SECRET' }, (err, result) => {
if (err) {
console.log(err)
}
console.log('Getting the value from AWS Secrets!!!!');
console.log('Limit Size:', process.env.SEARCH_LIMIT);
});
})();
But sometime its not necessary that all the modules need to be loaded. Even those modules also should get their env values ? How to get those?What kind of implementation will help here?