0

I need to use Amazon elastic beanstalk environment variable values for a local development but don't want them hard coded when I do a code push.

I'd like to run a bash script to set the variables, and this is how I do it with Heroku:

echo "... SETTING DATABASE_URL" export DATABASE_URL=$(heroku config:get DATABASE_URL) 

With elastic beanstalk, I can get a list of env variables with:

eb printenv <name of environment> 

I've tried grepping for just the value, e.g.

eb printenv my-environment | grep DB_NAME 

... but that returns entire line and I just need value. So tried grepping with regex and it won't return anything, .e.g.

eb printenv my-environment | grep '/(?s)(?<=DB_NAME).+/' 

It's a simple regex query and checks out fine on regex101.com, so not sure what the problem could be.

Any ideas of how to get specific key values pairs?

1 Answer 1

0

You can try something like this

# eb printenv | grep RAILS_ENV RAILS_ENV = production # eb printenv | grep RAILS_ENV | awk '{print $3}' production 

So in you case it would be

DATABASE_URL=$(eb printenv | grep DATABASE_URL | awk '{print $3}') 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.