General configuration using Aws.config in the Amazon SDK for Ruby - Amazon SDK for Ruby
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

General configuration using Aws.config in the Amazon SDK for Ruby

Aws.config

To provide global configuration within your code for all Amazon classes, use Aws.config that is available in the aws-sdk-core gem.

Aws.config supports two syntaxes for different uses. Global settings can either be applied for all Amazon Web Services services or for a specific service. For the complete list of supported settings, see the Client Options in the Amazon SDK for Ruby API Reference.

Global settings through Aws.config

To set service-agnostic settings through Aws.config, use the following syntax:

Aws.config[:<global setting name>] = <value>

These settings are merged into any created service clients.

Example of a global setting:

Aws.config[:region] = 'us-west-2'

If you try to use a setting name that is not globally supported, an error is raised when you attempt to create an instance of a type of service that doesn't support it. If this happens, use service-specific syntax instead.

Service-specific settings through Aws.config

To set service-specific settings through Aws.config, use the following syntax:

Aws.config[:<service identifier>] = { <global setting name>: <value> }

These settings are merged into all created service clients of that service type.

Example of a setting that only applies to Amazon S3:

Aws.config[:s3] = { force_path_style: true }

The <service identifier> can be identified by looking at the name of the corresponding Amazon SDK for Ruby gem name, and using the suffix that follows "aws-sdk-". For example:

  • For aws-sdk-s3, the service identifier string is "s3".

  • For aws-sdk-ecs, the service identifer string is "ecs".