I have a script used to start my application that I also want to use to set some environment variables. This is so I can encrypt the sensitive env vars in an S3 bucket and load these before the app. Here is my script start.sh
:
#!/bin/bash
# Load the S3 secrets file contents into the environment variables
eval $(aws s3 cp s3://secret-bucket-location/integration-secrets.txt - | sed 's/^/export /')
#I have also tried exporting variables here to see if my app picks them up
export TEST_ENV_VAR=testing
pm2 start server.js
The result is none of the environment variables are set. The ones set in the Elastic Beanstalk configuration are still set however.
It appears as though part of the EB launch config wipes them at some point.
Is there anywhere I can run this logic to allow me to set the variables? Or is there another way round this?
Thanks!