Class: AWS::ELB::LoadBalancer

Inherits:
Core::Resource
  • Object
show all
Defined in:
lib/aws/elb/load_balancer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ LoadBalancer

Returns a new instance of LoadBalancer.



37
38
39
# File 'lib/aws/elb/load_balancer.rb', line 37

def initialize name, options = {}
  super(options.merge(:name => name.to_s))
end

Instance Attribute Details

#availability_zone_namesArray<String> (readonly)

Return the names of the availability zones this load balancer routes traffic to.

Returns:

  • (Array<String>)

    the current value of availability_zone_names



35
36
37
# File 'lib/aws/elb/load_balancer.rb', line 35

def availability_zone_names
  @availability_zone_names
end

#canonical_hosted_zone_nameString (readonly)

Provides the name of the Amazon Route 53 hosted zone that is associated with the load balancer. For more information: http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/index.html?using-domain-names-with-elb.html.

Returns:

  • (String)

    the current value of canonical_hosted_zone_name



35
36
37
# File 'lib/aws/elb/load_balancer.rb', line 35

def canonical_hosted_zone_name
  @canonical_hosted_zone_name
end

#canonical_hosted_zone_name_idString (readonly)

Provides the ID of the Amazon Route 53 hosted zone name that is associated with the load balancer. For more information: http://docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/index.html?using-domain-names-with-elb.html.

Returns:

  • (String)

    the current value of canonical_hosted_zone_name_id



35
36
37
# File 'lib/aws/elb/load_balancer.rb', line 35

def canonical_hosted_zone_name_id
  @canonical_hosted_zone_name_id
end

#dns_nameString (readonly)

Specifies the external DNS name associated with this load balancer.

Returns:

  • (String)

    the current value of dns_name



35
36
37
# File 'lib/aws/elb/load_balancer.rb', line 35

def dns_name
  @dns_name
end

#nameString (readonly)

The name of the load balancer.

Returns:

  • (String)

    the current value of name



35
36
37
# File 'lib/aws/elb/load_balancer.rb', line 35

def name
  @name
end

Instance Method Details

#availability_zonesAvailabilityZoneCollection

A collection that help maanage the availability zones for this load balancer.

Examples:

enable an availability zone


load_balancer.availability_zones.enable('us-east-1b')

disable an availability zone


load_balancer.availability_zones.disable('us-east-1b')

list enabled availability zoens


load_balancer.availability_zones.each do |zone|
  puts zone.name
end

Returns:

  • (AvailabilityZoneCollection)

    Returns a collection that represents this load balancer’s availability zones. You can use this collection to enable and disable availability zones.



97
98
99
# File 'lib/aws/elb/load_balancer.rb', line 97

def availability_zones
  AvailabilityZoneCollection.new(self)
end

#backend_server_policiesBackendServerPolicyCollection



117
118
119
# File 'lib/aws/elb/load_balancer.rb', line 117

def backend_server_policies
  BackendServerPolicyCollection.new(self)
end

#configure_health_check(options = {}) ⇒ Object

Updates the configuration that drives the instance health checks.

You only need to pass the options you want to change. You can call #health_check_configuration if you want to see what the current configuration values are.

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :healthy_threshold (Integer)

    Specifies the number of consecutive health probe successes required before moving the instance to the Healthy state.

  • :unhealthy_threshold (Integer)

    Specifies the number of consecutive health probe failures required before moving the instance to the Unhealthy state.

  • :interval (Integer)

    Specifies the approximate interval, in seconds, between health checks of an individual instance.

  • :timeout (Integer)

    Specifies the amount of time, in seconds, during which no response means a failed health probe.

    This value must be less than the :interval value.

  • :target (String)

    Specifies the instance being checked.

    This option should be formatted like: “TCP:80”

    • The protocol is either TCP, HTTP, HTTPS, or SSL.

    • The range of valid ports is one (1) through 65535.

    TCP is the default, specified as a TCP: port pair, for example “TCP:5000”. In this case a healthcheck simply attempts to open a TCP connection to the instance on the specified port. Failure to connect within the configured timeout is considered unhealthy.

    SSL is also specified as SSL: port pair, for example, SSL:5000. For HTTP or HTTPS protocol, the situation is different. You have to include a ping path in the string. HTTP is specified as a HTTP:port;/;PathToPing; grouping, for example “HTTP:80/weather/us/wa/seattle”. In this case, a HTTP GET request is issued to the instance on the given port and path. Any answer other than “200 OK” within the timeout period is considered unhealthy.

    The total length of the HTTP ping target needs to be 1024 16-bit Unicode characters or less.



169
170
171
172
173
174
175
176
177
178
179
# File 'lib/aws/elb/load_balancer.rb', line 169

def configure_health_check options = {}

  new_config = health_check_configuration.merge(options)

  response = client.configure_health_check(
    :load_balancer_name => name,
    :health_check => new_config)

  new_config

end

#deletenil

Deletes the load balancer.

Returns:

  • (nil)


237
238
239
240
# File 'lib/aws/elb/load_balancer.rb', line 237

def delete
  client.delete_load_balancer(:load_balancer_name => name)
  nil
end

#exists?Boolean

Returns true if the load balancer exists.

Returns:

  • (Boolean)

    Returns true if the load balancer exists.



228
229
230
231
232
233
# File 'lib/aws/elb/load_balancer.rb', line 228

def exists?
  client.describe_load_balancers(:load_balancer_names => [name])
  true
rescue Errors::LoadBalancerNotFound
  false
end

#health_check_configurationHash

Returns a hash of the various health probes conducted on the load balancer instances. The following entries are returned:

* +:healthy_threshold+
* +:unhealthy_threshold+
* +:interval+
* +:target+
* +:timeout+

See #configure_health_check for more details on what each of the configuration values mean.

Returns:

  • (Hash)


195
196
197
198
199
200
201
202
203
204
# File 'lib/aws/elb/load_balancer.rb', line 195

def health_check_configuration
  cfg = health_check_description
  {
    :healthy_threshold => cfg.healthy_threshold,
    :unhealthy_threshold => cfg.unhealthy_threshold,
    :interval => cfg.interval,
    :target => cfg.target,
    :timeout => cfg.timeout,
  }
end

#instancesInstanceCollection

Returns:



112
113
114
# File 'lib/aws/elb/load_balancer.rb', line 112

def instances
  InstanceCollection.new(self)
end

#listenersListenerCollection

Returns:



102
103
104
# File 'lib/aws/elb/load_balancer.rb', line 102

def listeners
  ListenerCollection.new(self)
end

#policiesPolicyCollection

Returns:

  • (PolicyCollection)


107
108
109
# File 'lib/aws/elb/load_balancer.rb', line 107

def policies
  LoadBalancerPolicyCollection.new(self)
end

#source_security_groupHash

Generally you don’t need to call this method, rather you can just pass the load balancer as a source to the various authorize and revoke methods of SecurityGroup:

security_group.authorize_ingress(load_balancer)

security_group.revoke_ingress(load_balancer)

Returns:

  • (Hash)

    Returns a hash that can be passed to the following SecurityGroup methods as a source:

    • SecurityGroup#authorize_ingress

    • SecurityGroup#authorize_egress



220
221
222
223
224
225
# File 'lib/aws/elb/load_balancer.rb', line 220

def source_security_group
  { 
    :group_name => security_group_description.group_name,
    :user_id => security_group_description.owner_alias,
  }
end