I'm deploying symfony project via eb deploy to ec2 instance (aws linux 2). Post deploy migrations scripts works well, but then I try to run symfony command with ec2-user I get an error about wrong database credentials. It is because I have pushed dump .env file with empty values. All my enviroment variables are stored in eb -> configuration -> Environment properties. How to make these variables to be visible to other users to properly execute commands?
I can see these variables as json with:
/opt/elasticbeanstalk/bin/get-config environment
Open the Elastic Beanstalk console , and in the Regions list, select your AWS Region. In the navigation pane, choose Environments, and then choose the name of your environment from the list. If you have many environments, use the search bar to filter the environment list. In the navigation pane, choose Configuration.
To set environment variables Sign in to the AWS Management Console and open the Amplify console . In the Amplify console, choose App Settings, and then choose Environment variables. In the Environment variables section, choose Manage variables. In the Manage variables section, under Variable, enter your key.
The EB env variables on Amazon Linux 1 are stored in:
/opt/elasticbeanstalk/support/envvars
Thus, to load them when you login to the instance you can do the following:
source /opt/elasticbeanstalk/support/envvars
To check if they got loaded, you can just execute:
env
p.s.
For Amazon Linux 2:
export $(cat /opt/elasticbeanstalk/deployment/env | xargs)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With