Add-on Parameter Handling

Last Updated: 06 May 2015

Table of Contents

This article describes how to access command-line parameters that a user may have added as part of add-on provisioning.

Command-line parameter format

The command-line accepts parameters in standard Unix-style switch format, with or without an equals sign. Single parameters are interpreted as boolean switches and will have the string 'true' as their value.

For example, the following command line:

$ heroku addons:create youraddon --foo=bar --bar foo --baz

Will be interpreted as:

{ "foo" : "bar", "bar" : "foo", "baz" : "true" }

Accessing parameters

Heroku passes command-line parameters given to the addons:create action during add-on provisioning to the add-on provider. These options are passed in the JSON body of the provision request via the “options” key.

Consider this example:

$ heroku addons:create youraddon --foo=bar --bar foo --baz

The options are included as part of the JSON in the provision request:

POST /heroku/resources HTTP/1.0
Content-Type: application/json
  "options": {"foo":"bar","bar":"foo","baz":"true"},
  "heroku_id": "",
  "plan": "test",
  "callback_url": "http://localhost:7779/callback/999"

You can use the kensa gem to test the extra command line parameters:

$ kensa test provision --foo=bar --bar foo --baz