Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it Possible to Alias Config Variables on Heroku?

Tags:

heroku

I'm currently writing a tutorial on setting up Wordpress on Heroku. Right now I'm using the ClearDB add-on which sets a CLEARDB_DATABASE_URL ENV variable automatically. Is it possible to alias the ENV variable through Heroku as DATABASE_URL?

like image 305
Kevin Sylvestre Avatar asked May 02 '14 04:05

Kevin Sylvestre


2 Answers

It's not possible to alias an config var or refer to one from another. I asked a similar question and this is what they said:

I'm afraid that Config Variables can't refer to each other in this way, as they are simple a collection of Names and Values, with no interpolation or calculation available to the values.

You might like try a profile file...

like image 186
Abhijit Sarkar Avatar answered Oct 08 '22 17:10

Abhijit Sarkar


I've had a similar issue - where I'm trying to use an app in a pipeline connected to 2 different heroku DB's - in order to keep all he environments consistent in code, I did the following:

Heroku Configs:

DATABASE_URL=XXXXXXXX  - this was the first DB that heroku attached
HEROKU_POSTGRESQL_JADE_URL=XXXX - this was the second DB that heroku attached (the key name changes in each environment)
SECOND_DB_KEY_NAME=HEROKU_POSTGRESQL_JADE_URL

(ie. after each environment was set up - I added a reference to the new key)

This second DB key name, does not change if the DB credentials refresh.

In code, I then did the following at start up:

const databaseUrlKey = process.env.SECOND_DB_KEY_NAME
process.env['SECOND_DATABASE_URL'] = process.env[databaseUrlKey]
like image 25
Dan Avatar answered Oct 08 '22 17:10

Dan