Skip to content

Commit

Permalink
Fixing a regression where I was calling the wrong Aws API
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-ball committed May 19, 2015
1 parent f09c4a5 commit aa3348d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/kitchen/driver/aws/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def initialize(
creds = self.class.get_credentials(
profile_name, access_key_id, secret_access_key, session_token
)
Aws.config = {
::Aws.config.update(
:region => region,
:credentials => creds
}
)
end

# Try and get the credentials from an ordered list of locations
Expand Down Expand Up @@ -94,11 +94,11 @@ def get_instance_from_spot_request(request_id)
end

def client
@client ||= Aws::EC2::Client.new
@client ||= ::Aws::EC2::Client.new
end

def resource
@resource ||= Aws::EC2::Resource.new
@resource ||= ::Aws::EC2::Resource.new
end

end
Expand Down
23 changes: 23 additions & 0 deletions spec/kitchen/driver/ec2/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,27 @@
)
end
end

let(:client) { Kitchen::Driver::Aws::Client.new("us-west-1") }

describe "#initialize" do

it "successfully creates a client" do
expect(client).to be_a(Kitchen::Driver::Aws::Client)
end

it "Sets the AWS config" do
client
expect(Aws.config[:region]).to eq("us-west-1")
end
end

it "returns a client" do
expect(client.client).to be_a(Aws::EC2::Client)
end

it "returns a resource" do
expect(client.resource).to be_a(Aws::EC2::Resource)
end

end

0 comments on commit aa3348d

Please sign in to comment.