Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws eb deploy doesn't load environment variables

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
like image 284
Martynas Tumas Avatar asked Aug 06 '20 09:08

Martynas Tumas


People also ask

How do you access the Elastic Beanstalk 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.

How do I use an environment variable in AWS?

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.


1 Answers

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)
like image 111
Marcin Avatar answered Oct 07 '22 01:10

Marcin