Class: Chef::Provisioning::AWSDriver::Driver
- Inherits:
-
Driver
- Object
- Driver
- Chef::Provisioning::AWSDriver::Driver
- Defined in:
- lib/extensions/chef/provisioning/aws_driver/driver.rb
Instance Method Summary collapse
-
#initialize(driver_url, config) ⇒ Driver
constructor
A new instance of Driver.
Constructor Details
#initialize(driver_url, config) ⇒ Driver
Returns a new instance of Driver.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/extensions/chef/provisioning/aws_driver/driver.rb', line 6 def initialize(driver_url, config) super _, profile_name, region = driver_url.split(':') profile_name = nil if profile_name && profile_name.empty? region = nil if region && region.empty? credentials = profile_name ? aws_credentials[profile_name] : aws_credentials.default @aws_config = AWS.config( access_key_id: credentials[:aws_access_key_id], secret_access_key: credentials[:aws_secret_access_key], region: region || credentials[:region], proxy_uri: credentials[:proxy_uri] || nil, session_token: credentials[:aws_session_token] || nil, logger: Chef::Log.logger ) # TODO document how users could add something to the Aws.config themselves if they want to # Right now we are supporting both V1 and V2, so we create 2 config sets credentials2 = ::Aws::Credentials.new( credentials[:aws_access_key_id], credentials[:aws_secret_access_key], ENV["AWS_SESSION_TOKEN"] ) Chef::Config.chef_provisioning ||= {} ::Aws.config.update( credentials: credentials2, region: region || ENV["AWS_DEFAULT_REGION"] || credentials[:region], # TODO when we get rid of V1 replace the credentials class with something that knows how # to read ~/.aws/config :http_proxy => credentials[:proxy_uri] || nil, logger: Chef::Log.logger, retry_limit: Chef::Config.chef_provisioning[:aws_retry_limit] || 5 ) end |