Class: ConfigureS3Website::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/configure-s3-website/s3_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(location_constraint) ⇒ Endpoint

Returns a new instance of Endpoint.



135
136
137
138
139
140
141
142
# File 'lib/configure-s3-website/s3_client.rb', line 135

def initialize(location_constraint)
  raise InvalidS3LocationConstraintError unless
    location_constraints.has_key?location_constraint
  @region = location_constraints.fetch(location_constraint)[:region]
  @hostname = location_constraints.fetch(location_constraint)[:endpoint]
  @website_hostname = location_constraints.fetch(location_constraint)[:website_endpoint]
  @location_constraint = location_constraint
end

Instance Attribute Details

#hostnameObject (readonly)

Returns the value of attribute hostname.



133
134
135
# File 'lib/configure-s3-website/s3_client.rb', line 133

def hostname
  @hostname
end

#location_constraintObject (readonly)

Returns the value of attribute location_constraint.



133
134
135
# File 'lib/configure-s3-website/s3_client.rb', line 133

def location_constraint
  @location_constraint
end

#regionObject (readonly)

Returns the value of attribute region.



133
134
135
# File 'lib/configure-s3-website/s3_client.rb', line 133

def region
  @region
end

#website_hostnameObject (readonly)

Returns the value of attribute website_hostname.



133
134
135
# File 'lib/configure-s3-website/s3_client.rb', line 133

def website_hostname
  @website_hostname
end

Class Method Details

.by_config_source(config_source) ⇒ Object



166
167
168
# File 'lib/configure-s3-website/s3_client.rb', line 166

def self.by_config_source(config_source)
  endpoint = Endpoint.new(config_source.s3_endpoint || '')
end

Instance Method Details

#location_constraintsObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/configure-s3-website/s3_client.rb', line 145

def location_constraints
  eu_west_1_region = {
    :region           => 'EU (Ireland)',
    :website_endpoint => 's3-website-eu-west-1.amazonaws.com',
    :endpoint         => 's3-eu-west-1.amazonaws.com'
  }

  {
    ''               => { :region => 'US Standard',                   :endpoint => 's3.amazonaws.com',                :website_endpoint => 's3-website-us-east-1.amazonaws.com' },
    'us-west-2'      => { :region => 'US West (Oregon)',              :endpoint => 's3-us-west-2.amazonaws.com',      :website_endpoint => 's3-website-us-west-2.amazonaws.com' },
    'us-west-1'      => { :region => 'US West (Northern California)', :endpoint => 's3-us-west-1.amazonaws.com',      :website_endpoint => 's3-website-us-west-1.amazonaws.com' },
    'EU'             => eu_west_1_region,
    'eu-west-1'      => eu_west_1_region,
    'eu-central-1'   => { :region => 'EU (Frankfurt)',                :endpoint => 's3.eu-central-1.amazonaws.com',   :website_endpoint => 's3-website.eu-central-1.amazonaws.com' },
    'ap-southeast-1' => { :region => 'Asia Pacific (Singapore)',      :endpoint => 's3-ap-southeast-1.amazonaws.com', :website_endpoint => 's3-website-ap-southeast-1.amazonaws.com' },
    'ap-southeast-2' => { :region => 'Asia Pacific (Sydney)',         :endpoint => 's3-ap-southeast-2.amazonaws.com', :website_endpoint => 's3-website-ap-southeast-2.amazonaws.com' },
    'ap-northeast-1' => { :region => 'Asia Pacific (Tokyo)',          :endpoint => 's3-ap-northeast-1.amazonaws.com', :website_endpoint => 's3-website-ap-northeast-1.amazonaws.com' },
    'sa-east-1'      => { :region => 'South America (Sao Paulo)',     :endpoint => 's3-sa-east-1.amazonaws.com',      :website_endpoint => 's3-website-sa-east-1.amazonaws.com' }
  }
end