Module: Fhcap::S3Helper

Includes:
ProvidersHelper
Included in:
Tasks::Chef::Cookbook::ListArtifacts
Defined in:
lib/fhcap/tasks/chef/cookbook/aws/s3_helper.rb

Instance Method Summary collapse

Methods included from ProvidersHelper

#provider_availability_zones, #provider_config, #provider_credentials, #provider_for, #provider_names, #provider_names_for, #provider_regions, #provider_type, #providers_config

Instance Method Details

#with_provider_client(provider_name, provider_region) {|client| ... } ⇒ Object

Yields:

  • (client)


9
10
11
12
13
14
15
16
17
18
# File 'lib/fhcap/tasks/chef/cookbook/aws/s3_helper.rb', line 9

def with_provider_client(provider_name, provider_region)
  cfg = provider_config(provider_name)
  region = provider_region || provider_regions(provider_name).keys.first
  creds = cfg[:credentials]
  client = Aws::S3::Resource.new(
      region: region,
      credentials: Aws::Credentials.new(creds[:'aws-access-key'], creds[:'aws-secret-key'])
  )
  yield client
end