Skip to content

Commit 2df17a2

Browse files
committed
Adding proxy support that was present in Fog back, fixes regression #126
1 parent af92e78 commit 2df17a2

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@ The price you bid in order to submit a spot request. An additional step will be
199199

200200
The default is `nil`.
201201

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+
202210
## Disk Configuration
203211

204212
### ebs\_volume\_size

lib/kitchen/driver/aws/client.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ class Aws
3232
# @author Tyler Ball <[email protected]>
3333
class Client
3434

35-
def initialize(
35+
def initialize( # rubocop:disable Metrics/ParameterLists
3636
region,
3737
profile_name = nil,
3838
access_key_id = nil,
3939
secret_access_key = nil,
40-
session_token = nil
40+
session_token = nil,
41+
http_proxy = nil
4142
)
4243
creds = self.class.get_credentials(
4344
profile_name, access_key_id, secret_access_key, session_token
4445
)
4546
::Aws.config.update(
4647
:region => region,
47-
:credentials => creds
48+
:credentials => creds,
49+
:http_proxy => http_proxy
4850
)
4951
end
5052

lib/kitchen/driver/ec2.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Ec2 < Kitchen::Driver::Base # rubocop:disable Metrics/ClassLength
6262
default_config :username, nil
6363
default_config :associate_public_ip, nil
6464
default_config :interface, nil
65+
default_config :http_proxy, ENV["HTTP_PROXY"]
6566

6667
required_config :aws_ssh_key_id
6768
required_config :image_id
@@ -250,7 +251,8 @@ def ec2
250251
config[:shared_credentials_profile],
251252
config[:aws_access_key_id],
252253
config[:aws_secret_access_key],
253-
config[:aws_session_token]
254+
config[:aws_session_token],
255+
config[:http_proxy]
254256
)
255257
end
256258

spec/kitchen/driver/ec2/client_spec.rb

+21
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,27 @@
106106
client
107107
expect(Aws.config[:region]).to eq("us-west-1")
108108
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
109130
end
110131

111132
it "returns a client" do

0 commit comments

Comments
 (0)