kitchen-ec2 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63b191e76f8a9ca14b90f8fbccbdfd1ce3f331b6
4
- data.tar.gz: 852a2dc5b108ecb0cef3f27c65162e9716e938c3
3
+ metadata.gz: 28b62273c1ee5fb17313f193f401ddef8298c801
4
+ data.tar.gz: fd9d69df55c2f0e669e00cf41b050ac41b2f8492
5
5
  SHA512:
6
- metadata.gz: 1e9ac692d5b4d8f9b60633f5eb890bc70efb773fe4980e2478e6743b8dfbba2b7ac713f428f0bc5875da292ea8f6efc62dd4108fce061621d212d12b41be7971
7
- data.tar.gz: 827a0183547e2c3f24202711edf9a14b4f17663e677a13915230896076cb08b1cc065107c1ee42dbe3bf395b6715aaa9cab6928bdd245ac3201db19cac4c10eb
6
+ metadata.gz: 6962df92e7ffd49fb287f84d325950484729e777bc54c90380fd8e699caa273631e8003ca597de9cb274020519f187d65c23e916eaa3f2be9a0c8cb34774d7dd
7
+ data.tar.gz: 47489808c46515f9e0541e7fe060b90bf7f94012398765d49ad20037c9eca1dc2e61b18bed6badf2cbf2434cb0d5a3c036a50e738f90f497dbf175ef3463ffb0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 0.9.2 / 2015-05-26
2
+
3
+ ### Bug Fixes
4
+
5
+ * Pull Request [#131][]: Adding back support for a proxy via config `http_proxy` which defaults to `ENV['HTTP_PROXY']`
6
+ * Pull Request [#128][]:
7
+ * Fixes [#121][]: Fixing error `Network interfaces and an instance-level security groups may not be specified on the same request`
8
+ * Fixes [#127][]: User Data content should be base64 encoded when passed to aws sdk
9
+
10
+ ### New Features
11
+
12
+ ### Improvements
13
+
1
14
  ## 0.9.1 / 2015-05-21
2
15
 
3
16
  ### Bug Fixes
@@ -124,8 +137,12 @@
124
137
  [#107]: https://github.com/test-kitchen/kitchen-ec2/issues/107
125
138
  [#110]: https://github.com/test-kitchen/kitchen-ec2/issues/110
126
139
  [#112]: https://github.com/test-kitchen/kitchen-ec2/issues/112
140
+ [#121]: https://github.com/test-kitchen/kitchen-ec2/issues/121
127
141
  [#124]: https://github.com/test-kitchen/kitchen-ec2/issues/124
128
142
  [#125]: https://github.com/test-kitchen/kitchen-ec2/issues/125
143
+ [#127]: https://github.com/test-kitchen/kitchen-ec2/issues/127
144
+ [#128]: https://github.com/test-kitchen/kitchen-ec2/issues/128
145
+ [#131]: https://github.com/test-kitchen/kitchen-ec2/issues/131
129
146
  [@Atalanta]: https://github.com/Atalanta
130
147
  [@Igorshp]: https://github.com/Igorshp
131
148
  [@JamesAwesome]: https://github.com/JamesAwesome
data/README.md CHANGED
@@ -199,6 +199,14 @@ The price you bid in order to submit a spot request. An additional step will be
199
199
 
200
200
  The default is `nil`.
201
201
 
202
+ ### http\_proxy
203
+
204
+ Specify a proxy to send AWS requests through. Should be of the format `http://<host>:<port>`.
205
+
206
+ The default is `ENV['HTTP_PROXY']`
207
+
208
+ **Note** - The AWS command line utility allow you to specify [two proxies](http://docs.aws.amazon.com/cli/latest/userguide/cli-http-proxy.html), one for HTTP and one for HTTPS. The AWS Ruby SDK only allows you to specify 1 proxy and because all requests are `https://` this proxy needs to support HTTPS.
209
+
202
210
  ## Disk Configuration
203
211
 
204
212
  ### ebs\_volume\_size
@@ -32,19 +32,21 @@ module Kitchen
32
32
  # @author Tyler Ball <tball@chef.io>
33
33
  class Client
34
34
 
35
- def initialize(
35
+ def initialize( # rubocop:disable Metrics/ParameterLists
36
36
  region,
37
37
  profile_name = nil,
38
38
  access_key_id = nil,
39
39
  secret_access_key = nil,
40
- session_token = nil
40
+ session_token = nil,
41
+ http_proxy = nil
41
42
  )
42
43
  creds = self.class.get_credentials(
43
44
  profile_name, access_key_id, secret_access_key, session_token
44
45
  )
45
46
  ::Aws.config.update(
46
47
  :region => region,
47
- :credentials => creds
48
+ :credentials => creds,
49
+ :http_proxy => http_proxy
48
50
  )
49
51
  end
50
52
 
@@ -17,6 +17,7 @@
17
17
  # limitations under the License.
18
18
 
19
19
  require "kitchen/logging"
20
+ require "base64"
20
21
 
21
22
  module Kitchen
22
23
 
@@ -62,13 +63,21 @@ module Kitchen
62
63
  i[:network_interfaces] =
63
64
  [{
64
65
  :device_index => 0,
65
- :associate_public_ip_address => config[:associate_public_ip]
66
+ :associate_public_ip_address => config[:associate_public_ip],
67
+ :delete_on_termination => true
66
68
  }]
67
- # If specifying `:network_interfaces` in the request, you must specify the
68
- # subnet_id in the network_interfaces block and not at the top level
69
+ # If specifying `:network_interfaces` in the request, you must specify
70
+ # network specific configs in the network_interfaces block and not at
71
+ # the top level
69
72
  if config[:subnet_id]
70
73
  i[:network_interfaces][0][:subnet_id] = i.delete(:subnet_id)
71
74
  end
75
+ if config[:private_ip_address]
76
+ i[:network_interfaces][0][:private_ip_address] = i.delete(:private_ip_address)
77
+ end
78
+ if config[:security_group_ids]
79
+ i[:network_interfaces][0][:groups] = i.delete(:security_group_ids)
80
+ end
72
81
  end
73
82
  i
74
83
  end
@@ -134,14 +143,15 @@ module Kitchen
134
143
 
135
144
  def prepared_user_data
136
145
  # If user_data is a file reference, lets read it as such
137
- unless @user_data
138
- if config[:user_data] && File.file?(config[:user_data])
146
+ return nil if config[:user_data].nil?
147
+ @user_data ||= begin
148
+ if File.file?(config[:user_data])
139
149
  @user_data = File.read(config[:user_data])
140
150
  else
141
151
  @user_data = config[:user_data]
142
152
  end
153
+ @user_data = Base64.encode64(@user_data)
143
154
  end
144
- @user_data
145
155
  end
146
156
 
147
157
  end
@@ -62,6 +62,7 @@ module Kitchen
62
62
  default_config :username, nil
63
63
  default_config :associate_public_ip, nil
64
64
  default_config :interface, nil
65
+ default_config :http_proxy, ENV["HTTPS_PROXY"] || ENV["HTTP_PROXY"]
65
66
 
66
67
  required_config :aws_ssh_key_id
67
68
  required_config :image_id
@@ -250,7 +251,8 @@ module Kitchen
250
251
  config[:shared_credentials_profile],
251
252
  config[:aws_access_key_id],
252
253
  config[:aws_secret_access_key],
253
- config[:aws_session_token]
254
+ config[:aws_session_token],
255
+ config[:http_proxy]
254
256
  )
255
257
  end
256
258
 
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for EC2 Test Kitchen driver
24
- EC2_VERSION = "0.9.1"
24
+ EC2_VERSION = "0.9.2"
25
25
  end
26
26
  end
@@ -106,6 +106,27 @@ describe Kitchen::Driver::Aws::Client do
106
106
  client
107
107
  expect(Aws.config[:region]).to eq("us-west-1")
108
108
  end
109
+
110
+ context "when provided all optional parameters" do
111
+ let(:client) {
112
+ Kitchen::Driver::Aws::Client.new(
113
+ "us-west-1",
114
+ "profile_name",
115
+ "access_key_id",
116
+ "secret_access_key",
117
+ "session_token",
118
+ "http_proxy"
119
+ )
120
+ }
121
+ let(:creds) { double("creds") }
122
+ it "Sets the AWS config" do
123
+ expect(Kitchen::Driver::Aws::Client).to receive(:get_credentials).and_return(creds)
124
+ client
125
+ expect(Aws.config[:region]).to eq("us-west-1")
126
+ expect(Aws.config[:credentials]).to eq(creds)
127
+ expect(Aws.config[:http_proxy]).to eq("http_proxy")
128
+ end
129
+ end
109
130
  end
110
131
 
111
132
  it "returns a client" do
@@ -19,6 +19,7 @@
19
19
  require "kitchen/driver/aws/instance_generator"
20
20
  require "kitchen/driver/aws/client"
21
21
  require "tempfile"
22
+ require "base64"
22
23
 
23
24
  describe Kitchen::Driver::Aws::InstanceGenerator do
24
25
 
@@ -70,14 +71,15 @@ describe Kitchen::Driver::Aws::InstanceGenerator do
70
71
  end
71
72
 
72
73
  it "reads the file contents" do
73
- expect(generator.prepared_user_data).to eq("foo\nbar")
74
+ expect(Base64.decode64(generator.prepared_user_data)).to eq("foo\nbar")
74
75
  end
75
76
 
76
77
  it "memoizes the file contents" do
77
- expect(generator.prepared_user_data).to eq("foo\nbar")
78
+ decoded = Base64.decode64(generator.prepared_user_data)
79
+ expect(decoded).to eq("foo\nbar")
78
80
  tmp_file.write("other\nvalue")
79
81
  tmp_file.rewind
80
- expect(generator.prepared_user_data).to eq("foo\nbar")
82
+ expect(decoded).to eq("foo\nbar")
81
83
  end
82
84
  end
83
85
  end
@@ -280,9 +282,92 @@ describe Kitchen::Driver::Aws::InstanceGenerator do
280
282
  :key_name => nil,
281
283
  :subnet_id => nil,
282
284
  :private_ip_address => nil,
283
- :network_interfaces => [{ :device_index => 0, :associate_public_ip_address => true }]
285
+ :network_interfaces => [{
286
+ :device_index => 0,
287
+ :associate_public_ip_address => true,
288
+ :delete_on_termination => true
289
+ }]
284
290
  )
285
291
  end
292
+
293
+ context "and subnet is provided" do
294
+ let(:config) do
295
+ {
296
+ :associate_public_ip => true,
297
+ :subnet_id => "s-456"
298
+ }
299
+ end
300
+
301
+ it "adds a network_interfaces block" do
302
+ expect(generator.ec2_instance_data).to eq(
303
+ :placement => { :availability_zone => nil },
304
+ :instance_type => nil,
305
+ :ebs_optimized => nil,
306
+ :image_id => nil,
307
+ :key_name => nil,
308
+ :private_ip_address => nil,
309
+ :network_interfaces => [{
310
+ :device_index => 0,
311
+ :associate_public_ip_address => true,
312
+ :delete_on_termination => true,
313
+ :subnet_id => "s-456"
314
+ }]
315
+ )
316
+ end
317
+ end
318
+
319
+ context "and security_group_ids is provided" do
320
+ let(:config) do
321
+ {
322
+ :associate_public_ip => true,
323
+ :security_group_ids => ["sg-789"]
324
+ }
325
+ end
326
+
327
+ it "adds a network_interfaces block" do
328
+ expect(generator.ec2_instance_data).to eq(
329
+ :placement => { :availability_zone => nil },
330
+ :instance_type => nil,
331
+ :ebs_optimized => nil,
332
+ :image_id => nil,
333
+ :key_name => nil,
334
+ :subnet_id => nil,
335
+ :private_ip_address => nil,
336
+ :network_interfaces => [{
337
+ :device_index => 0,
338
+ :associate_public_ip_address => true,
339
+ :delete_on_termination => true,
340
+ :groups => ["sg-789"]
341
+ }]
342
+ )
343
+ end
344
+ end
345
+
346
+ context "and private_ip_address is provided" do
347
+ let(:config) do
348
+ {
349
+ :associate_public_ip => true,
350
+ :private_ip_address => "0.0.0.0"
351
+ }
352
+ end
353
+
354
+ it "adds a network_interfaces block" do
355
+ expect(generator.ec2_instance_data).to eq(
356
+ :placement => { :availability_zone => nil },
357
+ :instance_type => nil,
358
+ :ebs_optimized => nil,
359
+ :image_id => nil,
360
+ :key_name => nil,
361
+ :subnet_id => nil,
362
+ :network_interfaces => [{
363
+ :device_index => 0,
364
+ :associate_public_ip_address => true,
365
+ :delete_on_termination => true,
366
+ :private_ip_address => "0.0.0.0"
367
+ }]
368
+ )
369
+ end
370
+ end
286
371
  end
287
372
 
288
373
  context "when provided the maximum config" do
@@ -319,7 +404,6 @@ describe Kitchen::Driver::Aws::InstanceGenerator do
319
404
  :ebs_optimized => true,
320
405
  :image_id => "ami-123",
321
406
  :key_name => "key",
322
- :private_ip_address => "0.0.0.0",
323
407
  :block_device_mappings => [
324
408
  {
325
409
  :ebs => {
@@ -336,10 +420,12 @@ describe Kitchen::Driver::Aws::InstanceGenerator do
336
420
  :network_interfaces => [{
337
421
  :device_index => 0,
338
422
  :associate_public_ip_address => true,
339
- :subnet_id => "s-456"
423
+ :subnet_id => "s-456",
424
+ :delete_on_termination => true,
425
+ :groups => ["sg-789"],
426
+ :private_ip_address => "0.0.0.0"
340
427
  }],
341
- :security_group_ids => ["sg-789"],
342
- :user_data => "foo"
428
+ :user_data => Base64.encode64("foo")
343
429
  )
344
430
  end
345
431
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fletcher Nichol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  version: '0'
241
241
  requirements: []
242
242
  rubyforge_project:
243
- rubygems_version: 2.4.2
243
+ rubygems_version: 2.4.7
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: A Test Kitchen Driver for Amazon EC2