Module: AwsRegion
- Defined in:
- lib/ec2/amitools/region.rb
Overview
Module to hold region informations
Constant Summary collapse
- AWS_REGIONS =
[ 'eu-west-1', 'eu-central-1', 'us-east-1', 'us-gov-west-1', 'cn-north-1', 'us-west-1', 'us-west-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'sa-east-1', ]
- S3_LOCATIONS =
[ 'EU', 'eu-west-1', 'eu-central-1', 'US', 'us-gov-west-1', 'cn-north-1', 'us-west-1', 'us-west-2', 'ap-southeast-1', 'ap-southeast-2', 'ap-northeast-1', 'sa-east-1', ]
Class Method Summary collapse
- .determine_region_from_host(host) ⇒ Object
- .get_s3_location(region) ⇒ Object
- .guess_region_from_s3_bucket(location) ⇒ Object
- .regions ⇒ Object
- .s3_locations ⇒ Object
Class Method Details
.determine_region_from_host(host) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# 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) ⇒ Object
64 65 66 67 68 69 70 71 72 |
# 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 ⇒ Object
84 85 86 |
# File 'lib/ec2/amitools/region.rb', line 84 def regions AWS_REGIONS end |
.s3_locations ⇒ Object
88 89 90 |
# File 'lib/ec2/amitools/region.rb', line 88 def s3_locations S3_LOCATIONS end |