I am moving my firebase authenticated node.js application from Heroku to AWS Elastic Beanstalk. The private key is not parsing correctly. It is having trouble understanding the newline characters from the environment variables.
For reference I have already tried the solution found in this stackoverflow post: Node.js -Firebase Service Account Private Key won't parse
privateKey: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n')
Unfortunately, as this works on Heroku, the same is not true for AWS Elastic Beanstalk. After logging the private key in the terminal I notice it is replacing the \n with simply 'n' and making no newline character at all.
Newline characters are not allowed while setting environment variables in the EB software configuration. Any new lines are replaced with just a single space.
Not sure if there is another way short of keeping the key directly in the code which I would like to avoid.