hugo 0.3.5 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -16,8 +16,8 @@ begin
16
16
  gemspec.add_dependency('json')
17
17
 
18
18
  gemspec.name = "hugo"
19
- gemspec.summary = "Deploy Your Rack Apps to Cloud"
20
- gemspec.description = "Deploy your apps to the cloud."
19
+ gemspec.summary = "Deploy Your Rack Apps to EC2 Cloud"
20
+ gemspec.description = "Deploy your apps to the EC2 cloud."
21
21
  gemspec.email = "tom@jackhq.com"
22
22
  gemspec.homepage = "http://github.com/twilson63/hugo2"
23
23
  gemspec.authors = ["Tom Wilson", "Barrett Little"]
@@ -43,7 +43,9 @@ class Hugo::App
43
43
  raise ArgumentError, "app.key_path Required" unless key_path
44
44
  raise ArgumentError, "app.cookbook Required" unless cookbook
45
45
  raise ArgumentError, "app.run_list Required" unless run_list
46
-
46
+ raise ArgumentError, "app.aws_access_key_id Required" unless aws_access_key_id
47
+ raise ArgumentError, "app.aws_secret_access_key Required" unless aws_secret_access_key
48
+
47
49
  deploy_ec2
48
50
  #puts "Deploy Completed"
49
51
  end
@@ -52,10 +54,10 @@ class Hugo::App
52
54
  def destroy
53
55
  if lb
54
56
  lb.instances.each do |i|
55
- Hugo::Aws::Ec2.find(i).destroy
57
+ ec2(i).destroy
56
58
  end
57
59
  else
58
- Hugo::Aws::Ec2.find(instance).destroy
60
+ ec2(instance).destroy
59
61
  end
60
62
 
61
63
  end
@@ -65,6 +67,8 @@ class Hugo::App
65
67
  @key_path = nil
66
68
  @cookbook = nil
67
69
  @run_list = nil
70
+ @aws_access_key_id = nil
71
+ @aws_secret_access_key = nil
68
72
  end
69
73
 
70
74
 
@@ -98,6 +102,16 @@ class Hugo::App
98
102
  def db(arg=nil)
99
103
  set_or_return(:db, arg, :kind_of => [Hugo::Database])
100
104
  end
105
+
106
+ # Aws Access Key for EC2 Deployment
107
+ def aws_access_key_id(arg=nil)
108
+ set_or_return(:aws_access_key_id, arg, :kind_of => [String])
109
+ end
110
+
111
+ # Aws Access Secret Key for EC2 Deployment
112
+ def aws_secret_access_key(arg=nil)
113
+ set_or_return(:aws_secret_access_key, arg, :kind_of => [String])
114
+ end
101
115
 
102
116
  # URI of
103
117
  # def uri(arg=nil)
@@ -199,16 +213,18 @@ private
199
213
  end
200
214
 
201
215
  def create_ec2
202
- ec2 = Hugo::Aws::Ec2.new(:type => type || TYPE,
216
+ aws_ec2 = Hugo::Aws::Ec2.new(:type => type || TYPE,
203
217
  :zone => zone || ZONE,
204
218
  :image_id => image_id || AMI,
205
219
  :key_name => key_name,
206
- :security_group => security_group || "default").create
220
+ :security_group => security_group || "default",
221
+ :aws_access_key_id => aws_access_key_id,
222
+ :aws_secret_access_key => aws_secret_access_key).create
207
223
 
208
224
  new_ec2 = nil
209
225
  sleep 10
210
226
  loop do
211
- new_ec2 = Hugo::Aws::Ec2.find(ec2.name)
227
+ new_ec2 = ec2(aws_ec2.name)
212
228
  puts new_ec2.status
213
229
  if new_ec2.status == "running"
214
230
  break
@@ -225,8 +241,8 @@ private
225
241
  commands = []
226
242
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo apt-get update -y; fi'
227
243
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo apt-get install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential git-core xfsprogs -y; fi'
228
- commands << 'if [ -d "./hugo-repos" ]; then echo "."; else wget http://rubyforge.org/frs/download.php/60718/rubygems-1.3.5.tgz && tar zxf rubygems-1.3.5.tgz; fi'
229
- commands << 'if [ -d "./hugo-repos" ]; then echo "."; else cd rubygems-1.3.5 && sudo ruby setup.rb && sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem; fi'
244
+ commands << 'if [ -d "./hugo-repos" ]; then echo "."; else wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz && tar zxf rubygems-1.3.6.tgz; fi'
245
+ commands << 'if [ -d "./hugo-repos" ]; then echo "."; else cd rubygems-1.3.6 && sudo ruby setup.rb && sudo ln -sfv /usr/bin/gem1.8 /usr/bin/gem; fi'
230
246
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo gem update --system; fi'
231
247
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo gem install gemcutter --no-ri --no-rdoc; fi'
232
248
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo gem install chef -v 0.7.16 --no-ri --no-rdoc; fi'
@@ -235,9 +251,7 @@ private
235
251
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo gem install chef-deploy --no-ri --no-rdoc; fi'
236
252
  commands << 'if [ -d "./hugo-repos" ]; then echo "."; else sudo gem install git --no-ri --no-rdoc; fi'
237
253
  commands << "if [ -d \"./hugo-repos\" ]; then echo \".\"; else git clone #{self.cookbook} ~/hugo-repos; fi"
238
- ec2 = Hugo::Aws::Ec2.find(instance_id)
239
- #puts ec2.uri
240
- ec2.ssh(commands, nil, File.join(key_path, key_name))
254
+ ec2(instance_id).ssh(commands, nil, File.join(key_path, key_name))
241
255
  end
242
256
 
243
257
  def deploy_ec2
@@ -251,17 +265,17 @@ private
251
265
  self.dna.merge!(
252
266
  :run_list => run_list,
253
267
  :git => cookbook,
254
- :access_key => Hugo::Aws::Ec2::ACCESS_KEY,
255
- :secret_key => Hugo::Aws::Ec2::SECRET_KEY,
268
+ :access_key => aws_access_key_id,
269
+ :secret_key => aws_secret_access_key,
256
270
  :database => db ? db.info : {}
257
271
  )
258
272
 
259
273
  if lb
260
274
  lb.instances.each do |i|
261
- Hugo::Aws::Ec2.find(i).ssh(commands, dna, File.join(key_path, key_name))
275
+ ec2(i).ssh(commands, dna, File.join(key_path, key_name))
262
276
  end
263
277
  else
264
- Hugo::Aws::Ec2.find(instance).ssh(commands, dna, File.join(key_path, key_name))
278
+ ec2(instance).ssh(commands, dna, File.join(key_path, key_name))
265
279
  end
266
280
 
267
281
  end
@@ -269,11 +283,16 @@ private
269
283
  def delete_ec2(i=1)
270
284
  i.times do
271
285
  instance_id = lb.instances[0]
272
- Hugo::Aws::Ec2.find(instance_id).destroy
286
+ ec2(instance_id).destroy
273
287
  #lb.remove(instance_id)
274
288
 
275
289
  end
276
290
  end
291
+
292
+ def ec2(instance_id)
293
+ Hugo::Aws::Ec2.find(instance, aws_access_key_id, aws_secret_access_key)
294
+ end
295
+
277
296
 
278
297
 
279
298
  end
@@ -10,7 +10,9 @@ module Hugo
10
10
  ZONE = "us-east-1c"
11
11
  TYPE = "m1.small"
12
12
 
13
- attr_accessor :name, :uri, :type, :zone, :image_id, :key_name, :create_time, :status, :security_group
13
+ attr_accessor :name, :uri, :type, :zone, :image_id, :key_name,
14
+ :create_time, :status, :security_group,
15
+ :aws_access_key_id, :aws_secret_access_key
14
16
 
15
17
  def initialize(options = {})
16
18
  set_attributes(options)
@@ -45,12 +47,16 @@ module Hugo
45
47
  @security_group = options["groupSet"]["item"][0]["groupId"]
46
48
  end
47
49
 
50
+ @aws_access_key_id = options[:aws_access_key_id] || ACCESS_KEY
51
+ @aws_secret_access_key = options[:aws_secret_access_key] || SECRET_KEY
52
+
48
53
  end
49
54
 
50
55
 
51
56
  def create
52
- @ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
53
- result = @ec2.run_instances(:image_id => self.image_id, :key_name => self.key_name,
57
+ result = ec2.run_instances(
58
+ :image_id => self.image_id,
59
+ :key_name => self.key_name,
54
60
  :max_count => 1,
55
61
  :availability_zone => self.zone,
56
62
  :security_group => self.security_group) unless self.create_time
@@ -59,8 +65,7 @@ module Hugo
59
65
  end
60
66
 
61
67
  def destroy
62
- @ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
63
- @ec2.terminate_instances(:instance_id => self.name)
68
+ ec2.terminate_instances(:instance_id => self.name)
64
69
  end
65
70
 
66
71
  def save
@@ -97,13 +102,13 @@ module Hugo
97
102
  # @ec2.delete_security_group(:group_name => name)
98
103
  # end
99
104
 
100
- def self.all
101
- @ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
105
+ def self.all(access_key_id, secret_access_key)
106
+ @ec2 = AWS::EC2::Base.new(:access_key_id => access_key_id, :secret_access_key => secret_access_key)
102
107
  @ec2.describe_instances().reservationSet.item[0].instancesSet.item.map { |i| self.new(i) }
103
108
  end
104
109
 
105
- def self.find(instance)
106
- @ec2 = AWS::EC2::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
110
+ def self.find(instance, access_key_id, secret_access_key)
111
+ @ec2 = AWS::EC2::Base.new(:access_key_id => access_key_id, :secret_access_key => secret_access_key)
107
112
  self.new(@ec2.describe_instances(:instance_id => instance).reservationSet.item[0].instancesSet.item[0])
108
113
  end
109
114
 
@@ -119,6 +124,17 @@ module Hugo
119
124
  self.new(options).create
120
125
  end
121
126
  end
127
+
128
+ private
129
+ def ec2
130
+ AWS::EC2::Base.new(
131
+ :access_key_id => self.aws_access_key_id,
132
+ :secret_access_key => self.aws_secret_access_key)
133
+
134
+ end
135
+
136
+
137
+
122
138
  end
123
139
  end
124
140
  end
@@ -8,7 +8,7 @@ module Hugo
8
8
  LISTENERS = [{"InstancePort"=>"8080", "Protocol"=>"HTTP", "LoadBalancerPort"=>"80"},
9
9
  {"InstancePort"=>"8443", "Protocol"=>"TCP", "LoadBalancerPort"=>"443"}]
10
10
 
11
- attr_accessor :name, :uri, :listeners, :instances, :zones, :create_time
11
+ attr_accessor :name, :uri, :listeners, :instances, :zones, :create_time, :aws_access_key_id, :aws_secret_access_key
12
12
 
13
13
  def initialize(options = {} )
14
14
  @name = options[:name] || options["LoadBalancerName"]
@@ -33,11 +33,14 @@ module Hugo
33
33
  if options["CreatedTime"]
34
34
  @create_time = options["CreatedTime"]
35
35
  end
36
+
37
+ @aws_access_key_id = options[:aws_access_key_id] || ACCESS_KEY
38
+ @aws_secret_access_key = options[:aws_secret_access_key] || SECRET_KEY
39
+
36
40
  end
37
41
 
38
42
  def create
39
- @elb = AWS::ELB::Base.new(:access_key_id => Hugo::Aws::Elb::ACCESS_KEY, :secret_access_key => Hugo::Aws::Elb::SECRET_KEY)
40
- @elb.create_load_balancer(
43
+ elb.create_load_balancer(
41
44
  :load_balancer_name => self.name,
42
45
  :listeners => self.listeners,
43
46
  :availability_zones => self.zones
@@ -46,8 +49,7 @@ module Hugo
46
49
  end
47
50
 
48
51
  def destroy
49
- @elb = AWS::ELB::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
50
- @elb.delete_load_balancer(:load_balancer_name => self.name)
52
+ elb.delete_load_balancer(:load_balancer_name => self.name)
51
53
  end
52
54
 
53
55
  def save
@@ -55,8 +57,7 @@ module Hugo
55
57
  end
56
58
 
57
59
  def add(instance)
58
- @elb = AWS::ELB::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
59
- @elb.register_instances_with_load_balancer(
60
+ elb.register_instances_with_load_balancer(
60
61
  :instances => [instance],
61
62
  :load_balancer_name => @name)
62
63
  @instances << instance
@@ -65,21 +66,20 @@ module Hugo
65
66
 
66
67
  def remove(instance)
67
68
 
68
- @elb = AWS::ELB::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
69
- @elb.deregister_instances_from_load_balancer(
69
+ elb.deregister_instances_from_load_balancer(
70
70
  :instances => [instance],
71
71
  :load_balancer_name => @name)
72
72
  @instances = @instances - [instance]
73
73
  self
74
74
  end
75
75
 
76
- def self.all
77
- @elb = AWS::ELB::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
76
+ def self.all(aws_access_key_id, aws_secret_access_key)
77
+ @elb = AWS::ELB::Base.new(:access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key)
78
78
  instances = @elb.describe_load_balancers().DescribeLoadBalancersResult.LoadBalancerDescriptions.member
79
79
  instances.map { |i| self.new(i) }
80
80
  end
81
81
 
82
- def self.find(balancer)
82
+ def self.find(balancer, aws_access_key_id, aws_secret_access_key)
83
83
  @elb = AWS::ELB::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
84
84
 
85
85
  result = nil
@@ -94,8 +94,14 @@ module Hugo
94
94
  end
95
95
 
96
96
  def self.find_or_create(options)
97
- self.find(options[:name]) || self.new(options).create
97
+ self.find(options[:name], options[:aws_access_key_id], options[:aws_secret_access_key]) || self.new(options).create
98
+ end
99
+
100
+ private
101
+ def elb
102
+ AWS::ELB::Base.new(:access_key_id => @aws_access_key_id, :secret_access_key => @aws_secret_access_key)
98
103
  end
104
+
99
105
  end
100
106
  end
101
107
  end
@@ -9,7 +9,10 @@ module Hugo
9
9
  ZONE = "us-east-1c"
10
10
 
11
11
  attr_accessor :db, :uri, :server, :user, :password, :instance_class,
12
- :zone, :size, :status, :create_time, :db_security_group
12
+ :zone, :size, :status, :create_time, :db_security_group,
13
+ :aws_access_key_id, :aws_secret_access_key
14
+
15
+
13
16
 
14
17
  def initialize(options={})
15
18
  # create instance
@@ -30,18 +33,14 @@ module Hugo
30
33
  if options["DBSecurityGroups"] and options["DBSecurityGroups"]["DBSecurityGroup"]
31
34
  @db_security_group = options["DBSecurityGroups"]["DBSecurityGroup"]["DBSecurityGroupName"]
32
35
  end
36
+ @aws_access_key_id = options[:aws_access_key_id] || ACCESS_KEY
37
+ @aws_secret_access_key = options[:aws_secret_access_key] || SECRET_KEY
33
38
 
34
39
  end
35
40
 
36
41
  def create
37
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
38
42
 
39
- # TODO Create DB Security Group wheh Amazon Bug Fixed! -tnw
40
- # if @db_security_group
41
- # find_or_create_db_security_group(@db_security_group, @db_security_group)
42
- # end
43
-
44
- @rds.create_db_instance(
43
+ rds.create_db_instance(
45
44
  :db_instance_identifier => self.server,
46
45
  :allocated_storage => self.size,
47
46
  :db_instance_class => self.instance_class,
@@ -60,12 +59,11 @@ module Hugo
60
59
  end
61
60
 
62
61
  def destroy
63
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
64
- @rds.delete_db_instance(:db_instance_identifier => self.server, :skip_final_snapshot => true)
62
+ rds.delete_db_instance(:db_instance_identifier => self.server, :skip_final_snapshot => true)
65
63
  end
66
64
 
67
- def self.all
68
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
65
+ def self.all(aws_access_key_id, aws_secret_access_key)
66
+ @rds = AWS::RDS::Base.new(:access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key)
69
67
  instances = @rds.describe_db_instances.DescribeDBInstancesResult.DBInstances.DBInstance
70
68
 
71
69
  if instances.kind_of?(Array)
@@ -77,9 +75,9 @@ module Hugo
77
75
  end
78
76
  end
79
77
 
80
- def self.find(instance)
78
+ def self.find(instance, aws_access_key_id, aws_secret_access_key)
81
79
  # find instance
82
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
80
+ @rds = AWS::RDS::Base.new(:access_key_id => aws_access_key_id, :secret_access_key => aws_secret_access_key)
83
81
  @rds_instance = @rds.describe_db_instances(:db_instance_identifier => instance)
84
82
  instance_desc = @rds_instance.DescribeDBInstancesResult.DBInstances.DBInstance
85
83
  # initialize Hugo::Rds Object with instance hash
@@ -90,31 +88,36 @@ module Hugo
90
88
  end
91
89
 
92
90
  def self.find_or_create(options)
93
- rds = self.find(options[:server]) || self.new(options).create
91
+ rds = self.find(options[:server], options[:aws_access_key_id], options[:aws_secret_access_key]) || self.new(options).create
94
92
  rds.db = options[:name]
95
93
  rds.password = options[:password]
96
94
  rds
97
95
  end
98
96
 
99
97
  def authorize_security_group(db_sec, ec2_sec, owner_id)
100
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
101
- @rds.authorize_db_security_group(:db_security_group_name => db_sec, :ec2_security_group_name => ec2_sec, :ec2_security_group_owner_id => owner_id)
98
+ #@rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
99
+ rds.authorize_db_security_group(:db_security_group_name => db_sec, :ec2_security_group_name => ec2_sec, :ec2_security_group_owner_id => owner_id)
102
100
  end
103
101
 
104
102
  def find_or_create_db_security_group(name, description)
105
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
103
+ #@rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
106
104
  begin
107
- @security_groups = @rds.describe_db_security_groups(:db_security_group_name => name)
105
+ @security_groups = rds.describe_db_security_groups(:db_security_group_name => name)
108
106
  rescue
109
- @security_groups = @rds.create_db_security_group(:db_security_group_name => name, :db_security_group_description => description)
107
+ @security_groups = rds.create_db_security_group(:db_security_group_name => name, :db_security_group_description => description)
110
108
  end
111
109
  #puts @security_groups
112
110
  @security_groups
113
111
  end
114
112
 
115
113
  def destroy_db_security_group(name)
116
- @rds = AWS::RDS::Base.new(:access_key_id => ACCESS_KEY, :secret_access_key => SECRET_KEY)
117
- @rds.delete_db_security_group(:db_security_group_name => name)
114
+ rds.delete_db_security_group(:db_security_group_name => name)
115
+ end
116
+ private
117
+ def rds
118
+ AWS::RDS::Base.new(
119
+ :access_key_id => self.aws_access_key_id,
120
+ :secret_access_key => self.aws_secret_access_key)
118
121
  end
119
122
  end
120
123
  end
@@ -21,10 +21,15 @@ class Hugo::Balancer
21
21
  end
22
22
 
23
23
  def deploy
24
+ raise ArgumentError, "app.aws_access_key_id Required" unless aws_access_key_id
25
+ raise ArgumentError, "app.aws_secret_access_key Required" unless aws_secret_access_key
26
+
24
27
  Hugo::Aws::Elb.find_or_create(:name => name,
25
28
  :zones => zone,
26
29
  :listeners => [{ :instance_port => port, :protocol =>"HTTP", :load_balancer_port => web},
27
- { :instance_port => ssl_port, :protocol =>"TCP", :load_balancer_port => ssl_web}]
30
+ { :instance_port => ssl_port, :protocol =>"TCP", :load_balancer_port => ssl_web}],
31
+ :aws_access_key_id => aws_access_key_id,
32
+ :aws_secret_access_key => aws_secret_access_key
28
33
  )
29
34
  end
30
35
 
@@ -88,4 +93,14 @@ HELP
88
93
  set_or_return(:ssl_web, arg, :kind_of => [String])
89
94
  end
90
95
 
96
+ # Aws Access Key for EC2 Deployment
97
+ def aws_access_key_id(arg=nil)
98
+ set_or_return(:aws_access_key_id, arg, :kind_of => [String])
99
+ end
100
+
101
+ # Aws Access Secret Key for EC2 Deployment
102
+ def aws_secret_access_key(arg=nil)
103
+ set_or_return(:aws_secret_access_key, arg, :kind_of => [String])
104
+ end
105
+
91
106
  end
@@ -15,6 +15,8 @@ class Hugo::Cloud
15
15
  database.db_security_group name
16
16
  database.server name
17
17
  database.name db_name
18
+ database.aws_access_key_id(aws_access_key_id) if aws_access_key_id
19
+ database.aws_secret_access_key(aws_secret_access_key) if aws_secret_access_key
18
20
 
19
21
  database.instance_eval(&block) if block_given?
20
22
  db database.deploy
@@ -24,6 +26,9 @@ class Hugo::Cloud
24
26
  def balancer(&block)
25
27
  balancer = Hugo::Balancer.instance
26
28
  balancer.name name
29
+ balancer.aws_access_key_id(aws_access_key_id) if aws_access_key_id
30
+ balancer.aws_secret_access_key(aws_secret_access_key) if aws_secret_access_key
31
+
27
32
  balancer.instance_eval(&block) if block_given?
28
33
  lb balancer.deploy
29
34
  end
@@ -31,6 +36,9 @@ class Hugo::Cloud
31
36
  def app(name, &block)
32
37
  app_info = Hugo::App.instance
33
38
  app_info.name name
39
+ app_info.aws_access_key_id(aws_access_key_id) if aws_access_key_id
40
+ app_info.aws_secret_access_key(aws_secret_access_key) if aws_secret_access_key
41
+
34
42
  app_info.lb lb
35
43
  app_info.db db
36
44
  #app_info.cloud_name name
@@ -54,7 +62,11 @@ class Hugo::Cloud
54
62
  db.rds.destroy
55
63
  end
56
64
 
57
-
65
+ def clear
66
+ aws_access_key_id(nil)
67
+ aws_secret_access_key(nil)
68
+
69
+ end
58
70
 
59
71
  def print
60
72
  if db
@@ -120,6 +132,15 @@ REPORT
120
132
  end
121
133
 
122
134
 
135
+ # Aws Access Key for EC2 Deployment
136
+ def aws_access_key_id(arg=nil)
137
+ set_or_return(:aws_access_key_id, arg, :kind_of => [String])
138
+ end
139
+
140
+ # Aws Access Secret Key for EC2 Deployment
141
+ def aws_secret_access_key(arg=nil)
142
+ set_or_return(:aws_secret_access_key, arg, :kind_of => [String])
143
+ end
123
144
 
124
145
 
125
146
 
@@ -25,6 +25,8 @@ class Hugo::Database
25
25
  raise ArgumentError, "database.server Required" unless server
26
26
  raise ArgumentError, "database.user Required" unless user
27
27
  raise ArgumentError, "database.password Required" unless password
28
+ raise ArgumentError, "database.aws_access_key_id Required" unless aws_access_key_id
29
+ raise ArgumentError, "database.aws_secret_access_key Required" unless aws_secret_access_key
28
30
 
29
31
 
30
32
  @rds = Hugo::Aws::Rds.find_or_create( :name => name,
@@ -33,7 +35,10 @@ class Hugo::Database
33
35
  :password => password,
34
36
  :size => size,
35
37
  :zone => zone,
36
- :db_security_group => db_security_group
38
+ :db_security_group => db_security_group,
39
+ :aws_access_key_id => aws_access_key_id,
40
+ :aws_secret_access_key => aws_secret_access_key
41
+
37
42
  )
38
43
  self
39
44
  end
@@ -106,5 +111,15 @@ HELP
106
111
  def db_security_group(arg=nil)
107
112
  set_or_return(:db_security_group, arg, :kind_of => [String])
108
113
  end
114
+
115
+ # Aws Access Key for EC2 Deployment
116
+ def aws_access_key_id(arg=nil)
117
+ set_or_return(:aws_access_key_id, arg, :kind_of => [String])
118
+ end
119
+
120
+ # Aws Access Secret Key for EC2 Deployment
121
+ def aws_secret_access_key(arg=nil)
122
+ set_or_return(:aws_secret_access_key, arg, :kind_of => [String])
123
+ end
109
124
 
110
125
  end
@@ -5,10 +5,49 @@ describe "Hugo App" do
5
5
  mocks
6
6
  end
7
7
 
8
+ it "should allow aws key and secret key overrides" do
9
+ block = lambda do
10
+ cloud "my_cloud" do
11
+ clear
12
+ aws_access_key_id "12345"
13
+ aws_secret_access_key "123456"
14
+
15
+ database "my_db" do
16
+ server "my_server"
17
+ user "hello"
18
+ password "world"
19
+ end
20
+
21
+ balancer
22
+
23
+ app "testapp" do
24
+ clear
25
+ key_name "ec2-keypair"
26
+ key_path "~/.ec2"
27
+ cookbook "git@github.com:jackhq/hugo-cookbooks.git"
28
+
29
+ servers 0
30
+ end
31
+ #deploy
32
+ #print
33
+ end
34
+ end
35
+
36
+ lambda do
37
+ Hugo &block
38
+ end.should_not raise_error
39
+
40
+ end
41
+
42
+
8
43
  it "should be valid" do
9
44
 
10
45
  block = lambda do
11
46
  cloud "my_cloud" do
47
+ clear
48
+ aws_access_key_id "12345"
49
+ aws_secret_access_key "123456"
50
+
12
51
  database "my_db" do
13
52
  server "my_server"
14
53
  user "hello"
@@ -40,6 +79,10 @@ describe "Hugo App" do
40
79
  lambda do
41
80
  Hugo do
42
81
  cloud "my_cloud" do
82
+ clear
83
+ aws_access_key_id "12345"
84
+ aws_secret_access_key "123456"
85
+
43
86
  app "testapp" do
44
87
  clear
45
88
  key_path "~/.ec2"
@@ -56,6 +99,10 @@ describe "Hugo App" do
56
99
  lambda do
57
100
  Hugo do
58
101
  cloud "my_cloud" do
102
+ clear
103
+ aws_access_key_id "12345"
104
+ aws_secret_access_key "123456"
105
+
59
106
  app "testapp" do
60
107
  clear
61
108
  key_name "ec2-keypair"
@@ -72,6 +119,10 @@ describe "Hugo App" do
72
119
  lambda do
73
120
  Hugo do
74
121
  cloud "my_cloud" do
122
+ clear
123
+ aws_access_key_id "12345"
124
+ aws_secret_access_key "123456"
125
+
75
126
  app "testapp" do
76
127
  clear
77
128
  key_name "ec2-keypair"
@@ -84,6 +135,48 @@ describe "Hugo App" do
84
135
  end.should raise_error('app.cookbook Required')
85
136
  end
86
137
 
138
+ it "should raise error requiring aws_access_key_id" do
139
+ lambda do
140
+ Hugo do
141
+ cloud "my_cloud" do
142
+ clear
143
+ aws_secret_access_key "123456"
144
+
145
+ app "testapp" do
146
+ clear
147
+ key_name "ec2-keypair"
148
+ key_path "~/.ec2"
149
+ cookbook "my_cookbook"
150
+ run_list ["role[base_rack_apache]"]
151
+ end
152
+ deploy
153
+ end
154
+ end
155
+ end.should raise_error('app.aws_access_key_id Required')
156
+ end
157
+
158
+ it "should raise error requiring aws_secret_access_key" do
159
+ lambda do
160
+ Hugo do
161
+ cloud "my_cloud" do
162
+ clear
163
+
164
+ app "testapp" do
165
+ clear
166
+ aws_access_key_id "12345"
167
+
168
+ key_name "ec2-keypair"
169
+ key_path "~/.ec2"
170
+ cookbook "my_cookbook"
171
+ run_list ["role[base_rack_apache]"]
172
+ end
173
+ deploy
174
+ end
175
+ end
176
+ end.should raise_error('app.aws_secret_access_key Required')
177
+ end
178
+
179
+
87
180
 
88
181
  it "should save dna" do
89
182
  block = lambda do
@@ -29,24 +29,24 @@ describe Hugo::Aws::Ec2 do
29
29
  # end
30
30
 
31
31
  it "should terminate instance" do
32
- Hugo::Aws::Ec2.find('i-12345678').destroy.should be_true
32
+ Hugo::Aws::Ec2.find('i-12345678', '123456789','987654321').destroy.should be_true
33
33
  end
34
34
 
35
35
  it "should find instance" do
36
- Hugo::Aws::Ec2.find('i-12345678').should_not be_nil
36
+ Hugo::Aws::Ec2.find('i-12345678', '123456789','987654321').should_not be_nil
37
37
  end
38
38
 
39
39
  it "should return all instances" do
40
- Hugo::Aws::Ec2.all.length.should == 1
40
+ Hugo::Aws::Ec2.all('123456789','987654321').length.should == 1
41
41
  end
42
42
 
43
- it "should find or create security group" do
44
- Hugo::Aws::Ec2.find_or_create_security_group('test', 'test description').should_not be_empty
45
- end
46
-
47
- it "should destroy a security group" do
48
- Hugo::Aws::Ec2.destroy_security_group('test').should be_true
49
- end
43
+ # it "should find or create security group" do
44
+ # Hugo::Aws::Ec2.find_or_create_security_group('test', 'test description').should_not be_empty
45
+ # end
46
+ #
47
+ # it "should destroy a security group" do
48
+ # Hugo::Aws::Ec2.destroy_security_group('test').should be_true
49
+ # end
50
50
  #
51
51
  # it "should deploy app" do
52
52
  #
@@ -9,28 +9,29 @@ describe Hugo::Aws::Elb do
9
9
  end
10
10
 
11
11
  it "should create a new instance" do
12
- @hugo_elb = Hugo::Aws::Elb.new(:name => "myserver").should be_true
13
- @hugo_elb.save.should be_true
12
+ @hugo_elb = Hugo::Aws::Elb.new(:name => "myserver")
13
+ @hugo_elb.should_not be_nil
14
+ @hugo_elb.save.should_not be_nil
14
15
  end
15
16
  #
16
17
  it "should return all" do
17
- Hugo::Aws::Elb.all.length.should == 1
18
+ Hugo::Aws::Elb.all("1","2").length.should == 1
18
19
  end
19
20
  # #
20
21
  it "should find elb instance" do
21
- Hugo::Aws::Elb.find('test').should_not be_nil
22
+ Hugo::Aws::Elb.find('test',"1","2").should_not be_nil
22
23
  end
23
24
  #
24
25
  it "should delete elb instance" do
25
- Hugo::Aws::Elb.find('test').destroy.should_not be_nil
26
+ Hugo::Aws::Elb.find('test',"1","2").destroy.should_not be_nil
26
27
  end
27
28
 
28
29
  it "should add ec2 intance" do
29
- Hugo::Aws::Elb.find('test').add('i-12345678').instances.length.should == 1
30
+ Hugo::Aws::Elb.find('test',"1","2").add('i-12345678').instances.length.should == 1
30
31
  end
31
32
 
32
33
  it "should remove ec2 instance" do
33
- Hugo::Aws::Elb.find('test').remove('i-12345678').instances.length.should == 0
34
+ Hugo::Aws::Elb.find('test',"1","2").remove('i-12345678').instances.length.should == 0
34
35
  end
35
36
 
36
37
  end
@@ -8,37 +8,44 @@ describe Hugo::Aws::Rds do
8
8
  end
9
9
 
10
10
  it "should create a new instance" do
11
- @hugo_rds = Hugo::Aws::Rds.new(:name => "myserver", :db => "mydb", :user => "user", :password => "password").should be_true
11
+ @hugo_rds = Hugo::Aws::Rds.new(
12
+ :name => "myserver",
13
+ :db => "mydb",
14
+ :user => "user",
15
+ :password => "password",
16
+ :aws_access_key_id => '12',
17
+ :aws_secret_access_key => '12')
18
+ @hugo_rds.should_not be_nil
12
19
  @hugo_rds.save.should be_true
13
20
  end
14
21
 
15
22
  it "should return all" do
16
- Hugo::Aws::Rds.all.length.should == 1
23
+ Hugo::Aws::Rds.all('12','34').length.should == 1
17
24
  end
18
25
  #
19
26
  it "should find rds instance" do
20
- Hugo::Aws::Rds.find('test').should_not be_nil
27
+ Hugo::Aws::Rds.find('test','12','34').should_not be_nil
21
28
  end
22
29
 
23
30
  it "should delete rds instance" do
24
- Hugo::Aws::Rds.find('test').destroy
31
+ Hugo::Aws::Rds.find('test','12','34').destroy
25
32
  end
26
33
 
27
34
  it "should provide uri" do
28
- Hugo::Aws::Rds.find('test').uri.should_not be_nil
35
+ Hugo::Aws::Rds.find('test','12','34').uri.should_not be_nil
29
36
  end
30
37
 
31
- it "should find or create db security group" do
32
- @rds = Hugo::Aws::Rds.find('i-12345678')
33
- @rds.find_or_create_db_security_group('test', 'test description').should_not be_empty
34
- end
38
+ # it "should find or create db security group" do
39
+ # @rds = Hugo::Aws::Rds.find('i-12345678','12','34')
40
+ # @rds.find_or_create_db_security_group('test', 'test description').should_not be_empty
41
+ # end
35
42
 
36
- it "should destroy a db security group" do
37
- Hugo::Aws::Rds.find('i-12345678').destroy_db_security_group('test').should be_true
38
- end
43
+ # it "should destroy a db security group" do
44
+ # Hugo::Aws::Rds.find('i-12345678').destroy_db_security_group('test').should be_true
45
+ # end
39
46
 
40
- it "should authorize a ec2 security group" do
41
- @rds = Hugo::Aws::Rds.find('i-12345678')
42
- @rds.authorize_security_group('test', 'test', '12334').should_not be_empty
43
- end
47
+ # it "should authorize a ec2 security group" do
48
+ # @rds = Hugo::Aws::Rds.find('i-12345678','12','34')
49
+ # @rds.authorize_security_group('test', 'test', '12334').should_not be_empty
50
+ # end
44
51
  end
@@ -8,7 +8,13 @@ describe "Hugo Balancer" do
8
8
  it "should be valid" do
9
9
  block = lambda do
10
10
  cloud "my_cloud" do
11
- balancer
11
+ balancer do
12
+ aws_access_key_id "12345"
13
+ aws_secret_access_key "123456"
14
+
15
+ end
16
+
17
+
12
18
  end
13
19
  end
14
20
 
@@ -31,6 +37,8 @@ describe "Hugo Balancer" do
31
37
  it "should find or create balancer" do
32
38
  lb = Hugo::Balancer.instance
33
39
  lb.name "myserver"
40
+ lb.aws_access_key_id "12"
41
+ lb.aws_secret_access_key "12"
34
42
  lb.deploy.should be_a_kind_of(Hugo::Aws::Elb)
35
43
 
36
44
  end
@@ -52,6 +52,8 @@ describe "Hugo Database" do
52
52
  lambda do
53
53
  Hugo do
54
54
  cloud "my_cloud" do
55
+ aws_access_key_id "12"
56
+ aws_secret_access_key "34"
55
57
  database "testapp" do
56
58
  server "serverx"
57
59
  user "test_user"
@@ -54,6 +54,9 @@ describe "Hugo DSL" do
54
54
  block = lambda do
55
55
 
56
56
  cloud "gmms" do
57
+ aws_access_key_id "12345"
58
+ aws_secret_access_key "123456"
59
+
57
60
  balancer
58
61
 
59
62
  database "sentinel" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hugo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Wilson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-03-05 00:00:00 -05:00
13
+ date: 2010-03-07 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -73,7 +73,7 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: 2.0.16
75
75
  version:
76
- description: Deploy your apps to the cloud.
76
+ description: Deploy your apps to the EC2 cloud.
77
77
  email: tom@jackhq.com
78
78
  executables: []
79
79
 
@@ -121,7 +121,7 @@ rubyforge_project:
121
121
  rubygems_version: 1.3.5
122
122
  signing_key:
123
123
  specification_version: 3
124
- summary: Deploy Your Rack Apps to Cloud
124
+ summary: Deploy Your Rack Apps to EC2 Cloud
125
125
  test_files:
126
126
  - spec/lib/hugo/app_spec.rb
127
127
  - spec/lib/hugo/aws/ec2_spec.rb