|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
This section provides information about how to install, set up and use the AWS SDK for Ruby. If you have never used the SDK for Ruby before, you should start here.
To access AWS, you will need to sign up for an AWS account.
To sign up for an AWS account
Go to http://aws.amazon.com, and then click Sign Up.
Follow the on-screen instructions.
Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone keypad.
AWS sends you a confirmation e-mail after the sign-up process is complete. At any time, you can view your current account activity and manage your account by going to http://aws.amazon.com and clicking My Account/Console.
To get your access key ID and secret access key
Access keys consist of an access key ID and secret access key, which are used to sign programmatic requests that you make to AWS. If you don't have access keys, you can create them by using the AWS Management Console.
To create access keys, you must have permissions to perform the required IAM actions. For more information, see Granting IAM User Permission to Manage Password Policy and Credentials in Using IAM.
Go to the IAM console.
From the navigation menu, click Users.
Select your IAM user name.
Click User Actions, and then click Manage Access Keys.
Click Create Access Key.
Your keys will look something like this:
Access key ID example: AKIAIOSFODNN7EXAMPLE
Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
Click Download Credentials, and store the keys in a secure location.
Your secret key will no longer be available through the AWS Management Console; you will have the only copy. Keep it confidential in order to protect your account, and never email it. Do not share it outside your organization, even if an inquiry appears to come from AWS or Amazon.com. No one who legitimately represents Amazon will ever ask you for your secret key.
The AWS Ruby SDK runs on Ruby 1.8.7 and later. If you have an older version of Ruby, Ruby enVironment Manager (RVM) is a great way to try the latest version. RVM is a command-line tool that manages multiple versions of Ruby on a single computer.
To install the AWS Ruby gem, enter the following command:
gem install aws-sdk
To connect to any of the supported services with the SDK for Ruby, you must provide your AWS credentials. The AWS SDKs and CLIs use provider chains to look for AWS credentials in a number of different places, including system or user environment variables and local AWS configuration files.
Setting your credentials for use by the SDK for Ruby can be done in a number of ways, but here are the recommended approaches:
To set credentials for your local user (login), specify them in a file on your local system, located at:
~/.aws/credentials on Linux, OS X, or Unix
C:\Users\ on Windows
This file should contain lines in the following format:
[default] aws_access_key_id =
Substitute your own AWS credentials values for the values your_access_key_id and your_secret_access_key.
To set credentials for a particular terminal (command-line) session, set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.
To set these variables in Linux, OS X, or Unix, use export:
To set these variables in Windows, use set:
To set credentials for an EC2 instance, you should specify an IAM role and then give your EC2 instance access to that role as shown in Using IAM Roles for Amazon EC2 Instances with the AWS SDK for Ruby.
Once you have set your AWS credentials using one of these methods, they can be loaded automatically by the SDK for Ruby by using the default credential provider chain. For complete information about how to load and use AWS credentials in your SDK for Ruby applications, see Providing Credentials.
The SDK for Ruby is packaged with a number of code samples, which you can browse on your machine or view on GitHub. For more information about the samples that are provided, see AWS SDK for Ruby Samples.