Class | RightAws::ElbInterface |
In: |
lib/elb/right_elb_interface.rb
|
Parent: | RightAwsBase |
The RightAws::ElbInterface class provides a complete interface to Amazon‘s Elastic Load Balancer service.
For explanations of the semantics of each call, please refer to Amazon‘s documentation at docs.amazonwebservices.com/ElasticLoadBalancing/latest/DeveloperGuide/
Create an interface handle:
elb = RightAws::ElbInterface.new(aws_access_key_id, aws_security_access_key)
Create an new load balancer:
elb.create_load_balancer( 'test-kd1', ['us-east-1a', 'us-east-1b'], [ { :protocol => :http, :load_balancer_port => 80, :instance_port => 80 }, { :protocol => :tcp, :load_balancer_port => 443, :instance_port => 443 } ])
Configure its health checking:
elb.configure_health_check( 'test-kd1', { :healthy_threshold => 9, :unhealthy_threshold => 3, :target => "TCP:433", :timeout => 6, :interval => 31}
Register instances with the balancer:
elb.register_instances_with_load_balancer('test-kd1', 'i-8b8bcbe2', 'i-bf8bcbd6') #=> ["i-8b8bcbe2", "i-bf8bcbd6"]
Add new availability zones:
elb.enable_availability_zones_for_load_balancer("test-kd1", "us-east-1c")
API_VERSION | = | "2009-11-25" | Amazon ELB API version being used | |
DEFAULT_HOST | = | "elasticloadbalancing.amazonaws.com" | ||
DEFAULT_PATH | = | '/' | ||
DEFAULT_PROTOCOL | = | 'https' | ||
DEFAULT_PORT | = | 443 |
Create a new handle to an ELB account. All handles share the same per process or per thread HTTP connection to Amazon ELB. Each handle is for a specific account. The params have the following options:
Define an application healthcheck for the instances. Returns an updated health check configuration for the load balancer.
hc = elb.configure_health_check( 'test-kd1', { :healthy_threshold => 9, :unhealthy_threshold => 3, :target => "TCP:433", :timeout => 6, :interval => 31} pp hc #=> { :target=>"TCP:433", :timeout=>6, :interval=>31, :healthy_threshold=>9, :unhealthy_threshold=>3 }
Generates a stickiness policy with sticky session lifetimes that follow that of an application-generated cookie. This policy can only be associated with HTTP listeners.
elb.create_app_cookie_stickiness_policy('my-load-balancer', 'MyLoadBalancerPolicy', 'MyCookie') #=> true
Generates a stickiness policy with sticky session lifetimes controlled by the lifetime of the browser (user-agent) or a specified expiration period. This policy can only be associated only with HTTP listeners.
elb.create_lb_cookie_stickiness_policy('my-load-balancer', 'MyLoadBalancerPolicy', 60) #=> true
Create new load balancer. Returns a new load balancer DNS name.
lb = elb.create_load_balancer( 'test-kd1', ['us-east-1a', 'us-east-1b'], [ { :protocol => :http, :load_balancer_port => 80, :instance_port => 80 }, { :protocol => :tcp, :load_balancer_port => 443, :instance_port => 443 } ]) puts lb #=> "test-kd1-1519253964.us-east-1.elb.amazonaws.com"
Delete load balancer. Returns true on success.
elb.delete_load_balancer('test-kd1') #=> true
Amazon: Because this API has been designed to be idempotent, even if the LoadBalancer does not exist or has been deleted, DeleteLoadBalancer still returns a success.
Remove instance(s) from the load balancer. Returns an updated list of instances for the load balancer.
elb.deregister_instances_with_load_balancer('test-kd1', 'i-8b8bcbe2') #=> ["i-bf8bcbd6"]
Describe the current state of the instances of the specified load balancer. Returns a list of the instances.
elb.describe_instance_health('test-kd1', 'i-8b8bcbe2', 'i-bf8bcbd6') #=> [ { :description => "Instance registration is still in progress", :reason_code => "ELB", :instance_id => "i-8b8bcbe2", :state => "OutOfService" }, { :description => "Instance has failed at least the UnhealthyThreshold number of health checks consecutively.", :reason_code => "Instance", :instance_id => "i-bf8bcbd6", :state => "OutOfService" } ]
Remove one or more zones from a load balancer. Returns a list of updated availability zones for the load balancer.
elb.disable_availability_zones_for_load_balancer("test-kd1", "us-east-1c") #=> ["us-east-1a"]
Add one or more zones to a load balancer. Returns a list of updated availability zones for the load balancer.
elb.enable_availability_zones_for_load_balancer("test-kd1", "us-east-1c") #=> ["us-east-1a", "us-east-1c"]
Add new instance(s) to the load balancer. Returns an updated list of instances for the load balancer.
elb.register_instances_with_load_balancer('test-kd1', 'i-8b8bcbe2', 'i-bf8bcbd6') #=> ["i-8b8bcbe2", "i-bf8bcbd6"]