StorageGRID Webscale & AWS SDK for Ruby Version 2

In recent posts, we've covered how to access StorageGRID Webscale's S3 API and how to setup SSL certificates. In this post, we'll show you how to use the AWS SDK for Ruby Version 2 to access StorageGRID's S3 endpoint.

 

require 'aws-sdk'

s3 = Aws::S3::Client.new(region: 'us-east-1',
                         endpoint: 'https://s3gateway.mycompany.com:8082',
                         ssl_verify_peer: true,
                         ssl_ca_bundle: 'server.crt',
                         credentials: Aws::SharedCredentials.new(profile_name: 'my_profile'),
                         force_path_style: true)

response = s3.list_buckets
response.buckets.each { |b| puts "Bucket: #{b.name}, Creation-Date:#{b.creation_date}"}

 

Import is that you specify the region parameter as 'us-east-1'. Otherwise the SDK will complain about a missing parameter. The SDK will connect to the endpoint, which is specified in the endpoint field, in this case "https://s3gateway.mycompany.com:8082", which is our StorageGRID Gateway node for S3.

 

For more information on how to use the Ruby SDK, have a look at AWS S3 Ruby SDK documentation.

 

Follow me on Twitter: @clemenssiebler