AWS SDK for Ruby
Developer Guide (Version v1.0.0)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

Getting Started with the AWS SDK for Ruby

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.

Get an AWS Account and Your AWS Credentials

To access AWS, you will need to sign up for an AWS account.

To sign up for an AWS account

  1. Open, and then click Sign Up.

  2. 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 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.

  1. Open the IAM console.

  2. From the navigation menu, click Users.

  3. Select your IAM user name.

  4. Click User Actions, and then click Manage Access Keys.

  5. Click Create Access Key.

    Your keys will look something like this:

    • Access key ID example: AKIAIOSFODNN7EXAMPLE

    • Secret access key example: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

  6. 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 No one who legitimately represents Amazon will ever ask you for your secret key.

Related topics

Set Up Your Ruby Environment

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.

Install the AWS SDK for Ruby

To install the AWS Ruby gem, enter the following command:

gem install aws-sdk

Set up your AWS Credentials for Use with the SDK for Ruby

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:

  • Set credentials in the AWS credentials profile file on your local system, located at:

    • ~/.aws/credentials on Linux, OS X, or Unix

    • C:\Users\USERNAME\.aws\credentials on Windows

    This file should contain lines in the following format:

    aws_access_key_id = your_access_key_id
    aws_secret_access_key = your_secret_access_key

    Substitute your own AWS credentials values for the values your_access_key_id and your_secret_access_key.

  • 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:

    export AWS_ACCESS_KEY_ID=your_access_key_id
    export AWS_SECRET_ACCESS_KEY=your_secret_access_key

    To set these variables in Windows, use set:

    set AWS_ACCESS_KEY_ID=your_access_key_id
    set AWS_SECRET_ACCESS_KEY=your_secret_access_key
  • 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.

Explore the SDK for Ruby Code Samples

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.

Where to Go from Here

The SDK reference documentation provides information about both the AWS Ruby gem and AWS Rails integration gem.

The Additional Resources section has pointers to other resources to assist you in programming AWS.