Class: AWS::ELB::Base
- Defined in:
- lib/AWS/ELB.rb,
lib/AWS/ELB/load_balancers.rb
Overview
Introduction:
The library exposes one main interface class, ‘AWS::ELB::Base’. This class provides all the methods for using the ELB service including the handling of header signing and other security issues . This class uses Net::HTTP to interface with the ELB Query API interface.
Required Arguments:
:access_key_id => String (default : “”) :secret_access_key => String (default : “”)
Optional Arguments:
:use_ssl => Boolean (default : true) :server => String (default : ‘elasticloadbalancing.amazonaws.com’) :proxy_server => String (default : nil)
Instance Attribute Summary
Attributes inherited from Base
#port, #proxy_server, #server, #use_ssl
Instance Method Summary collapse
- #api_version ⇒ Object
-
#configure_health_check(options = {}) ⇒ Object
Amazon Developer Guide Docs:.
-
#create_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:.
- #default_host ⇒ Object
-
#delete_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:.
-
#deregister_instances_from_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs: This API deregisters instances from the LoadBalancer.
- #describe_intance_health(options = {}) ⇒ Object
-
#describe_load_balancers(options = {}) ⇒ Object
Amazon Developer Guide Docs:.
- #disable_availability_zones_for_load_balancer(options = {}) ⇒ Object
- #enable_availability_zones_for_load_balancer(options = {}) ⇒ Object
-
#register_instances_with_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:.
Methods inherited from Base
Constructor Details
This class inherits a constructor from AWS::Base
Instance Method Details
#api_version ⇒ Object
47 48 49 |
# File 'lib/AWS/ELB.rb', line 47 def api_version API_VERSION end |
#configure_health_check(options = {}) ⇒ Object
Amazon Developer Guide Docs:
This API enables you to define an application healthcheck for the instances.
Note: Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly.
Required Arguments
:health_check => Hash (:timeout, :interval, :unhealthy_threshold, :healthy_threshold)
:load_balancer_name => String
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/AWS/ELB/load_balancers.rb', line 167 def configure_health_check( = {} ) raise ArgumentError, "No :health_check provided" if [:health_check].nil? || [:health_check].empty? raise ArgumentError, "No :health_check => :target provided" if [:health_check][:target].nil? || [:health_check][:target].empty? raise ArgumentError, "No :health_check => :timeout provided" if [:health_check][:timeout].nil? || [:health_check][:timeout].empty? raise ArgumentError, "No :health_check => :interval provided" if [:health_check][:interval].nil? || [:health_check][:interval].empty? raise ArgumentError, "No :health_check => :unhealthy_threshold provided" if [:health_check][:unhealthy_threshold].nil? || [:health_check][:unhealthy_threshold].empty? raise ArgumentError, "No :health_check => :healthy_threshold provided" if [:health_check][:healthy_threshold].nil? || [:health_check][:healthy_threshold].empty? raise ArgumentError, "No :load_balancer_name provided" if [:load_balancer_name].nil? || [:load_balancer_name].empty? params = {} params['LoadBalancerName'] = [:load_balancer_name] params['HealthCheck.Target'] = [:health_check][:target] params['HealthCheck.Timeout'] = [:health_check][:timeout] params['HealthCheck.Interval'] = [:health_check][:interval] params['HealthCheck.UnhealthyThreshold'] = [:health_check][:unhealthy_threshold] params['HealthCheck.HealthyThreshold'] = [:health_check][:healthy_threshold] return response_generator(:action => "ConfigureHealthCheck", :params => params) end |
#create_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:
This API creates a new LoadBalancer. Once the call has completed successfully, a new LoadBalancer will be created, but it will not be usable until at least one instance has been registered. When the LoadBalancer creation is completed, you can check whether it is usable by using the DescribeInstanceHealth API. The LoadBalancer is usable as soon as any registered instance is InService.
Required Arguments:
:load_balancer_name => String
:listeners => Array of Hashes (:protocol, :load_balancer_port, :instance_port)
:availability_zones => Array of Strings
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/AWS/ELB/load_balancers.rb', line 19 def create_load_balancer( = {} ) raise ArgumentError, "No :availability_zones provided" if [:availability_zones].nil? || [:availability_zones].empty? raise ArgumentError, "No :listeners provided" if [:listeners].nil? || [:listeners].empty? raise ArgumentError, "No :load_balancer_name provided" if [:load_balancer_name].nil? || [:load_balancer_name].empty? params = {} params.merge!(pathlist('AvailabilityZones.member', [[:availability_zones]].flatten)) params.merge!(pathhashlist('Listeners.member', [[:listeners]].flatten, { :protocol => 'Protocol', :load_balancer_port => 'LoadBalancerPort', :instance_port => 'InstancePort' })) params['LoadBalancerName'] = [:load_balancer_name] return response_generator(:action => "CreateLoadBalancer", :params => params) end |
#default_host ⇒ Object
51 52 53 |
# File 'lib/AWS/ELB.rb', line 51 def default_host DEFAULT_HOST end |
#delete_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:
This API deletes the specified LoadBalancer. On deletion, all of the configured properties of the LoadBalancer will be deleted. If you attempt to recreate the LoadBalancer, you need to reconfigure all the settings. The DNS name associated with a deleted LoadBalancer is no longer be usable. Once deleted, the name and associated DNS record of the LoadBalancer no longer exist and traffic sent to any of its IP addresses will no longer be delivered to your instances. You will not get the same DNS name even if you create a new LoadBalancer with same LoadBalancerName.
Required Arguments:
:load_balancer_name => String
53 54 55 56 57 58 59 |
# File 'lib/AWS/ELB/load_balancers.rb', line 53 def delete_load_balancer( = {} ) raise ArgumentError, "No :load_balancer_name provided" if [:load_balancer_name].nil? || [:load_balancer_name].empty? params = { 'LoadBalancerName' => [:load_balancer_name] } return response_generator(:action => "DeleteLoadBalancer", :params => params) end |
#deregister_instances_from_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:
This API deregisters instances from the LoadBalancer. Trying to deregister an instance that is not registered with the LoadBalancer does nothing.
In order to successfully call this API, you must provide the same account credentials as those that were used to create the LoadBalancer.
Once the instance is deregistered, it will stop receiving traffic from the LoadBalancer.
Required Arguments:
:instances => Array of Strings
:load_balancer_name => String
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/AWS/ELB/load_balancers.rb', line 141 def deregister_instances_from_load_balancer( = {} ) raise ArgumentError, "No :instances provided" if [:instances].nil? || [:instances].empty? raise ArgumentError, "No :load_balancer_name provided" if [:load_balancer_name].nil? || [:load_balancer_name].empty? params = {} params.merge!(pathhashlist('Instances.member', [[:instances]].flatten.map{|instance| {:instance_id => instance}}, { :instance_id => 'InstanceId' })) params['LoadBalancerName'] = [:load_balancer_name] return response_generator(:action => "DeregisterInstancesFromLoadBalancer", :params => params) end |
#describe_intance_health(options = {}) ⇒ Object
188 189 190 |
# File 'lib/AWS/ELB/load_balancers.rb', line 188 def describe_intance_health( = {} ) raise "Not yet implemented" end |
#describe_load_balancers(options = {}) ⇒ Object
Amazon Developer Guide Docs:
This API returns detailed configuration information for the specified LoadBalancers, or if no LoadBalancers are specified, then the API returns configuration information for all LoadBalancers created by the caller. For more information, please see LoadBalancer.
You must have created the specified input LoadBalancers in order to retrieve this information. In other words, in order to successfully call this API, you must provide the same account credentials as those that were used to create the LoadBalancer.
Optional Arguments:
:load_balancer_names => String
77 78 79 80 81 82 83 |
# File 'lib/AWS/ELB/load_balancers.rb', line 77 def describe_load_balancers( = {} ) = { :load_balancer_names => [] }.merge() params = pathlist("LoadBalancerName.member", [:load_balancer_names]) return response_generator(:action => "DescribeLoadBalancers", :params => params) end |
#disable_availability_zones_for_load_balancer(options = {}) ⇒ Object
192 193 194 |
# File 'lib/AWS/ELB/load_balancers.rb', line 192 def disable_availability_zones_for_load_balancer( = {} ) raise "Not yet implemented" end |
#enable_availability_zones_for_load_balancer(options = {}) ⇒ Object
196 197 198 |
# File 'lib/AWS/ELB/load_balancers.rb', line 196 def enable_availability_zones_for_load_balancer( = {} ) raise "Not yet implemented" end |
#register_instances_with_load_balancer(options = {}) ⇒ Object
Amazon Developer Guide Docs:
This API adds new instances to the LoadBalancer.
Once the instance is registered, it starts receiving traffic and requests from the LoadBalancer. Any instance that is not in any of the Availability Zones registered for the LoadBalancer will be moved to the OutOfService state. It will move to the InService state when the Availability Zone is added to the LoadBalancer.
You must have been the one who created the LoadBalancer. In other words, in order to successfully call this API, you must provide the same account credentials as those that were used to create the LoadBalancer.
NOTE: Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly.
Required Arguments:
:instances => Array of Strings
:load_balancer_name => String
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/AWS/ELB/load_balancers.rb', line 109 def register_instances_with_load_balancer( = {} ) raise ArgumentError, "No :instances provided" if [:instances].nil? || [:instances].empty? raise ArgumentError, "No :load_balancer_name provided" if [:load_balancer_name].nil? || [:load_balancer_name].empty? params = {} params.merge!(pathhashlist('Instances.member', [[:instances]].flatten.map{|instance| {:instance_id => instance}}, { :instance_id => 'InstanceId' })) params['LoadBalancerName'] = [:load_balancer_name] return response_generator(:action => "RegisterInstancesWithLoadBalancer", :params => params) end |