Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improvements to the shell command helper. Moved it from ec2sh to awsh…

…ell.

Closes #24

See ChangeLog for more info.
  • Loading branch information...
commit 1959c284da04dad499b22d44fd95bfa1f11ddc77 1 parent 3f00278
@grempe authored
Showing with 142 additions and 55 deletions.
  1. +9 −0 ChangeLog
  2. +81 −0 bin/awshell
  3. +6 −48 bin/ec2sh
  4. +46 −7 bin/setup.rb
View
9 ChangeLog
@@ -1,3 +1,12 @@
+* (In progress) Close issue #22, allow detach_volume to take a boolean as a string or TrueClass FalseClass
+
+=== 0.9.16 2010-07-07
+ * Less strict checking on which server endpoints you can pass in as an environment var.
+ * Moved ec2sh script to awshell to better reflect the more comprehensive nature of the gem.
+ * Better instructions on using awshell upon running
+ * awshell now sets up handles for all of the various services we use, not just @ec2 (+ @as, @rds, @elb, @cw)
+ * awshell prints out the various server endpoints that it will actually use in the shell (you can override with env vars).
+
=== 0.9.11 2010-04-23
* RDS#create_db_instance : renamed misspelled :backend_retention_period option to :backup_retention_period.
* Better handling of FixNum options in a few methods.
View
81 bin/awshell
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+# Amazon Web Services EC2 Query API Ruby library
+#
+# Ruby Gem Name:: amazon-ec2
+# Author:: Glenn Rempe (mailto:glenn@rempe.us)
+# Copyright:: Copyright (c) 2007-2010 Glenn Rempe
+# License:: Distributes under the same terms as Ruby
+# Home:: http://github.com/grempe/amazon-ec2/tree/master
+#++
+
+# CREDITS : Credit for this bit of shameful ripoff coolness
+# goes to Marcel Molina and his AWS::S3 gem. Thanks!
+
+aws_lib = File.dirname(__FILE__) + '/../lib/AWS'
+setup = File.dirname(__FILE__) + '/setup'
+irb_name = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
+
+welcome_message = <<-MESSAGE
+
+Usage :
+
+This is an interactive Ruby 'irb' shell that allows you to use the
+AWS commands available in the 'amazon-ec2' gem. This can be a
+great tool to help you debug issues and run commands
+against the live AWS servers. You can do anything in this
+shell that you can in a normal irb shell.
+
+Config :
+
+You must set the following environment variables that contain your
+AWS credentials in your system shell for this to work.
+
+ AMAZON_ACCESS_KEY_ID
+ AMAZON_SECRET_ACCESS_KEY
+
+Each AWS service has its own default server endpoints. You can override
+the endpoints with the following environment variables set in your
+system shell:
+
+ EC2 : EC2_URL
+ Elastic Load Balancing : ELB_URL
+ AutoScaling : AS_URL
+ RDS : RDS_URL
+ CloudWatch : AWS_CLOUDWATCH_URL
+
+For your convenience, the various AWS services are wired up in this shell
+to the following class variables. You can execute methods on each of these:
+
+ @ec2 (Elastic Compute Cloud)
+ @elb (Elastic Load Balancing)
+ @as (AutoScaling)
+ @rds (Relational Database Service)
+ @cw (CloudWatch)
+
+You can make method calls on these instances to execute commands against
+the various services. Pre-pending a 'pp' should give you a pretty printed
+version of the response which may be easier to read.
+
+Examples:
+
+ returns : Pretty Print all ec2 public methods
+ >> pp @ec2.methods.sort
+
+ returns : Pretty Print a Hash describing your EC2 images
+ >> @ec2.describe_images(:owner_id => ['self'])
+
+ returns : an Array of AWS::Response objects, each an EC2 image and its data
+ >> @ec2.describe_images(:owner_id => ['self']).imagesSet.item
+ >> @ec2.describe_images(:owner_id => ['self']).imagesSet.item[0]
+
+MESSAGE
+
+if ( ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY'] )
+ puts welcome_message
+ exec "#{irb_name} -rubygems -r #{aws_lib} -r #{setup} --simple-prompt"
+else
+ puts "You must define AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY as shell environment variables before running #{$0}!"
+ puts welcome_message
+end
+
View
54 bin/ec2sh
@@ -4,59 +4,17 @@
#
# Ruby Gem Name:: amazon-ec2
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
-# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
+# Copyright:: Copyright (c) 2007-2010 Glenn Rempe
# License:: Distributes under the same terms as Ruby
# Home:: http://github.com/grempe/amazon-ec2/tree/master
#++
-# CREDITS : Credit for this bit of shameful ripoff coolness
-# goes to Marcel Molina and his AWS::S3 gem. Thanks!
+message = <<-MESSAGE
-# Usage : running this starts up an irb session and
-# sets up the connection to EC2 as a class variable called
-# '@ec2'. So just do something like the following on the
-# shell command line:
+ DEPRECATION WARNING:
-# macbook-pro:~ glenn$ ec2sh
-# >> @ec2.describe_images
-# => [#<AWS::EC2::Item image_location...
+ This script has been renamed to 'awshell'. Please run that command instead.
-aws_lib = File.dirname(__FILE__) + '/../lib/AWS'
-setup = File.dirname(__FILE__) + '/setup'
-irb_name = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
+MESSAGE
-if ( ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY'] )
-
- welcome_message = <<-MESSAGE
-
- 'ec2sh' usage :
- This is an interactive 'irb' command shell that allows you to use all
- commands available to the amazon-ec2 gem. You'll find this to be a
- great tool to help you debug issues and practice running commands
- against the live EC2 servers prior to putting them in your code.
-
- The EC2 connection is wired to the class instance '@ec2'. Make method calls
- on this to execute commands on EC2. Adding a #to_s
- at the end of any command should give you a full String representation of the
- response.
-
- Examples to try:
-
- returns : all ec2 public methods
- >> @ec2.methods.sort
-
- returns : a string representation of ALL images
- >> @ec2.describe_images.to_s
-
- returns : an Array of AWS::Response objects, each an EC2 image and its data
- >> @ec2.describe_images.imagesSet.item
- >> @ec2.describe_images.imagesSet.item[0] (a hash representing a single item in that array)
- >> @ec2.describe_images.imagesSet.item[0].to_s (a String representation of that item)
-
- MESSAGE
-
- puts welcome_message
- exec "#{irb_name} -rubygems -r #{aws_lib} -r #{setup} --simple-prompt"
-else
- puts "You must define AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY as shell environment variables before running #{$0}!"
-end
+puts message
View
53 bin/setup.rb
@@ -4,26 +4,65 @@
#
# Ruby Gem Name:: amazon-ec2
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
-# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
+# Copyright:: Copyright (c) 2007-2010 Glenn Rempe
# License:: Distributes under the same terms as Ruby
# Home:: http://github.com/grempe/amazon-ec2/tree/master
#++
if ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY']
+
opts = {
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
}
+
if ENV['EC2_URL']
opts[:server] = URI.parse(ENV['EC2_URL']).host
+ @ec2 = AWS::EC2::Base.new(opts)
+ else
+ @ec2 = AWS::EC2::Base.new(opts)
+ end
+
+ if ENV['ELB_URL']
+ opts[:server] = URI.parse(ENV['ELB_URL']).host
+ @elb = AWS::ELB::Base.new(opts)
+ else
+ @elb = AWS::ELB::Base.new(opts)
+ end
+
+ if ENV['AS_URL']
+ opts[:server] = URI.parse(ENV['AS_URL']).host
+ @as = AWS::Autoscaling::Base.new(opts)
+ else
+ @as = AWS::Autoscaling::Base.new(opts)
end
- @ec2 = AWS::EC2::Base.new(opts)
- @elb = AWS::ELB::Base.new(opts)
- @as = AWS::Autoscaling::Base.new(opts)
- @rds = AWS::RDS::Base.new(opts)
-end
-puts "EC2 Server: #{opts[:server]}"
+ if ENV['RDS_URL']
+ opts[:server] = URI.parse(ENV['RDS_URL']).host
+ @rds = AWS::RDS::Base.new(opts)
+ else
+ @rds = AWS::RDS::Base.new(opts)
+ end
+
+ if ENV['AWS_CLOUDWATCH_URL']
+ opts[:server] = URI.parse(ENV['AWS_CLOUDWATCH_URL']).host
+ @cw = AWS::Cloudwatch::Base.new(opts)
+ else
+ @cw = AWS::Cloudwatch::Base.new(opts)
+ end
+
+ puts ""
+ puts "Server Endpoints Configured"
+ puts "--"
+ puts "@ec2.default_host (Elastic Compute Cloud) : #{@ec2.default_host}"
+ puts "@elb.default_host (Elastic Load Balancer) : #{@elb.default_host}"
+ puts "@as.default_host (Autoscaling) : #{@as.default_host}"
+ puts "@rds.default_host (Relational DB Service) : #{@rds.default_host}"
+ puts "@cw.default_host (Cloudwatch) : #{@cw.default_host}"
+ puts ""
+
+end
+require 'pp'
include AWS
Please sign in to comment.
Something went wrong with that request. Please try again.