Skip to content
EY Cloud API Client
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.travis.yml Bump to 2.0.x for requirement of ruby 1.9.3 or higher.

Engine Yard Cloud Client

engineyard-cloud-client contains a Ruby api library to the Engine Yard Cloud API. Extracted from the engineyard gem.

Build Status

Version 2.0.x

As of the 2.0 version series, we will only be supporting ruby versions 1.9.3 and greater. Supporting older versions of ruby has gotten increasingly difficult as more and more gems assume that everyone is using 1.9.3 or greater.

The 1.0 version series will no longer be under active development, but will remain available through rubygems and on the 1-0-stable branch.

Use at your own risk

At this time, cloud-client is not documented for public use. It was created to be used by the engineyard gem with the hopes of eventually providing a public api client, but it's still in its infancy.

If you would like to use this gem directly instead of interfacing with the engineyard gem, you will likely be on your own. We may be available to answer questions about the gem, but the gem itself is not currently a supported public interface to Engine Yard Cloud.

This gem accesses API actions that can alter your dashboard and settings. If used incorrectly, it could lead to problems. As we work towards making this a reliable public client, the interface may change.

If you intend to use this gem, please lock to an exact version and pay close attention to newly released versions and changes to the interface.

Please open github issues for any problems you encounter.



require 'engineyard-cloud-client'

ey_api =

# the api object will retain the token after authenticate is called
token = api.authenticate!("", "password")

# or, if you already have the token
ey_api = api_token)

Current User:

user = ey_api.current_user
user.class # => EY::CloudClient::User  # => "Your Name" # => ""


apps = ey_api.apps # loads all your app data at once; caches result

app = apps.find {|app| == 'myapp'}
app.class           # => EY::CloudClient::App            # => 'myapp'              # => 123
app.repository_uri  # =>

app.account.class   # => EY::CloudClient::Account

app.app_environments.first.class # => EY::CloudClient::AppEnvironment {|e|} # => ['myapp_production', 'myapp_staging']

Create a new application (to be booted within Environments):

account =, {:id => 4212, :name => 'drnic'})
app = EY::CloudClient::App.create(ey_api,
  "account"        => account
  "name"           => "myapp",
  "repository_uri" => "",
  "app_type_id"    => "rails3",

Valid app_type_id are: rack, rails2, rails3, rails4, sinatra, nodejs. For some your account may require an early access feature to be enabled.


account = app.account
account.class   # => EY::CloudClient::Account      # => 1234    # => 'myaccount'


Upload your SSH public keys before you create Environments.

keypair = EY::CloudClient::Keypair.create(ey_api, {
  "name"       => 'laptop',
  "public_key" => "ssh-rsa OTHERKEYPAIR"


envs = ey_api.environments # loads all your environment data at once; caches result

env = envs.find {|e| == 'myapp_production'}
env.class             # => EY::CloudClient::Environment              # => 'myapp_production'                # => 2345
env.framework_env     # => "production"
env.app_server_stack_name     # => "nginx_thin"
env.deployment_configurations # => {"myapp"=>{"name"=>"myapp", "uri"=>nil, "migrate"=>{"command"=>"rake db:migrate", "perform"=>false}, "repository_uri"=>"", "id"=>123, "domain_name"=>"_"}}
env.load_balancer_ip_address  # => ""

# if environment isn't booted
env.instances_count     # => 0
env.app_master          # => nil
env.instances.count     # => []

# if environment is booted
env.instances_count     # => 1
env.app_master.class    # => EY::CloudClient::Instance
env.instances.first.class # => EY::CloudClient::Instance

Create a new environment (for a given App):

app =, {:id => 4212, :name => 'drnic'})
env = EY::CloudClient::Environment.create(ey_api,
  "app"                   => app,
  "name"                  => 'myapp_production',
  "app_server_stack_name" => 'nginx_thin',       # default: nginx_passenger3
  "region"                => 'us-west-1',        # default: us-east-1
  "framework_env"         => 'staging'           # default: production

Valid app_server_stack_name values: nginx_unicorn, nginx_passenger3, nginx_nodejs, nginx_thin, nginx_puma. For some your account may require an early access feature to be enabled.


# filtering by roles and roles with names
env.instances_by_role(:app_master, :app, :util) # => [EY::CloudClient::Instance, ...]
env.select_instances(util: %w[resque1 resque2 redis])  # => [EY::CloudClient::Instance, ...]

instance = env.instances.first
instance.class        # => EY::CloudClient::Instance           # => 12345
instance.role         # => "solo"
instance.status       # => "running"
instance.amazon_id    # => "i-abcdefg"
instance.hostname     # => ""
instance.public_hostname # => "" # alias of hostname

# add an instance
# IMPORTANT: See comments in code at 
# lib/engineyard-cloud-client/models/environment.rb#add_instance(opts)
# caveats may apply now and/or in the future
api = 'my token')
env = api.environment_by_name("myenv")

env.add_instance(role: "app") # adds app instance to cluster
env.add_instance(role: "util", name: "sphinx") # adds util named "sphinx"

# remove an instance
# IMPORTANT: See comments in code at
# lib/engineyard-cloud-client/models/environment.rb#remove_instance(instance)
# There are certain cases where this may not exactly do what you want,
# depending on how you call this, the state of your environment at
# runtime, and the IaaS on the other end.
api = 'my token')
env = api.environment_by_name("myenv")
bad_instance = env.instance_by_id(12345) # instance ID according to API

# valid instance sizes (or, "how do I add a 64-bit medium_cpu for example?")
# This is also documented at
=> [... array of valid instance sizes/names ...]


# Assuming you've authenticated with an object named 'api'...
env = ( { |x| == "my_uniqe_env_name"}).first
# big list of all environment snapshots here (array)
# See your DB snapshots: { |x| x.role == "db" }


When $DEBUG is set, display debug information to the ui object using the #debug method. The API commands will print internal request information:

app = EY::CloudClient::App.create(ey_api, 'account' => account, 'name' => 'myapp2', 'repository_uri' => '', 'app_type_id' => 'rails3')
       Token  YOURTOKEN
     Request  POST
      Params  {"app"=>{"name"=>"myapp2", "app_type_id"=>"rails3", "repository_uri"=>""}}
   "account"=>{"name"=>"myaccount", "id"=>1234},
Something went wrong with that request. Please try again.