Configuring service clients in the AWS SDK for Ruby
To programmatically access AWS services, the AWS SDK for Ruby uses a client class for each AWS service. For example, if your application needs to access Amazon EC2, your application creates an Amazon EC2 client object to interface with that service. You then use the service client to make requests to that AWS service.
To make a request to an AWS service, you must first create a service client. For each AWS service your code uses, it has its own gem and its own dedicated type for interacting with it. The client exposes one method for each API operation exposed by the service.
There are many alternative ways to configure SDK behavior, but ultimately everything has to do with the behavior of service clients. Any configuration has no effect until a service client that is created from them is used.
You must establish how your code authenticates with AWS when you develop with AWS services. You must also set the AWS Region you want to use.
The AWS SDKs and Tools Reference Guide also contains settings, features, and other foundational concepts common among many of the AWS SDKs.
Topics
The Shared config
and
credentials
files can be used for configuration settings. For all
AWS SDK settings, see the Settings
reference in the AWS SDKs and Tools Reference Guide.
Different profiles can
be used to store different configurations. To specify the active profile that the SDK loads, you can use the AWS_PROFILE
environment variable or the profile
option of Aws.config
.
Precedence of settings
Global settings configure features, credential providers, and other functionality that are supported by most SDKs and have a broad impact across AWS services. All AWS SDKs have a series of places (or sources) that they check in order to find a value for global settings. Not all settings are available in all sources. The following is the setting lookup precedence:
-
Any explicit setting set in the code or on a service client itself takes precedence over anything else.
-
Any parameters passed directly into a client constructor take highest precedence.
-
Aws.config
is checked for global or service-specific settings.
-
-
The environment variable is checked.
-
The shared AWS
credentials
file is checked. -
The shared AWS
config
file is checked. -
Any default value provided by the AWS SDK for Ruby source code itself is used last.