module Aws

Constants

API_DIR

@api private

EmptyStructure
SERVICE_MODULE_NAMES

@api private services

VERSION

Attributes

config[R]

@return [Hash] Returns a hash of default configuration options shared

by all constructed clients.

Public Class Methods

add_service(svc_name, options = {}) click to toggle source

Registers a new service.

Aws.add_service('SvcName',
  api: '/path/to/svc.api.json',
  paginators: '/path/to/svc.paginators.json',
  waiters: '/path/to/svc.waiters.json',
  resources: '/path/to/svc.resources.json')

Aws::SvcName::Client.new
#=> #<Aws::SvcName::Client>

@param [String] svc_name The name of the service. This will also be

the namespace under {Aws}. This must be a valid constant name.

@option options :api @option options :paginators @option options :waiters @option options :resources @return [Module<Service>] Returns the new service module.

# File lib/aws-sdk-core.rb, line 469
def add_service(svc_name, options = {})
  svc_module = Module.new { extend Service }
  const_set(svc_name, svc_module)
  @services[svc_name] = [svc_module, options]
  @service_added_callbacks.each do |callback|
    callback.call(svc_name.to_s, *@services[svc_name])
  end
  svc_module
end
config=(config) click to toggle source

@param [Hash] config

# File lib/aws-sdk-core.rb, line 320
def config=(config)
  if Hash === config
    @config = config
  else
    raise ArgumentError, 'configuration object must be a hash'
  end
end
eager_autoload!(options = {}) click to toggle source

Loads modules that are normally loaded with Ruby's `autoload`. This can avoid thread-safety issues that some Ruby versions have with `autoload`.

# loads ALL services
Aws.eager_autoload!

Loading all services can be slow. You can specify what services you want to load with the `:services` option. All services not named will continue to autoload as normal.

Aws.eager_autoload!(services: %w(S3 EC2))

@return [void]

# File lib/aws-sdk-core.rb, line 416
def eager_autoload!(options = {})
  eager_loader = EagerLoader.new
  eager_loader.load(JMESPath)
  eager_loader.load(Seahorse)
  sub_modules(options).each do |module_or_class|
    eager_loader.load(module_or_class)
  end
  eager_loader
end
partition(partition_name) click to toggle source

Return the partition with the given name. A partition describes the services and regions available in that partition.

aws = Aws.partition('aws')

puts "Regions available in the aws partition:\n"
aws.regions.each do |region|
  puts region.name
end

puts "Services available in the aws partition:\n"
aws.services.each do |services|
  puts services.name
end

See {Partitions} for more information and examples.

@param [String] partition_name The name of the partition to return.

Valid names include "aws", "aws-cn", and "aws-us-gov".

@return [Partitions::Partition]

@raise [ArgumentError] Raises an `ArgumentError` if a partition is

not found with the given name. The error message contains a list
of valid partition names.
# File lib/aws-sdk-core.rb, line 353
def partition(partition_name)
  Partitions.default_list.partition(partition_name)
end
partitions() click to toggle source

Return an array of partitions. A partition describes the services and regions available in that partition.

Aws.partitions.each do |partition|

  puts "Regions available in #{partition.name}:\n"
  partition.regions.each do |region|
    puts region.name
  end

  puts "Services available in #{partition.name}:\n"
  partition.services.each do |service|
    puts service.name
  end
end

See {Partitions} for more information and examples.

@return [Array<Partitions::Partition>] Returns an array of all

known partitions.
# File lib/aws-sdk-core.rb, line 377
def partitions
  Partitions.default_list.partitions
end
service_added() { |svc_name, svc_module, options| ... } click to toggle source

Yields to the given block for each service that has already been defined via {add_service}. Also yields to the given block for each new service added after the callback is registered. @api private

# File lib/aws-sdk-core.rb, line 443
def service_added(&block)
  callback = Proc.new
  @services.each do |svc_name, (svc_module, options)|
    yield(svc_name, svc_module, options)
  end
  @service_added_callbacks << callback
end
shared_config() click to toggle source

@api private

# File lib/aws-sdk-core.rb, line 310
def shared_config
  enabled = ENV["AWS_SDK_CONFIG_OPT_OUT"] ? false : true
  @shared_config ||= SharedConfig.new(config_enabled: enabled)
end
sub_modules(options = {}) click to toggle source
# File lib/aws-sdk-core.rb, line 426
def sub_modules(options = {})
  constants = Aws.constants.map(&:to_s)
  if options[:services]
    constants -= SERVICE_MODULE_NAMES
    constants += options[:services] || SERVICE_MODULE_NAMES
  end
  constants.inject([]) do |modules, const_name|
    constant = Aws.const_get(const_name)
    modules << constant if Module === constant
    modules
  end
end
use_bundled_cert!() click to toggle source

The SDK ships with a ca certificate bundle to use when verifying SSL peer certificates. By default, this cert bundle is NOT used. The SDK will rely on the default cert available to OpenSSL. This ensures the cert provided by your OS is used.

For cases where the default cert is unavailable, e.g. Windows, you can call this method.

Aws.use_bundled_cert!

@return [String] Returns the path to the bundled cert.

# File lib/aws-sdk-core.rb, line 392
def use_bundled_cert!
  config.delete(:ssl_ca_directory)
  config.delete(:ssl_ca_store)
  config[:ssl_ca_bundle] = File.expand_path(File.join(
    File.dirname(__FILE__),
    '..',
    'ca-bundle.crt'
  ))
end