Skip to content

Commit

Permalink
Add require 'aws-sdk' as needed
Browse files Browse the repository at this point in the history
The aws-sdk gem namespace was being called before it was required.
Solves sous-chefs#181
  • Loading branch information
shortdudey123 committed Nov 17, 2015
1 parent ae0ac8c commit dfbe1ea
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libraries/ec2.rb
Original file line number Diff line number Diff line change
@@ -42,6 +42,12 @@ def find_snapshot_id(volume_id = '', find_most_recent = false)
end

def ec2
begin
require 'aws-sdk'
rescue LoadError
Chef::Log.error("Missing gem 'aws-sdk'. Use the default aws recipe to install it first.")
end

@@ec2 ||= create_aws_interface(::Aws::EC2::Client)
end

5 changes: 5 additions & 0 deletions libraries/elb.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@ module Elb
include Opscode::Aws::Ec2

def elb
begin
require 'aws-sdk'
rescue LoadError
Chef::Log.error("Missing gem 'aws-sdk'. Use the default aws recipe to install it first.")
end
@@elb ||= create_aws_interface(::Aws::ElasticLoadBalancing::Client)
end
end
5 changes: 5 additions & 0 deletions libraries/s3.rb
Original file line number Diff line number Diff line change
@@ -6,6 +6,11 @@ module S3
include Opscode::Aws::Ec2

def s3
begin
require 'aws-sdk'
rescue LoadError
Chef::Log.error("Missing gem 'aws-sdk'. Use the default aws recipe to install it first.")
end
@@s3 ||= create_aws_interface(::Aws::S3::Client)
end
end

0 comments on commit dfbe1ea

Please sign in to comment.