Installation
We can install the AWS SDK for Ruby with rubygems as:gem install aws-sdk
Or can be used as bundler by adding:
gem 'aws-sdk', '~> 1.0'
Basic Configuration
Configuring to use AWS services:AWS.config(access_key_id: '...', secret_access_key: '...')
Or can be configure for a particular service as:-
EC2 = AWS::EC2.new(
access_key_id: '...', secret_access_key: '...
)
CW = AWS::CloudWatch.new(
access_key_id: '...', secret_access_key: '...
) IAM = AWS::IAM.new(
access_key_id: '...', secret_access_key: '...
)
Basic Usage
Each service provides a service interface and a client.ec2 = AWS.ec2 #=> AWS::EC2
ec2.client #=> AWS::EC2::Client
The client provides one method for each API operation. The client methods accept a hash of request params and return a response with a hash of response data. The service interfaces provide a higher level abstration built using the client.
Example: list instance tags using a client
resp = EC2.client.(filters: [{ name: "resource-id", values: ["i-12345678"] }])
resp[:tag_set].first