Home > heroku_plus

heroku_plus

Heroku_plus is a project mainly written in ..., based on the MIT license.

Enhances default Heroku capabilities with multi-account support.

= Overview

Managing multiple Heroku[http://heroku.com/] accounts is not easy with the Heroku gem. In fact, it is not even possible without a lot of manual labor, random scripts, etc. This gem enhances default Heroku capabilities with multi-account support so you can easily switch between accounts with a single command line command.

Special thanks to Ruby5[http://ruby5.envylabs.com] for mentioning this gem in {Episode 103}[http://ruby5.envylabs.com/episodes/105-episode-103-august-17-2010].

= License

Copyright (c) 2010 {Brooke Kuhlmann}[http://www.aeonscope.net]. See the included LICENSE for more info.

= History

See the CHANGELOG file for more info.

= Requirements

  1. Mac OS X.
  2. Multiple Heroku[http://heroku.com/] accounts.
  3. Heroku gem[http://github.com/heroku/heroku].

= Installation

Type the following from the command line to install:

gem install heroku_plus

= Setup

In order to understand how this gem benefits you, you first need to understand how the Heroku gem determines what your accounts settings are (as {originally discussed here}[http://www.aeonscope.net/2010/02/22/managing-multiple-heroku-accounts/]). Heroku does this by pulling information from your Heroku credentials and your SSH settings. Lets take a closer look.

=== Overview

The Heroku gem determines your setup from your Heroku credentials, SSH files, and your project Git config within your project directory. Example:

~/.heroku/credentials ~/.ssh/config ~/.ssh/id_rsa ~/.ssh/id_rsa.pub ~/Development/Ruby/your_project/.git/config

This setup works wonderfully if you only own one Heroku account but breaks down considerably with multiple accounts because you have to manually maintain multiple credentials, id_rsa, and id_rsa.pub files for each Heroku account you own. Luckily, this gem solves this management headache for you but lets make sure we understand the above list in detail so you can learn how this gem helps you. Read on.

=== Heroku Setup

For each of your Heroku apps, change to the root directory of each app, and issue the following command:

git remote add heroku [email protected]:.git.

This will allow you to push and deploy your changes back to the Heroku servers properly.

=== Heroku Credentials (~/.heroku/credentials)

You need a credentials files for each Heroku account. This file is created for you by the Heroku gem when you first setup your account and is a text file that consists of your login (i.e. email address) and password. Example:

[email protected] dafkk3$59dkagblk3k5l56

This file contains the credentials necessary to validate your machine with your Heroku account. To support multiple accounts, I suggest the following:

~/.heroku/credentials - The active/current account. ~/.heroku/account_1.credentials - Your first account. ~/.heroku/account_2.credentials - Your second account.

NOTE: Account switching will not work properly if accounts are not suffixed with the .credentials file extension.

=== SSH Configuration (~/.ssh/config)

The SSH configuration file. This file should consist of or at least contain the following due to the Heroku setup steps mentioned earlier:

Host official.heroku.com HostName heroku.com User git IdentitiesOnly yes

=== SSH Identity (~/.ssh/id_rsa and ~/.ssh/id_rsa.pub)

You need private and public SSH identity files for each Heroku account (it is assumed you are using RSA encryption but any encryption technique will work). If these files do not already exist, then here is how to create them:

ssh-keygen -t rsa -C "" -f ~/.ssh/id_rsa

To support multiple accounts, I suggest the following:

~/.ssh/id_rsa - The active/current private key. ~/.ssh/id_rsa.pub - The active/current public key.

~/.ssh/account_1.identity - Your first private identity. ~/.ssh/account_1.identity.pub - Your first public identity.

~/.ssh/account_2.identity - Your second private identity. ~/.ssh/account_2.identity.pub - Your second public identity.

NOTE: Account switching will not work properly if all accounts are not suffixed with the .identity file extension.

=== Project Git Configuration (~/Development/Ruby/your_project/.git/config)

This is somewhat outside the scope of documentation for this gem but I think it is important to mention. The Git configuration file, as you might know, is what configures Git for your particular project. If you have more than one branch (i.e. remote) listed within this config file you will still need to pass the --app command when issuing Heroku commands. The reason for supporting multiple branches is because you might wish to have a production and test server where you deploy to test before updating your production server. For example, your config file might look like this:

[remote "example-prod"] [remote "example-test"]

This would then require you use the --app option when issuing a Heroku command. For example:

heroku restart --app example-prod heroku restart --app example-test

While this gem alleviates the need to specify the --app command when dealing within multiple Heroku accounts, it does not help you when dealing with multiple branches within a single Heroku account. That, I leave to you.

=== Default Gem Configuration

You can change the default settings for this gem by creating the following file:

~/.heroku/settings.yml

The contents of the file should look like this (where the default values can be changed to your liking):


:ssh_identity: "id_rsa"

= Usage

From a command line, type: herokup -h

Full usage is displayed below:

-s, --switch ACCOUNT Switch Heroku credentials and SSH identity to specified account. -b, --backup ACCOUNT Backup existing Heroku credentials and SSH identity to specified account. -d, --destroy ACCOUNT Destroy Heroku credentials and SSH identity for specified account. -l, --list Show all Heroku accounts. -i, --info Show the current Heroku credentials and SSH identity. -h, --help Show this help message. -v, --version Show the current version.

= Workflow

From this point forward, you can switch between accounts as follows:

  1. Change directory to the app you want to work on.
  2. Type: herokup -s
  3. Make changes to your code.
  4. Type: git commit -a -m “Your comments.”
  5. Type: git push heroku master.
  6. Have a beer.

= Contact/Feedback/Issues