This folder contains code examples that demonstrate how to use the AWS SDK for Ruby to automate various Amazon web services.
- An AWS account. To create an account, see How do I create and activate a new AWS account on the AWS Premium Support website.
- AWS credentials or an AWS Security Token Service (AWS STS) access token. For details, see Configuring the AWS SDK for Ruby in the AWS SDK for Ruby Developer Guide.
- To run the code examples, Ruby version 1.9 or later. For Ruby download and installation instructions, see Download Ruby on the Ruby Progamming Language website.
- To test the code examples, RSpec 3.9 or later. For RSpec download and installation instructions, see the rspec/rspec repository in GitHub.
- The AWS SDK for Ruby. For AWS SDK for Ruby download and installation instructions, see Install the AWS SDK for Ruby in the AWS SDK for Ruby Developer Guide.
- As an AWS best practice, grant this code least privilege, or only the permissions required to perform a task. For more information, see Grant least privilege in the AWS Identity and Access Management User Guide.
- This code has not been tested in all AWS Regions. Some AWS services are available only in specific AWS Regions. For more information, see the AWS Regional Table on the AWS website.
- Running this code might result in charges to your AWS account.
Most of these code example files can be run with very little to no modification. For example, to use Ruby to run the s3/create_bucket_snippet.rb
file, you must edit the file before you can run it. To do this, open the file, replace the bucket_name
and region
variables' default values with your own values, save the file, and then run the file from the command line, for example:
ruby s3/create_bucket_snippet.rb
Most of these files have been refactored into reusable functions that can be copied into your own code. You can then call those functions directly from your own code without modifying the copied function code itself. For example, you could copy the bucket_created?
function code from the s3/create_bucket_snippet.rb
file into your own code. You could then adapt the code in the run_me
function in that same file as a basis to write your own code to call the copied bucket_created?
function.
Most of these code example files have accompanying tests that are written to work with RSpec. These tests are in the tests
folder and contain the same file name as the corresponding code example file, for example s3/tests/test_create_bucket_snippet.rb
contains tests for s3/create_bucket_snippet.rb
.
To use RSpec to run all tests within a file, specify the path to that file, for example:
rspec s3/tests/test_create_bucket_snippet.rb
To explore additional options for using RSpec to run tests, run the rspec --help
command.
Most of these tests are designed to use stubs, to avoid generating unnecessary costs in an AWS account. For more information, see Stubbing Client Responses and Errors in the AWS SDK for Ruby Developer Guide.
- AWS Documentation
- AWS SDK for Ruby Documentation
- AWS Tools and SDKs Shared Configuration and Credentials Reference Guide
- RSpec Documentation
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0