module S3Secure::AwsServices::S3
Public Instance Methods
check_bucket!()
click to toggle source
# File lib/s3_secure/aws_services/s3.rb, line 29 def check_bucket! # IMPORANT: The class that includes this module must set @bucket before using the s3 method. unless @bucket raise "@bucket #{@bucket.inspect} is not set. The class must set @bucket before using the any client method." end region_map # triggers building region map for specific @bucket end
new_s3_regional_client()
click to toggle source
# File lib/s3_secure/aws_services/s3.rb, line 11 def new_s3_regional_client options = {} options[:endpoint] = "https://s3.#{region}.amazonaws.com" options[:region] = region Aws::S3::Client.new(options) rescue Aws::STS::Errors::RegionDisabledException puts "ERROR: Fail to establish client connection to region #{region}".color(:red) raise end
region()
click to toggle source
# File lib/s3_secure/aws_services/s3.rb, line 50 def region region_map[@bucket] end
region_map()
click to toggle source
# File lib/s3_secure/aws_services/s3.rb, line 38 def region_map region = @@region_map[@bucket] return @@region_map if region # return cache # build cache resp = s3_client.get_bucket_location(bucket: @bucket) region = resp.location_constraint region = 'us-east-1' if region.empty? # "" means us-east-1 @@region_map[@bucket] = region @@region_map end
s3()
click to toggle source
# File lib/s3_secure/aws_services/s3.rb, line 6 def s3 check_bucket! @@s3_clients[@bucket] ||= new_s3_regional_client end
s3_client()
click to toggle source
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.
# File lib/s3_secure/aws_services/s3.rb, line 24 def s3_client Aws::S3::Client.new end