Module: AWS

Defined in:
lib/aws/core.rb,
lib/aws.rb,
lib/aws/s3.rb,
lib/aws/ec2.rb,
lib/aws/elb.rb,
lib/aws/iam.rb,
lib/aws/sns.rb,
lib/aws/sqs.rb,
lib/aws/sts.rb,
lib/aws/rails.rb,
lib/aws/errors.rb,
lib/aws/record.rb,
lib/aws/ec2/tag.rb,
lib/aws/ec2/vpc.rb,
lib/aws/s3/tree.rb,
lib/aws/iam/user.rb,
lib/aws/core/data.rb,
lib/aws/dynamo_db.rb,
lib/aws/ec2/image.rb,
lib/aws/iam/group.rb,
lib/aws/s3/bucket.rb,
lib/aws/s3/client.rb,
lib/aws/s3/errors.rb,
lib/aws/s3/policy.rb,
lib/aws/simple_db.rb,
lib/aws/sns/topic.rb,
lib/aws/sqs/queue.rb,
lib/aws/core/model.rb,
lib/aws/ec2/client.rb,
lib/aws/ec2/errors.rb,
lib/aws/ec2/region.rb,
lib/aws/ec2/subnet.rb,
lib/aws/ec2/volume.rb,
lib/aws/elb/client.rb,
lib/aws/elb/errors.rb,
lib/aws/iam/client.rb,
lib/aws/iam/errors.rb,
lib/aws/iam/policy.rb,
lib/aws/s3/request.rb,
lib/aws/sns/client.rb,
lib/aws/sns/errors.rb,
lib/aws/sns/policy.rb,
lib/aws/sqs/client.rb,
lib/aws/sqs/errors.rb,
lib/aws/sqs/policy.rb,
lib/aws/sts/client.rb,
lib/aws/sts/errors.rb,
lib/aws/sts/policy.rb,
lib/aws/core/client.rb,
lib/aws/core/naming.rb,
lib/aws/core/policy.rb,
lib/aws/ec2/request.rb,
lib/aws/elb/request.rb,
lib/aws/iam/request.rb,
lib/aws/sns/request.rb,
lib/aws/sqs/request.rb,
lib/aws/sts/request.rb,
lib/aws/sts/session.rb,
lib/aws/auto_scaling.rb,
lib/aws/ec2/instance.rb,
lib/aws/ec2/key_pair.rb,
lib/aws/ec2/resource.rb,
lib/aws/ec2/snapshot.rb,
lib/aws/elb/listener.rb,
lib/aws/iam/resource.rb,
lib/aws/record/model.rb,
lib/aws/record/scope.rb,
lib/aws/s3/s3_object.rb,
lib/aws/s3/tree/node.rb,
lib/aws/core/resource.rb,
lib/aws/core/response.rb,
lib/aws/core/xml/stub.rb,
lib/aws/record/errors.rb,
lib/aws/record/naming.rb,
lib/aws/s3/acl_object.rb,
lib/aws/s3/client/xml.rb,
lib/aws/core/cacheable.rb,
lib/aws/core/xml/frame.rb,
lib/aws/dynamo_db/item.rb,
lib/aws/dynamo_db/keys.rb,
lib/aws/ec2/attachment.rb,
lib/aws/ec2/collection.rb,
lib/aws/ec2/elastic_ip.rb,
lib/aws/iam/access_key.rb,
lib/aws/iam/collection.rb,
lib/aws/iam/mfa_device.rb,
lib/aws/s3/tree/parent.rb,
lib/aws/simple_db/item.rb,
lib/aws/cloud_formation.rb,
lib/aws/core/autoloader.rb,
lib/aws/core/collection.rb,
lib/aws/core/inflection.rb,
lib/aws/core/meta_utils.rb,
lib/aws/core/uri_escape.rb,
lib/aws/core/xml/parser.rb,
lib/aws/dynamo_db/table.rb,
lib/aws/dynamo_db/types.rb,
lib/aws/ec2/network_acl.rb,
lib/aws/ec2/route_table.rb,
lib/aws/ec2/tagged_item.rb,
lib/aws/ec2/vpn_gateway.rb,
lib/aws/iam/user_policy.rb,
lib/aws/s3/data_options.rb,
lib/aws/simple_workflow.rb,
lib/aws/auto_scaling/tag.rb,
lib/aws/core/page_result.rb,
lib/aws/core/xml/grammar.rb,
lib/aws/dynamo_db/client.rb,
lib/aws/dynamo_db/errors.rb,
lib/aws/ec2/dhcp_options.rb,
lib/aws/record/validator.rb,
lib/aws/s3/uploaded_part.rb,
lib/aws/simple_db/client.rb,
lib/aws/simple_db/domain.rb,
lib/aws/simple_db/errors.rb,
lib/aws/sns/subscription.rb,
lib/aws/core/async_handle.rb,
lib/aws/core/http/handler.rb,
lib/aws/core/http/request.rb,
lib/aws/dynamo_db/request.rb,
lib/aws/elb/listener_opts.rb,
lib/aws/elb/load_balancer.rb,
lib/aws/iam/login_profile.rb,
lib/aws/record/attributes.rb,
lib/aws/record/conversion.rb,
lib/aws/record/exceptions.rb,
lib/aws/record/hash_model.rb,
lib/aws/s3/object_version.rb,
lib/aws/s3/presigned_post.rb,
lib/aws/s3/tree/leaf_node.rb,
lib/aws/simple_db/request.rb,
lib/aws/auto_scaling/group.rb,
lib/aws/core/configuration.rb,
lib/aws/core/http/response.rb,
lib/aws/core/log_formatter.rb,
lib/aws/dynamo_db/resource.rb,
lib/aws/ec2/security_group.rb,
lib/aws/ec2/tag_collection.rb,
lib/aws/ec2/vpc_collection.rb,
lib/aws/ec2/vpn_connection.rb,
lib/aws/record/model/scope.rb,
lib/aws/record/validations.rb,
lib/aws/s3/object_metadata.rb,
lib/aws/auto_scaling/client.rb,
lib/aws/auto_scaling/errors.rb,
lib/aws/core/default_signer.rb,
lib/aws/core/option_grammar.rb,
lib/aws/core/resource_cache.rb,
lib/aws/core/response_cache.rb,
lib/aws/core/session_signer.rb,
lib/aws/core/xml/root_frame.rb,
lib/aws/dynamo_db/batch_get.rb,
lib/aws/dynamo_db/item_data.rb,
lib/aws/ec2/has_permissions.rb,
lib/aws/iam/user_collection.rb,
lib/aws/s3/multipart_upload.rb,
lib/aws/s3/tree/branch_node.rb,
lib/aws/simple_db/attribute.rb,
lib/aws/simple_db/item_data.rb,
lib/aws/auto_scaling/request.rb,
lib/aws/core/xml/frame_stack.rb,
lib/aws/ec2/config_transform.rb,
lib/aws/ec2/customer_gateway.rb,
lib/aws/ec2/image_collection.rb,
lib/aws/ec2/internet_gateway.rb,
lib/aws/iam/group_collection.rb,
lib/aws/record/abstract_base.rb,
lib/aws/s3/bucket_collection.rb,
lib/aws/s3/object_collection.rb,
lib/aws/simple_email_service.rb,
lib/aws/simple_workflow/type.rb,
lib/aws/sns/topic_collection.rb,
lib/aws/sqs/queue_collection.rb,
lib/aws/sqs/received_message.rb,
lib/aws/auto_scaling/activity.rb,
lib/aws/auto_scaling/instance.rb,
lib/aws/cloud_formation/stack.rb,
lib/aws/core/client/query_xml.rb,
lib/aws/core/indifferent_hash.rb,
lib/aws/dynamo_db/batch_write.rb,
lib/aws/ec2/availability_zone.rb,
lib/aws/ec2/network_acl/entry.rb,
lib/aws/ec2/network_interface.rb,
lib/aws/ec2/region_collection.rb,
lib/aws/ec2/route_table/route.rb,
lib/aws/ec2/subnet_collection.rb,
lib/aws/ec2/tagged_collection.rb,
lib/aws/ec2/volume_collection.rb,
lib/aws/iam/policy_collection.rb,
lib/aws/record/dirty_tracking.rb,
lib/aws/simple_workflow/count.rb,
lib/aws/sts/federated_session.rb,
lib/aws/cloud_formation/client.rb,
lib/aws/cloud_formation/errors.rb,
lib/aws/core/client/query_json.rb,
lib/aws/core/collection/simple.rb,
lib/aws/core/http/curb_handler.rb,
lib/aws/core/service_interface.rb,
lib/aws/dynamo_db/expectations.rb,
lib/aws/ec2/reserved_instances.rb,
lib/aws/iam/server_certificate.rb,
lib/aws/iam/virtual_mfa_device.rb,
lib/aws/s3/access_control_list.rb,
lib/aws/s3/prefixed_collection.rb,
lib/aws/simple_workflow/client.rb,
lib/aws/simple_workflow/domain.rb,
lib/aws/simple_workflow/errors.rb,
lib/aws/cloud_formation/request.rb,
lib/aws/core/lazy_error_classes.rb,
lib/aws/ec2/filtered_collection.rb,
lib/aws/ec2/instance_collection.rb,
lib/aws/ec2/key_pair_collection.rb,
lib/aws/ec2/snapshot_collection.rb,
lib/aws/elb/instance_collection.rb,
lib/aws/elb/listener_collection.rb,
lib/aws/iam/signing_certificate.rb,
lib/aws/record/hash_model/scope.rb,
lib/aws/record/model/attributes.rb,
lib/aws/record/validators/block.rb,
lib/aws/record/validators/count.rb,
lib/aws/s3/paginated_collection.rb,
lib/aws/simple_workflow/request.rb,
lib/aws/sns/has_delivery_policy.rb,
lib/aws/core/signature/version_2.rb,
lib/aws/core/signature/version_3.rb,
lib/aws/core/signature/version_4.rb,
lib/aws/core/xml/sax_handlers/ox.rb,
lib/aws/elb/load_balancer_policy.rb,
lib/aws/record/validators/format.rb,
lib/aws/record/validators/length.rb,
lib/aws/record/validators/method.rb,
lib/aws/s3/tree/child_collection.rb,
lib/aws/simple_db/put_attributes.rb,
lib/aws/simple_workflow/resource.rb,
lib/aws/sqs/received_sns_message.rb,
lib/aws/core/collection/limitable.rb,
lib/aws/dynamo_db/item_collection.rb,
lib/aws/ec2/attachment_collection.rb,
lib/aws/ec2/block_device_mappings.rb,
lib/aws/ec2/elastic_ip_collection.rb,
lib/aws/ec2/permission_collection.rb,
lib/aws/iam/access_key_collection.rb,
lib/aws/iam/group_user_collection.rb,
lib/aws/iam/mfa_device_collection.rb,
lib/aws/iam/user_group_collection.rb,
lib/aws/simple_db/domain_metadata.rb,
lib/aws/simple_db/item_collection.rb,
lib/aws/auto_scaling/group_options.rb,
lib/aws/core/http/httparty_handler.rb,
lib/aws/core/http/net_http_handler.rb,
lib/aws/dynamo_db/table_collection.rb,
lib/aws/ec2/network_acl_collection.rb,
lib/aws/ec2/route_table_collection.rb,
lib/aws/ec2/vpn_gateway/attachment.rb,
lib/aws/ec2/vpn_gateway_collection.rb,
lib/aws/iam/user_policy_collection.rb,
lib/aws/record/validators/presence.rb,
lib/aws/auto_scaling/scaling_policy.rb,
lib/aws/auto_scaling/tag_collection.rb,
lib/aws/cloud_formation/stack_event.rb,
lib/aws/core/xml/sax_handlers/rexml.rb,
lib/aws/ec2/dhcp_options_collection.rb,
lib/aws/ec2/network_acl/association.rb,
lib/aws/ec2/resource_tag_collection.rb,
lib/aws/ec2/route_table/association.rb,
lib/aws/iam/group_policy_collection.rb,
lib/aws/record/model/finder_methods.rb,
lib/aws/record/validators/exclusion.rb,
lib/aws/record/validators/inclusion.rb,
lib/aws/s3/object_upload_collection.rb,
lib/aws/s3/uploaded_part_collection.rb,
lib/aws/simple_db/delete_attributes.rb,
lib/aws/simple_db/domain_collection.rb,
lib/aws/simple_email_service/client.rb,
lib/aws/simple_email_service/errors.rb,
lib/aws/simple_email_service/quotas.rb,
lib/aws/sns/subscription_collection.rb,
lib/aws/cloud_formation/stack_output.rb,
lib/aws/core/xml/sax_handlers/libxml.rb,
lib/aws/ec2/vpn_connection/telemetry.rb,
lib/aws/elb/load_balancer_collection.rb,
lib/aws/iam/account_alias_collection.rb,
lib/aws/record/hash_model/attributes.rb,
lib/aws/record/validators/acceptance.rb,
lib/aws/s3/bucket_version_collection.rb,
lib/aws/s3/object_version_collection.rb,
lib/aws/simple_email_service/request.rb,
lib/aws/auto_scaling/group_collection.rb,
lib/aws/auto_scaling/scheduled_action.rb,
lib/aws/cloud_formation/stack_options.rb,
lib/aws/cloud_formation/stack_summary.rb,
lib/aws/core/signature/version_3_http.rb,
lib/aws/dynamo_db/primary_key_element.rb,
lib/aws/ec2/security_group_collection.rb,
lib/aws/ec2/vpn_connection_collection.rb,
lib/aws/simple_email_service/identity.rb,
lib/aws/simple_workflow/activity_task.rb,
lib/aws/simple_workflow/activity_type.rb,
lib/aws/simple_workflow/decision_task.rb,
lib/aws/simple_workflow/history_event.rb,
lib/aws/simple_workflow/workflow_type.rb,
lib/aws/cloud_formation/stack_resource.rb,
lib/aws/core/xml/sax_handlers/nokogiri.rb,
lib/aws/dynamo_db/attribute_collection.rb,
lib/aws/record/validators/confirmation.rb,
lib/aws/record/validators/numericality.rb,
lib/aws/s3/multipart_upload_collection.rb,
lib/aws/simple_db/attribute_collection.rb,
lib/aws/ec2/customer_gateway_collection.rb,
lib/aws/ec2/internet_gateway/attachment.rb,
lib/aws/ec2/internet_gateway_collection.rb,
lib/aws/ec2/reserved_instances_offering.rb,
lib/aws/simple_workflow/type_collection.rb,
lib/aws/auto_scaling/activity_collection.rb,
lib/aws/auto_scaling/instance_collection.rb,
lib/aws/cloud_formation/stack_collection.rb,
lib/aws/ec2/availability_zone_collection.rb,
lib/aws/ec2/network_interface/attachment.rb,
lib/aws/ec2/network_interface_collection.rb,
lib/aws/ec2/security_group/ip_permission.rb,
lib/aws/elb/availability_zone_collection.rb,
lib/aws/record/hash_model/finder_methods.rb,
lib/aws/simple_db/consistent_read_option.rb,
lib/aws/auto_scaling/launch_configuration.rb,
lib/aws/ec2/reserved_instances_collection.rb,
lib/aws/iam/server_certificate_collection.rb,
lib/aws/iam/virtual_mfa_device_collection.rb,
lib/aws/s3/bucket_lifecycle_configuration.rb,
lib/aws/simple_db/expect_condition_option.rb,
lib/aws/simple_workflow/domain_collection.rb,
lib/aws/simple_workflow/option_formatters.rb,
lib/aws/sns/topic_subscription_collection.rb,
lib/aws/iam/signing_certificate_collection.rb,
lib/aws/s3/prefix_and_delimiter_collection.rb,
lib/aws/simple_workflow/workflow_execution.rb,
lib/aws/auto_scaling/scaling_policy_options.rb,
lib/aws/elb/load_balancer_policy_collection.rb,
lib/aws/elb/backend_server_policy_collection.rb,
lib/aws/auto_scaling/scaling_policy_collection.rb,
lib/aws/cloud_formation/stack_event_collection.rb,
lib/aws/auto_scaling/notification_configuration.rb,
lib/aws/auto_scaling/scheduled_action_collection.rb,
lib/aws/cloud_formation/stack_summary_collection.rb,
lib/aws/simple_email_service/identity_collection.rb,
lib/aws/simple_workflow/activity_task_collection.rb,
lib/aws/simple_workflow/activity_type_collection.rb,
lib/aws/simple_workflow/decision_task_collection.rb,
lib/aws/simple_workflow/history_event_collection.rb,
lib/aws/simple_workflow/workflow_type_collection.rb,
lib/aws/cloud_formation/stack_resource_collection.rb,
lib/aws/ec2/reserved_instances_offering_collection.rb,
lib/aws/auto_scaling/launch_configuration_collection.rb,
lib/aws/simple_email_service/email_address_collection.rb,
lib/aws/simple_workflow/workflow_execution_collection.rb,
lib/aws/cloud_formation/stack_resource_summary_collection.rb,
lib/aws/auto_scaling/notification_configuration_collection.rb,
lib/aws/ec2/security_group/egress_ip_permission_collection.rb,
lib/aws/ec2/security_group/ingress_ip_permission_collection.rb

Overview

Copyright 2011-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the “License”). You may not use this file except in compliance with the License. A copy of the License is located at

http://aws.amazon.com/apache2.0/

or in the “license” file accompanying this file. This file is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Core, Errors, Http, Rails, Record Classes: AutoScaling, CloudFormation, DynamoDB, EC2, ELB, IAM, Railtie, S3, SNS, SQS, STS, SimpleDB, SimpleEmailService, SimpleWorkflow

Constant Summary collapse

VERSION =

Current version of the AWS SDK for Ruby

"1.5.2"
@@config =
nil
@@eager =
false
@@autoloads =
{}

Class Method Summary collapse

Class Method Details

.autoloadsObject



37
38
39
# File 'lib/aws/core/autoloader.rb', line 37

def self.autoloads
  @@autoloads
end

.config(options = {}) ⇒ Core::Configuration

Note:

Changing the global configuration does not affect objects that have already been constructed.

The global configuration for AWS. Generally you set your prefered configuration operations once after loading the aws-sdk gem.

AWS.config({
  :access_key_id => 'ACCESS_KEY_ID',
  :secret_access_key => 'SECRET_ACCESS_KEY',
  :simple_db_endpoint => 'sdb.us-west-1.amazonaws.com',
  :max_retries => 2,
})

When using AWS classes they will always default to use configuration values defined in config.

AWS.config(:max_retries => 2)

sqs = AWS::SQS.new
sqs.config.max_retries #=> 2

If you want to change a configuration value for a single instance you pass the new configuration value to that object’s initializer:

AWS::SQS.new(:max_retries => 0)

Parameters:

  • options (Hash) (defaults to: {})
  • options[Boolean] (Hash)

    a customizable set of options

Options Hash (options):

  • :access_key_id (String) — default: nil

    AWS access key id credential.

  • :secret_access_key (String) — default: nil

    AWS secret access key credential.

  • :session_token (String, nil) — default: nil

    AWS secret token credential.

  • :auto_scaling_endpoint (String) — default: 'autoscaling.us-east-1.amazonaws.com'

    The service endpoint for Auto Scaling.

  • :cloud_formation_endpoint (String) — default: 'cloudformation.us-east-1.amazonaws.com'

    The service endpoint for AWS CloudFormation.

  • :dynamo_db_endpoint (String) — default: 'dynamodb.amazonaws.com'

    The service endpoint for Amazon DynamoDB.

  • :dynamo_db_retry_throughput_errors (String) — default: true

    When true, AWS::DynamoDB::Errors::ProvisionedThroughputExceededException errors will be retried.

  • :ec2_endpoint (String) — default: 'ec2.amazonaws.com'

    The service endpoint for Amazon EC2.

  • :elb_endpoint (String) — default: 'elasticloadbalancing.us-east-1.amazonaws.com'

    The server endpoint for Elastic Load Balancing.

  • :http_handler (Object) — default: AWS::HTTPartyHandler

    The http handler that sends requests to AWS.

  • :iam_endpoint (String) — default: 'iam.amazonaws.com'

    The service endpoint for AWS Idenity Access Management (IAM).

  • :logger (Logger, nil) — default: nil

    A logger to send log messages to. Here is an example that logs to standard out.

    require 'logger'
    AWS.config(:logger => Logger.new($stdout))
    
  • :log_level (Symbol) — default: :info

    The level log messages are sent to the logger with (e.g. :notice, :info, :warn, :debug, etc).

  • :log_formatter (Object)

    The log formatter is responsible for building log messages from responses. You can quickly change log formats by providing a canned log formatter.

    AWS.config(:log_formatter => AWS::Core::LogFormatter.colored)
    

    Here is the complete list of canned log formatters:

    • AWS::Core::LogFormatter.default

    • AWS::Core::LogFormatter.short

    • AWS::Core::LogFormatter.debug

    • AWS::Core::LogFormatter.colored

    You can also create an instance of AWS::Core::LogFormatter with a custom log message pattern. See AWS::Core::LogFormatter for a complete list of pattern substituions.

    pattern = "[AWS :operation :duration] :error_message"
    AWS.config(:log_formatter => AWS::Core::LogFormatter.new(pattern))
    

    Lastly you can pass any object that responds to #format accepting and instance of AWS::Core::Response and returns a string.

  • :max_retries (Integer) — default: 3

    The maximum number of times service errors (500) should be retried. There is an exponential backoff in between service request retries, so the more retries the longer it can take to fail.

  • :proxy_uri (String, URI, nil) — default: nil

    The URI of the proxy to send service requests through. You can pass a URI object or a URI string:

    AWS.config(:proxy_uri => 'https://user:[email protected]:443/path?query')
    
  • :s3_endpoint (String) — default: 's3.amazonaws.com'

    The service endpoint for Amazon S3.

  • :s3_multipart_max_parts (Integer) — default: 1000

    The maximum number of parts to split a file into when uploading in parts to S3.

  • :s3_multipart_threshold (Integer) — default: 16777216

    When uploading data to S3, if the number of bytes to send exceedes :s3_multipart_threshold then a multi part session is automatically started and the data is sent up in chunks. The size of each part is specified by :s3_multipart_min_part_size. Defaults to 16777216 (16MB).

  • :s3_multipart_min_part_size (Integer) — default: 5242880

    The absolute minimum size (in bytes) each S3 multipart segment should be. Defaults to 5242880 (5MB).

  • :s3_server_side_encryption (Symbol) — default: nil

    The algorithm to use when encrypting object data on the server side. The only valid value is :aes256, which specifies that the object should be stored using the AES encryption algorithm with 256 bit keys. Defaults to nil, meaning server side encryption is not used unless specified on each individual call to upload an object. This option controls the default behavior for the following methods:

  • :simple_db_endpoint (String) — default: 'sdb.amazonaws.com'

    The service endpoint for Amazon SimpleDB.

  • :simple_db_consistent_reads (Boolean) — default: false

    Determines if all SimpleDB read requests should be done consistently. Consistent reads are slower, but reflect all changes to SDB.

  • :simple_email_service_endpoint (String) — default: 'email.us-east-1.amazonaws.com'

    The service endpoint for Amazon Simple Email Service.

  • :simple_workflow_service (String) — default: 'swf.us-east-1.amazonaws.com'

    The service endpoint for Amazon Simple Workflow Service.

  • :signer (Object) — default: AWS::DefaultSigner

    The request signer. Defaults to a default request signer implementation.

  • :ssl_ca_file (String)

    The path to a CA cert bundle in PEM format.

    If :ssl_verify_peer is true (the default) this bundle will be used to validate the server certificate in each HTTPS request. The AWS SDK for Ruby ships with a CA cert bundle, which is the default value for this option.

  • :ssl_ca_path (String) — default: nil

    The path the a CA cert directory.

  • :ssl_verify_peer (Boolean) — default: true

    When true the HTTP handler validate server certificates for HTTPS requests.

    This option should only be disabled for diagnostic purposes; leaving this option set to false exposes your application to man-in-the-middle attacks and can pose a serious security risk.

  • :sns_endpoint (String) — default: 'sns.us-east-1.amazonaws.com'

    The service endpoint for Amazon SNS.

  • :sqs_endpoint (String) — default: 'sqs.us-east-1.amazonaws.com'

    The service endpoint for Amazon SQS.

  • :sts_endpoint (String) — default: 'sts.amazonaws.com'

    The service endpoint for AWS Security Token Service.

  • :use_ssl (Boolean) — default: true

    When true, all requests to AWS are sent using HTTPS instead vanilla HTTP.

  • :user_agent_prefix (String) — default: nil

    A string prefix to append to all requets against AWS services. This should be set for clients and applications built ontop of the aws-sdk gem.

Returns:



345
346
347
348
349
# File 'lib/aws/core.rb', line 345

def config options = {}
  @@config ||= Core::Configuration.new
  @@config = @@config.with(options) unless options.empty?
  @@config
end

.eager_autoload!Object



30
31
32
33
34
35
# File 'lib/aws/core/autoloader.rb', line 30

def self.eager_autoload!
  unless @@eager
    @@eager = true
    @@autoloads.values.uniq.each {|file_path| require(file_path) }
  end
end

.memoizeObject

Note:

Memoization is currently only supported for the EC2 APIs; other APIs are unaffected by the status of memoization. To protect your code from future changes in memoization support, you should not enable memoization while calling non-EC2 APIs.

Enables memoization for the current thread, within a block. Memoization lets you avoid making multiple requests for the same data by reusing the responses which have already been received. For example, consider the following code to get the most recently launched EC2 instance:

latest = ec2.instances.sort_by(&:launch_time).last

The above code would make N+1 requests (where N is the number of instances in the account); iterating the collection of instances is one request, and Enumerable#sort_by calls AWS::EC2::Instance#launch_time for each instance, causing another request per instance. We can rewrite the code as follows to make only one request:

latest = AWS.memoize do
  ec2.instances.sort_by(&:launch_time).last
end

Iterating the collection still causes a request, but each subsequent call to AWS::EC2::Instance#launch_time uses the results from that first request rather than making a new request for the same data.

While memoization is enabled, every response that is received from the service is retained in memory. Therefore you should use memoization only for short-lived blocks of code that make relatively small numbers of requests. The cached responses are used in two ways while memoization is enabled:

  1. Before making a request, the SDK checks the cache for a response to a request with the same signature (credentials, service endpoint, operation name, and parameters). If such a response is found, it is used instead of making a new request.

  2. Before retrieving data for an attribute of a resource (e.g. AWS::EC2::Instance#launch_time), the SDK attempts to find a cached response that contains the requested data. If such a response is found, the cached data is returned instead of making a new request.

When memoization is disabled, all previously cached responses are discarded.



437
438
439
440
441
442
443
444
445
446
# File 'lib/aws/core.rb', line 437

def memoize
  return yield if memoizing?

  begin
    start_memoizing
    yield if block_given?
  ensure
    stop_memoizing
  end
end

.memoizing?Boolean

Note:

Memoization is currently only supported for the EC2 APIs; other APIs are unaffected by the status of memoization. To protect your code from future changes in memoization support, you should not enable memoization while calling non-EC2 APIs.

Returns True if memoization is enabled for the current thread. See memoize for a full discussion of the memoization feature.

Returns:

  • (Boolean)

    True if memoization is enabled for the current thread. See memoize for a full discussion of the memoization feature.



384
385
386
# File 'lib/aws/core.rb', line 384

def memoizing?
  !Thread.current[:aws_memoization].nil?
end

.register_autoloads(klass, prefix = nil, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/aws/core/autoloader.rb', line 21

def self.register_autoloads klass, prefix = nil, &block
  autoloader = Core::Autoloader.new(klass, prefix)
  autoloader.instance_eval(&block)
  autoloader.autoloads.each_pair do |const_name, file_path|
    require(file_path) if @@eager
    @@autoloads["#{klass}::#{const_name}"] = file_path
  end
end

.resource_cacheObject



449
450
451
452
453
454
# File 'lib/aws/core.rb', line 449

def resource_cache
  if memoizing?
    Thread.current[:aws_memoization][:resource_cache] ||=
      Core::ResourceCache.new
  end
end

.response_cacheObject



457
458
459
460
461
462
# File 'lib/aws/core.rb', line 457

def response_cache
  if memoizing?
    Thread.current[:aws_memoization][:response_cache] ||=
      Core::ResponseCache.new
  end
end

.start_memoizingObject

Note:

Memoization is currently only supported for the EC2 APIs; other APIs are unaffected by the status of memoization. To protect your code from future changes in memoization support, you should not enable memoization while calling non-EC2 APIs.

Starts memoizing service requests made in the current thread. See memoize for a full discussion of the memoization feature. This has no effect if memoization is already enabled.



359
360
361
362
# File 'lib/aws/core.rb', line 359

def start_memoizing
  Thread.current[:aws_memoization] ||= {}
  nil
end

.stop_memoizingObject

Note:

Memoization is currently only supported for the EC2 APIs; other APIs are unaffected by the status of memoization. To protect your code from future changes in memoization support, you should not enable memoization while calling non-EC2 APIs.

Stops memoizing service requests made in the current thread. See memoize for a full discussion of the memoization feature. This has no effect if memoization is already disabled.



372
373
374
# File 'lib/aws/core.rb', line 372

def stop_memoizing
  Thread.current[:aws_memoization] = nil
end

.stub!nil

Causes all requests to return empty responses without making any requests against the live services. This does not attempt to mock the services.

Returns:

  • (nil)


468
469
470
471
# File 'lib/aws/core.rb', line 468

def stub!
  config(:stub_requests => true)
  nil
end