The Heroku Connector is part of the Spring Cloud Connectors project.
This connector will discover services that are bound to an application running in Heroku.
Cloud Detection
This connector checks for the presence of a DYNO
environment variable. This variable is specific to and provided by Heroku; it is set to the identifier of an application’s dyno. If the variable exists, the connector will be activated.
Service Detection
Heroku exposes the URL of a service instance (add-on) as a config var, which is made available to an application as an environment variable. The Spring Cloud Heroku Connector checks for environment variables which contain URLs used by add-ons and uses their presence to detect the relevant services.
As an example, consider a RabbitMQ service provided by CloudAMQP. After adding the CloudAMQP add-on to a Heroku application, you can run heroku config
to see a new CLOUDAMQP_URL
config var.
$ heroku config
=== frozen-oasis-1234 Config Vars
CLOUDAMQP_URL: amqp://sfdkjdj:[email protected]/lyfkue
...
Supported Services
This connector comes with built-in support for several service types and providers. The variables and URI schemes with which it establishes availability of each service are described below.
PostgreSQL (Heroku)
The connector will check for:
-
a
HEROKU_POSTGRESQL_
config var with value using the schemepostgres
MySQL (ClearDB)
The connector will check for:
-
a
CLEARDB_DATABASE_URL
config var with value using the schememysql
Redis (Redis To Go, Redis Cloud, RedisGreen, openredis, Heroku Redis)
The connector will check for:
-
a
REDISTOGO_URL
config var with value using the schemeredis
-
a
REDISCLOUD_URL
config var with value using the schemeredis
-
an
OPENREDIS_URL
config var with value using the schemeredis
-
a
REDISGREEN_URL
config var with value using the schemeredis
-
a
REDIS_URL
config var with value using the schemeredis
MongoDB (MongoLab, MongoHQ, MongoSoup)
The connector will check for:
-
a
MONGOLAB_URI
config var with value using the schememongodb
-
a
MONGOHQ_URL
config var with value using the schememongodb
-
a
MONGOSOUP_URL
config var with value using the schememongodb
RabbitMQ (CloudAMQP)
The connector will check for:
-
a
CLOUDAMQP_URL
config var with value using the schemeamqp
oramqps
Supporting Additional Providers for Existing Service Types
To add support for a new provider of a service already listed above, add the provider’s environment prefix to the list in getEnvPrefixes()
on the ServiceInfoCreator
class.
Limitations
Unlike Cloud Foundry, Heroku exposes very little application information that is retrievable from within a running instance (for example, there is no good way to find the name of the application). If your application requires access to such information, you must make the information available through environment variables.
To have a sensible application name available through ApplicationInstanceInfo
, set the SPRING_CLOUD_APP_NAME
environment variable.
heroku config:add SPRING_CLOUD_APP_NAME=myappname --app myappname
If this environment variable is not set, the application name will be set to <unknown>
.