Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

384
Visualizações
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
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

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)
over 4 years ago · Santiago Trujillo Relatório

0

I stumbled on the same issue, this documentation shed some light on how to fix permission issues in Amazon Linux 2 although it is not straightforward.

over 4 years ago · Santiago Trujillo Relatório

0

Something to note, is that the answer provided by @Marcin will fail if implemented in a deployment script within the .ebextensions or .platform folders on new instance deployments.

In order to properly retrieve the environment variables, and source them to the shell, AWS has an article outlining how this is done:

https://aws.amazon.com/premiumsupport/knowledge-center/elastic-beanstalk-env-variables-shell/

For future reference, here are the instructions copied from the AWS docs:

Resolution

  1. Create a .ebextension file in your application source bundle and include the following:
commands:
    setvars:
        command: /opt/elasticbeanstalk/bin/get-config environment | jq -r 'to_entries | .[] | "export \(.key)=\"\(.value)\""' > /etc/profile.d/sh.local
packages:
    yum:
        jq: []

Note: The configuration file in step 1 is called setvars.config.

  1. Save the .ebextension file, and then deploy it to your Elastic Beanstalk environment.

  2. To test if the variables are being exported, connect to your instance using SSH, and then run the following command. Before testing, close any existing sessions and then reconnect using SSH. env | grep VARIABLE_NAME Important: For step 3, set VARIABLE_NAME to a variable defined in your environment.

The output shows if your environment variables are set correctly. In the following example output, a variable called RDS_PORT is defined in the Elastic Beanstalk environment.

$ env|grep RDS_PORT
RDS_PORT=3306

Note: Because you're using the commands on the .ebextension, you can update the sh.local file only with a new deployment. If you add or change a variable in the environment, then you must create a new deployment before the variable is exported to the operating system.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda