Using the Amazon SDK for Ruby REPL utility
The aws-sdk gem includes a Read-Eval-Print-Loop (REPL) interactive
command-line interface where you can test the SDK for Ruby and immediately see the results. SDK for Ruby
gems are available at RubyGems.org
Prerequisites
-
The
aws-v3.rbis located in the aws-sdk-resourcesgem. The aws-sdk-resourcesgem is also included by the mainaws-sdkgem. -
You will need an xml library, such as the
rexmlgem. -
Although the program does work with the Interactive Ruby Shell (
irb), we recommend that you install theprygem, which provides a more powerful REPL environment.
Bundler setup
If you use BundlerGemfile will address the prerequisite gems:
-
Open your
Gemfilethat you created when you installed the Amazon SDK for Ruby. Add the following lines to the file:gem "aws-sdk" gem "rexml" gem "pry" -
Save the Gemfile.
-
Install the dependencies specified in your
Gemfile:$bundle install
Running REPL
You can access the REPL by running aws-v3.rb from the command line.
aws-v3.rb
Alternatively, you can enable HTTP wire logging by setting the verbose flag. HTTP wire logging provides information about the communication between the Amazon SDK for Ruby and Amazon. Note, the verbose flag also adds overhead that can make your code run slower.
aws-v3.rb -v
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. In the REPL, every service class has a
helper that returns a new client object for interacting with that service. The name of the
helper will be the name of the service converted to lower case. For example, the names of
the Amazon S3 and Amazon EC2 helper objects are s3 and ec2, respectively.
To list the Amazon S3 buckets in your account, you can enter s3.list_buckets into
the prompt.
You can type quit into the REPL prompt to exit.