Sha256: c719a93c6d0bc7fc8d2e3f34049cd15c24e34ea1ac2f4a40158a7cabbe5ff395
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
require "aws-sdk-s3" module S3Secure module AwsServices extend Memoist @@buckets = {} # holds bucket => region map def s3_regional_client(bucket) region = @@buckets[bucket] unless region resp = s3_client.get_bucket_location(bucket: bucket) region = resp.location_constraint region = 'us-east-1' if region.empty? # "" means us-east-1 end new_s3_regional_client(region) end def new_s3_regional_client(region=nil) options = {} options[:endpoint] = "https://s3.#{region}.amazonaws.com" if region options[:region] = region if region Aws::S3::Client.new(options) end memoize :new_s3_regional_client # Generic s3 client. Will be configured to whatever region user has locally configured in ~/.aws/config # Used to call get_bucket_location to get each specific bucket's location. # Generally use the s3_regional_client instead of this. def s3_client Aws::S3::Client.new end memoize :s3_client end end
Version data entries
5 entries across 5 versions & 1 rubygems