nirvdrum-amazon-ec2 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. data/.gitignore +9 -0
  2. data/.yardopts +1 -0
  3. data/ChangeLog +304 -0
  4. data/LICENSE +66 -0
  5. data/README.rdoc +359 -0
  6. data/README_dev.rdoc +10 -0
  7. data/Rakefile +70 -0
  8. data/VERSION +1 -0
  9. data/amazon-ec2.gemspec +142 -0
  10. data/bin/ec2-gem-example.rb +137 -0
  11. data/bin/ec2-gem-profile.rb +10 -0
  12. data/bin/ec2sh +62 -0
  13. data/bin/setup.rb +29 -0
  14. data/deps.rip +1 -0
  15. data/lib/AWS.rb +321 -0
  16. data/lib/AWS/Autoscaling.rb +70 -0
  17. data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
  18. data/lib/AWS/Cloudwatch.rb +32 -0
  19. data/lib/AWS/Cloudwatch/monitoring.rb +80 -0
  20. data/lib/AWS/EC2.rb +33 -0
  21. data/lib/AWS/EC2/availability_zones.rb +29 -0
  22. data/lib/AWS/EC2/console.rb +25 -0
  23. data/lib/AWS/EC2/devpay.rb +18 -0
  24. data/lib/AWS/EC2/elastic_ips.rb +86 -0
  25. data/lib/AWS/EC2/image_attributes.rb +133 -0
  26. data/lib/AWS/EC2/images.rb +117 -0
  27. data/lib/AWS/EC2/instances.rb +234 -0
  28. data/lib/AWS/EC2/keypairs.rb +47 -0
  29. data/lib/AWS/EC2/products.rb +21 -0
  30. data/lib/AWS/EC2/security_groups.rb +164 -0
  31. data/lib/AWS/EC2/snapshots.rb +102 -0
  32. data/lib/AWS/EC2/spot_instance_requests.rb +105 -0
  33. data/lib/AWS/EC2/volumes.rb +100 -0
  34. data/lib/AWS/ELB.rb +71 -0
  35. data/lib/AWS/ELB/load_balancers.rb +178 -0
  36. data/lib/AWS/RDS.rb +73 -0
  37. data/lib/AWS/RDS/rds.rb +522 -0
  38. data/lib/AWS/exceptions.rb +200 -0
  39. data/lib/AWS/responses.rb +21 -0
  40. data/perftools/ec2prof +0 -0
  41. data/perftools/ec2prof-results.dot +132 -0
  42. data/perftools/ec2prof-results.txt +100 -0
  43. data/perftools/ec2prof.symbols +102 -0
  44. data/test/test_Autoscaling_groups.rb +337 -0
  45. data/test/test_EC2.rb +68 -0
  46. data/test/test_EC2_availability_zones.rb +49 -0
  47. data/test/test_EC2_console.rb +54 -0
  48. data/test/test_EC2_elastic_ips.rb +144 -0
  49. data/test/test_EC2_image_attributes.rb +238 -0
  50. data/test/test_EC2_images.rb +229 -0
  51. data/test/test_EC2_instances.rb +611 -0
  52. data/test/test_EC2_keypairs.rb +123 -0
  53. data/test/test_EC2_products.rb +48 -0
  54. data/test/test_EC2_responses.rb +53 -0
  55. data/test/test_EC2_s3_xmlsimple.rb +80 -0
  56. data/test/test_EC2_security_groups.rb +205 -0
  57. data/test/test_EC2_snapshots.rb +83 -0
  58. data/test/test_EC2_spot_instance_requests.rb +178 -0
  59. data/test/test_EC2_volumes.rb +142 -0
  60. data/test/test_ELB_load_balancers.rb +239 -0
  61. data/test/test_RDS.rb +354 -0
  62. data/test/test_helper.rb +23 -0
  63. data/wsdl/2007-08-29.ec2.wsdl +1269 -0
  64. data/wsdl/2008-02-01.ec2.wsdl +1614 -0
  65. data/wsdl/2008-05-05.ec2.wsdl +2052 -0
  66. data/wsdl/2008-12-01.ec2.wsdl +2354 -0
  67. data/wsdl/2009-10-31.ec2.wsdl +4261 -0
  68. data/wsdl/2009-11-30.ec2.wsdl +4668 -0
  69. metadata +199 -0
@@ -0,0 +1,10 @@
1
+ = Dev Docs
2
+
3
+ Publishing the gem using Jeweler:
4
+
5
+ rake version:bump:patch release
6
+
7
+ Push the gem to gemcutter:
8
+
9
+ gem push pkg/amazon-ec2-X.Y.Z.gem
10
+
@@ -0,0 +1,70 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'yard'
4
+
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "nirvdrum-amazon-ec2"
8
+ gem.summary = %Q{Amazon EC2 Ruby Gem}
9
+ gem.description = %Q{A Ruby library for accessing the Amazon Web Services EC2, ELB, RDS, Cloudwatch, and Autoscaling API's.}
10
+ gem.email = "glenn@rempe.us"
11
+ gem.homepage = "http://github.com/grempe/amazon-ec2"
12
+ gem.authors = ["Glenn Rempe"]
13
+ gem.rdoc_options = ["--title", "amazon-ec2 documentation", "--line-numbers", "--main", "README.rdoc"]
14
+ gem.rubyforge_project = 'amazon-ec2'
15
+ gem.add_dependency('xml-simple', '>= 1.0.12')
16
+ gem.add_development_dependency('mocha', '>= 0.9.8')
17
+ gem.add_development_dependency('test-spec', '>= 0.10.0')
18
+ gem.add_development_dependency('rcov', '>= 0.9.6')
19
+ gem.add_development_dependency('perftools.rb', '>= 0.3.9')
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ test.rcov_opts << "--exclude /gems/,/Library/,spec"
36
+ end
37
+ rescue LoadError
38
+ task :rcov do
39
+ abort "RCov is not available. In order to run rcov, you must: [sudo] gem install rcov"
40
+ end
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION.yml')
48
+ config = YAML.load(File.read('VERSION.yml'))
49
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
50
+ else
51
+ version = ""
52
+ end
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "amazon-ec2 #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
59
+
60
+ YARD::Rake::YardocTask.new do |t|
61
+ #t.files = ['lib/**/*.rb']
62
+ end
63
+
64
+ desc "Generate a perftools.rb profile"
65
+ task :profile do
66
+ system("CPUPROFILE=perftools/ec2prof RUBYOPT='-r/Library/Ruby/Gems/1.8/gems/perftools.rb-0.3.2/lib/perftools.bundle' ruby -r'rubygems' bin/ec2-gem-profile.rb")
67
+ system("pprof.rb --text --ignore=Gem perftools/ec2prof > perftools/ec2prof-results.txt")
68
+ system("pprof.rb --dot --ignore=Gem perftools/ec2prof > perftools/ec2prof-results.dot")
69
+ end
70
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.7.9
@@ -0,0 +1,142 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{amazon-ec2}
8
+ s.version = "0.7.9"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Glenn Rempe"]
12
+ s.date = %q{2009-12-22}
13
+ s.description = %q{A Ruby library for accessing the Amazon Web Services EC2, ELB, RDS, Cloudwatch, and Autoscaling API's.}
14
+ s.email = %q{glenn@rempe.us}
15
+ s.executables = ["ec2-gem-example.rb", "ec2-gem-profile.rb", "ec2sh", "setup.rb"]
16
+ s.extra_rdoc_files = [
17
+ "ChangeLog",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "README_dev.rdoc"
21
+ ]
22
+ s.files = [
23
+ ".gitignore",
24
+ ".yardopts",
25
+ "ChangeLog",
26
+ "LICENSE",
27
+ "README.rdoc",
28
+ "README_dev.rdoc",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "amazon-ec2.gemspec",
32
+ "bin/ec2-gem-example.rb",
33
+ "bin/ec2-gem-profile.rb",
34
+ "bin/ec2sh",
35
+ "bin/setup.rb",
36
+ "deps.rip",
37
+ "lib/AWS.rb",
38
+ "lib/AWS/Autoscaling.rb",
39
+ "lib/AWS/Autoscaling/autoscaling.rb",
40
+ "lib/AWS/Cloudwatch.rb",
41
+ "lib/AWS/Cloudwatch/monitoring.rb",
42
+ "lib/AWS/EC2.rb",
43
+ "lib/AWS/EC2/availability_zones.rb",
44
+ "lib/AWS/EC2/console.rb",
45
+ "lib/AWS/EC2/devpay.rb",
46
+ "lib/AWS/EC2/elastic_ips.rb",
47
+ "lib/AWS/EC2/image_attributes.rb",
48
+ "lib/AWS/EC2/images.rb",
49
+ "lib/AWS/EC2/instances.rb",
50
+ "lib/AWS/EC2/keypairs.rb",
51
+ "lib/AWS/EC2/products.rb",
52
+ "lib/AWS/EC2/security_groups.rb",
53
+ "lib/AWS/EC2/snapshots.rb",
54
+ "lib/AWS/EC2/volumes.rb",
55
+ "lib/AWS/ELB.rb",
56
+ "lib/AWS/ELB/load_balancers.rb",
57
+ "lib/AWS/RDS.rb",
58
+ "lib/AWS/RDS/rds.rb",
59
+ "lib/AWS/exceptions.rb",
60
+ "lib/AWS/responses.rb",
61
+ "perftools/ec2prof",
62
+ "perftools/ec2prof-results.dot",
63
+ "perftools/ec2prof-results.txt",
64
+ "perftools/ec2prof.symbols",
65
+ "test/test_Autoscaling_groups.rb",
66
+ "test/test_EC2.rb",
67
+ "test/test_EC2_availability_zones.rb",
68
+ "test/test_EC2_console.rb",
69
+ "test/test_EC2_elastic_ips.rb",
70
+ "test/test_EC2_image_attributes.rb",
71
+ "test/test_EC2_images.rb",
72
+ "test/test_EC2_instances.rb",
73
+ "test/test_EC2_keypairs.rb",
74
+ "test/test_EC2_products.rb",
75
+ "test/test_EC2_responses.rb",
76
+ "test/test_EC2_s3_xmlsimple.rb",
77
+ "test/test_EC2_security_groups.rb",
78
+ "test/test_EC2_snapshots.rb",
79
+ "test/test_EC2_volumes.rb",
80
+ "test/test_ELB_load_balancers.rb",
81
+ "test/test_RDS.rb",
82
+ "test/test_helper.rb",
83
+ "wsdl/2007-08-29.ec2.wsdl",
84
+ "wsdl/2008-02-01.ec2.wsdl",
85
+ "wsdl/2008-05-05.ec2.wsdl",
86
+ "wsdl/2008-12-01.ec2.wsdl",
87
+ "wsdl/2009-10-31.ec2.wsdl",
88
+ "wsdl/2009-11-30.ec2.wsdl"
89
+ ]
90
+ s.homepage = %q{http://github.com/grempe/amazon-ec2}
91
+ s.rdoc_options = ["--title", "amazon-ec2 documentation", "--line-numbers", "--main", "README.rdoc"]
92
+ s.require_paths = ["lib"]
93
+ s.rubyforge_project = %q{amazon-ec2}
94
+ s.rubygems_version = %q{1.3.5}
95
+ s.summary = %q{Amazon EC2 Ruby Gem}
96
+ s.test_files = [
97
+ "test/test_Autoscaling_groups.rb",
98
+ "test/test_EC2.rb",
99
+ "test/test_EC2_availability_zones.rb",
100
+ "test/test_EC2_console.rb",
101
+ "test/test_EC2_elastic_ips.rb",
102
+ "test/test_EC2_image_attributes.rb",
103
+ "test/test_EC2_images.rb",
104
+ "test/test_EC2_instances.rb",
105
+ "test/test_EC2_keypairs.rb",
106
+ "test/test_EC2_products.rb",
107
+ "test/test_EC2_responses.rb",
108
+ "test/test_EC2_s3_xmlsimple.rb",
109
+ "test/test_EC2_security_groups.rb",
110
+ "test/test_EC2_snapshots.rb",
111
+ "test/test_EC2_volumes.rb",
112
+ "test/test_ELB_load_balancers.rb",
113
+ "test/test_helper.rb",
114
+ "test/test_RDS.rb"
115
+ ]
116
+
117
+ if s.respond_to? :specification_version then
118
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
119
+ s.specification_version = 3
120
+
121
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
122
+ s.add_runtime_dependency(%q<xml-simple>, [">= 1.0.12"])
123
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
124
+ s.add_development_dependency(%q<test-spec>, [">= 0.10.0"])
125
+ s.add_development_dependency(%q<rcov>, [">= 0.9.6"])
126
+ s.add_development_dependency(%q<perftools.rb>, [">= 0.3.9"])
127
+ else
128
+ s.add_dependency(%q<xml-simple>, [">= 1.0.12"])
129
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
130
+ s.add_dependency(%q<test-spec>, [">= 0.10.0"])
131
+ s.add_dependency(%q<rcov>, [">= 0.9.6"])
132
+ s.add_dependency(%q<perftools.rb>, [">= 0.3.9"])
133
+ end
134
+ else
135
+ s.add_dependency(%q<xml-simple>, [">= 1.0.12"])
136
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
137
+ s.add_dependency(%q<test-spec>, [">= 0.10.0"])
138
+ s.add_dependency(%q<rcov>, [">= 0.9.6"])
139
+ s.add_dependency(%q<perftools.rb>, [">= 0.3.9"])
140
+ end
141
+ end
142
+
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Amazon Web Services EC2 Query API Ruby library
4
+ #
5
+ # Ruby Gem Name:: amazon-ec2
6
+ # Author:: Glenn Rempe (mailto:glenn@rempe.us)
7
+ # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://github.com/grempe/amazon-ec2/tree/master
10
+ #++
11
+
12
+ require File.dirname(__FILE__) + '/../lib/AWS'
13
+ require 'pp'
14
+
15
+ # pull these from the local shell environment variables set in ~/.bash_login
16
+ # or using appropriate methods specific to your login shell.
17
+ #
18
+ # e.g. in ~/.bash_login
19
+ #
20
+ # # For amazon-ec2 and amazon s3 ruby gems
21
+ # export AMAZON_ACCESS_KEY_ID="FOO"
22
+ # export AMAZON_SECRET_ACCESS_KEY="BAR"
23
+
24
+ ACCESS_KEY_ID = ENV['AMAZON_ACCESS_KEY_ID']
25
+ SECRET_ACCESS_KEY = ENV['AMAZON_SECRET_ACCESS_KEY']
26
+
27
+ if ACCESS_KEY_ID.nil? || ACCESS_KEY_ID.empty?
28
+ puts "Error : You must add the shell environment variables AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY before calling #{$0}!"
29
+ exit
30
+ end
31
+
32
+ # us-east-1.ec2.amazonaws.com == ec2.amazonaws.com
33
+ # eu-west-1.ec2.amazonaws.com for the european region
34
+ # test different servers by running something like:
35
+ # export EC2_URL='https://ec2.amazonaws.com';./bin/ec2-gem-example.rb
36
+ if ENV['EC2_URL']
37
+ ec2 = AWS::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['EC2_URL']).host )
38
+ else
39
+ # default server is US ec2.amazonaws.com
40
+ ec2 = AWS::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY )
41
+ end
42
+
43
+ puts "----- ec2.methods.sort -----"
44
+ p ec2.methods.sort
45
+
46
+ puts "----- listing images owned by 'amazon' -----"
47
+ ec2.describe_images(:owner_id => "amazon").imagesSet.item.each do |image|
48
+ image.keys.each do |key|
49
+ puts "#{key} => #{image[key]}"
50
+ end
51
+ end
52
+
53
+ puts "----- listing all running instances -----"
54
+ pp ec2.describe_instances()
55
+
56
+ puts "----- creating a security group -----"
57
+ pp ec2.create_security_group(:group_name => "ec2-example-rb-test-group", :group_description => "ec-example.rb test group description.")
58
+
59
+ puts "----- listing security groups -----"
60
+ pp ec2.describe_security_groups()
61
+
62
+ puts "----- deleting a security group -----"
63
+ pp ec2.delete_security_group(:group_name => "ec2-example-rb-test-group")
64
+
65
+ puts "----- listing my keypairs (verbose mode) -----"
66
+ pp ec2.describe_keypairs()
67
+
68
+ # ELB examples
69
+ # Autoscaling examples
70
+ if ENV['ELB_URL']
71
+ elb = AWS::ELB::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['ELB_URL']).host )
72
+ else
73
+ elb = AWS::ELB::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
74
+ end
75
+
76
+ puts "----- creating an elastic load balancer -----"
77
+ pp elb.create_load_balancer(
78
+ :availability_zones => ["us-east-1a"],
79
+ :load_balancer_name => "elb-test-load-balancer",
80
+ :listeners => [{:protocol => "tcp", :load_balancer_port => "80", :instance_port => "8080"}]
81
+ )
82
+
83
+ puts "----- listing elastic load balancers -----"
84
+ pp elb.describe_load_balancers(:load_balancer_names => ["elb-test-load-balancer"])
85
+
86
+ puts "----- deleting load balancer -----"
87
+ pp elb.delete_load_balancer(:load_balancer_name => "elb-test-load-balancer")
88
+
89
+ # Autoscaling examples
90
+ if ENV['AS_URL']
91
+ as = AWS::Autoscaling::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY, :server => URI.parse(ENV['AS_URL']).host )
92
+ else
93
+ as = AWS::Autoscaling::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
94
+ end
95
+
96
+ puts "---- creating a launch configuration group -----"
97
+ pp as.create_launch_configuration(
98
+ :image_id => "ami-ed46a784",
99
+ :instance_type => "m1.small",
100
+ :availability_zones => ["us-east-1a"],
101
+ :launch_configuration_name => "ec2-example-test-launch-configuration"
102
+ )
103
+
104
+ puts "---- creating an autoscaling group -----"
105
+ pp as.create_autoscaling_group( :autoscaling_group_name => "ec2-example-test-autoscaling-group",
106
+ :availability_zones => ["us-east-1a"],
107
+ :min_size => 0,
108
+ :max_size => 0,
109
+ :launch_configuration_name => "ec2-example-test-launch-configuration"
110
+ )
111
+
112
+ puts "---- listing autoscaling groups -----"
113
+ pp as.describe_autoscaling_groups(:autoscaling_group_names => [])
114
+
115
+ puts "---- creating a new autoscaling trigger ----"
116
+ pp as.create_or_updated_scaling_trigger(
117
+ :autoscaling_group_name => "ec2-example-test-autoscaling-group",
118
+ :measure_name => "CPUUtilization",
119
+ :statistic => "Average",
120
+ :period => 300,
121
+ :trigger_name => "test-auto-scaling-trigger-name",
122
+ :lower_threshold => 0.2,
123
+ :lower_breach_scale_increment => 0,
124
+ :upper_threshold => 1.5,
125
+ :upper_breach_scale_increment => 0,
126
+ :breach_duration => 1200,
127
+ :dimensions => ["AutoScalingGroupName", "ec2-example-test-autoscaling-group"]
128
+ )
129
+
130
+ puts "---- deleting scaling trigger -----"
131
+ pp as.delete_trigger(:trigger_name => "test-auto-scaling-trigger-name", :autoscaling_group_name => "ec2-example-test-autoscaling-group")
132
+
133
+ puts "---- deleting autoscaling group -----"
134
+ pp as.delete_autoscaling_group(:autoscaling_group_name => "ec2-example-test-autoscaling-group")
135
+
136
+ puts "---- deleting launch configuration group -----"
137
+ pp as.delete_launch_configuration(:launch_configuration_name => "ec2-example-test-launch-configuration")
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Basic single command application that we can call with perftools.rb to get consistent results.
4
+
5
+ require File.dirname(__FILE__) + '/../lib/AWS'
6
+ ACCESS_KEY_ID = ENV['AMAZON_ACCESS_KEY_ID']
7
+ SECRET_ACCESS_KEY = ENV['AMAZON_SECRET_ACCESS_KEY']
8
+ ec2 = AWS::EC2::Base.new( :access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY )
9
+ @images = ec2.describe_images
10
+
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Amazon Web Services EC2 Query API Ruby library
4
+ #
5
+ # Ruby Gem Name:: amazon-ec2
6
+ # Author:: Glenn Rempe (mailto:glenn@rempe.us)
7
+ # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://github.com/grempe/amazon-ec2/tree/master
10
+ #++
11
+
12
+ # CREDITS : Credit for this bit of shameful ripoff coolness
13
+ # goes to Marcel Molina and his AWS::S3 gem. Thanks!
14
+
15
+ # Usage : running this starts up an irb session and
16
+ # sets up the connection to EC2 as a class variable called
17
+ # '@ec2'. So just do something like the following on the
18
+ # shell command line:
19
+
20
+ # macbook-pro:~ glenn$ ec2sh
21
+ # >> @ec2.describe_images
22
+ # => [#<AWS::EC2::Item image_location...
23
+
24
+ aws_lib = File.dirname(__FILE__) + '/../lib/AWS'
25
+ setup = File.dirname(__FILE__) + '/setup'
26
+ irb_name = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
27
+
28
+ if ( ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY'] )
29
+
30
+ welcome_message = <<-MESSAGE
31
+
32
+ 'ec2sh' usage :
33
+ This is an interactive 'irb' command shell that allows you to use all
34
+ commands available to the amazon-ec2 gem. You'll find this to be a
35
+ great tool to help you debug issues and practice running commands
36
+ against the live EC2 servers prior to putting them in your code.
37
+
38
+ The EC2 connection is wired to the class instance '@ec2'. Make method calls
39
+ on this to execute commands on EC2. Adding a #to_s
40
+ at the end of any command should give you a full String representation of the
41
+ response.
42
+
43
+ Examples to try:
44
+
45
+ returns : all ec2 public methods
46
+ >> @ec2.methods.sort
47
+
48
+ returns : a string representation of ALL images
49
+ >> @ec2.describe_images.to_s
50
+
51
+ returns : an Array of AWS::Response objects, each an EC2 image and its data
52
+ >> @ec2.describe_images.imagesSet.item
53
+ >> @ec2.describe_images.imagesSet.item[0] (a hash representing a single item in that array)
54
+ >> @ec2.describe_images.imagesSet.item[0].to_s (a String representation of that item)
55
+
56
+ MESSAGE
57
+
58
+ puts welcome_message
59
+ exec "#{irb_name} -rubygems -r #{aws_lib} -r #{setup} --simple-prompt"
60
+ else
61
+ puts "You must define AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY as shell environment variables before running #{$0}!"
62
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Amazon Web Services EC2 Query API Ruby library
4
+ #
5
+ # Ruby Gem Name:: amazon-ec2
6
+ # Author:: Glenn Rempe (mailto:glenn@rempe.us)
7
+ # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://github.com/grempe/amazon-ec2/tree/master
10
+ #++
11
+
12
+ if ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY']
13
+ opts = {
14
+ :access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
15
+ :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
16
+ }
17
+ if ENV['EC2_URL']
18
+ opts[:server] = URI.parse(ENV['EC2_URL']).host
19
+ end
20
+ @ec2 = AWS::EC2::Base.new(opts)
21
+ @elb = AWS::ELB::Base.new(opts)
22
+ @as = AWS::Autoscaling::Base.new(opts)
23
+ @rds = AWS::RDS::Base.new(opts)
24
+ end
25
+
26
+ puts "EC2 Server: #{opts[:server]}"
27
+
28
+ include AWS
29
+