Making Amazon Web Services service requests using the Amazon SDK for Ruby
To programmatically access Amazon Web Services services, SDKs use a client class for each Amazon Web Services 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 Amazon Web Services service.
To make a request to an Amazon Web Services service, you must first create and configure a service client. For each Amazon Web Services 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.
Each service client requires an Amazon Web Services Region and a credential provider. The SDK uses these values to send requests to the correct Region for your resources and to sign requests with the correct credentials. You can specify these values programmatically in code or have them automatically loaded from the environment.
-
When instantiating a client class, Amazon credentials must be supplied. For the order that the SDK checks for authentication providers, see Credential provider chain.
-
The SDK has a series of places (or sources) that it checks in order to find a value for configuration settings. For details, see Precedence of settings.
The SDK for Ruby includes client classes that provide interfaces to the Amazon Web Services services. Each
client class supports a particular Amazon Web Services service and follows the convention
Aws::
. For
example, <service identifier>
::ClientAws::S3::Client
provides an interface to the Amazon Simple Storage Service service, and Aws::SQS::Client
provides an
interface to the Amazon Simple Queue Service service.
All client classes for all Amazon Web Services services are thread-safe.
You can pass configuration options directly to Client and Resource constructors. These
options take precedence over the environment and Aws.config
defaults.
# using a credentials object ec2 = Aws::EC2::Client.new(region: 'us-west-2', credentials: credentials)