Class: AWS::ELB::LoadBalancerPolicyCollection
- Inherits:
-
Object
- Object
- AWS::ELB::LoadBalancerPolicyCollection
- Includes:
- Core::Collection::Simple
- Defined in:
- lib/aws/elb/load_balancer_policy_collection.rb
Instance Attribute Summary collapse
-
#load_balancer ⇒ Object
readonly
Returns the value of attribute load_balancer.
Attributes included from Core::Model
Instance Method Summary collapse
-
#[](policy_name) ⇒ LoadBalancerPolicy
Returns a reference to the load balancer policy with the given name.
-
#create(name, type, attributes = {}) ⇒ nil
Creates a new load balancer policy that contains the necessary attributes depending on the policy type.
-
#initialize(load_balancer, options = {}) ⇒ LoadBalancerPolicyCollection
constructor
A new instance of LoadBalancerPolicyCollection.
Methods included from Core::Collection::Simple
Methods included from Core::Collection
#each, #each_batch, #enum, #first, #in_groups_of, #page
Methods included from Core::Model
#client, #config_prefix, #inspect
Constructor Details
#initialize(load_balancer, options = {}) ⇒ LoadBalancerPolicyCollection
Returns a new instance of LoadBalancerPolicyCollection.
21 22 23 24 |
# File 'lib/aws/elb/load_balancer_policy_collection.rb', line 21 def initialize load_balancer, = {} @load_balancer = load_balancer super end |
Instance Attribute Details
#load_balancer ⇒ Object (readonly)
Returns the value of attribute load_balancer.
26 27 28 |
# File 'lib/aws/elb/load_balancer_policy_collection.rb', line 26 def load_balancer @load_balancer end |
Instance Method Details
#[](policy_name) ⇒ LoadBalancerPolicy
Returns a reference to the load balancer policy with the given name.
184 185 186 |
# File 'lib/aws/elb/load_balancer_policy_collection.rb', line 184 def [] policy_name LoadBalancerPolicy.new(load_balancer, policy_name) end |
#create(name, type, attributes = {}) ⇒ nil
Creates a new load balancer policy that contains the necessary attributes depending on the policy type. Policies are settings that are saved for your load balancer and that can be applied to the front-end listener, or the back-end application server, depending on your policy type.
Applying Policies
To apply a policy to a front-end listener:
# each listener may only have a single policy
load_balancer.listener[80].policy = listener_policy
To apply a policy to backend instance port
# back end servers can have multiple policies per instance port
load_balancer.backend_server_policies.add(80, back_end_policy)
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/aws/elb/load_balancer_policy_collection.rb', line 158 def create name, type, attributes = {} attribute_list = [] attributes.each do |attr_name,values| [values].flatten.each do |value| attribute_list << { :attribute_name => attr_name, :attribute_value => value.to_s } end end client.create_load_balancer_policy( :load_balancer_name => load_balancer.name, :policy_name => name.to_s, :policy_type_name => type.to_s, :policy_attributes => attribute_list) LoadBalancerPolicy.new(load_balancer, name, :type => type.to_s) end |