module AwsRegion
Module to hold region informations
Module to hold region informations
Constants
- AWS_REGIONS
- S3_LOCATIONS
Public Instance Methods
determine_region_from_host(host)
click to toggle source
# File lib/ec2/amitools/region.rb, line 46 def determine_region_from_host host # http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region if host == "s3.amazonaws.com" || host == "s3-external-1.amazonaws.com" "us-east-1" elsif domains = host.split(".") # handle s3-$REGION.amazonaws.something if domains.length >= 3 && domains[0].start_with?("s3-") domains[0].sub("s3-", "") # handle s3.$REGION.amazonaws.something, this is specific to the cn-north-1 endpoint elsif domains.length >= 3 && domains[0] == "s3" domains[1] else "us-east-1" end end end
get_s3_location(region)
click to toggle source
# File lib/ec2/amitools/region.rb, line 74 def get_s3_location(region) if (region == "eu-west-1") return 'EU' elsif (region == "us-east-1") return :unconstrained else return region end end
guess_region_from_s3_bucket(location)
click to toggle source
# File lib/ec2/amitools/region.rb, line 64 def guess_region_from_s3_bucket(location) if (location == "EU") return "eu-west-1" elsif ((location == "US") || (location == "") || (location.nil?)) return "us-east-1" else return location end end
regions()
click to toggle source
# File lib/ec2/amitools/region.rb, line 84 def regions AWS_REGIONS end
s3_locations()
click to toggle source
# File lib/ec2/amitools/region.rb, line 88 def s3_locations S3_LOCATIONS end