Class: AWS::ELB::Listener
- Inherits:
-
Object
- Object
- AWS::ELB::Listener
- Defined in:
- lib/aws/elb/listener.rb
Instance Attribute Summary collapse
- #load_balancer ⇒ LoadBalancer readonly
- #port ⇒ Integer readonly
Instance Method Summary collapse
-
#delete ⇒ nil
Deletes the listener from its load balancer.
-
#exists? ⇒ Boolean
Returns true if this listener exists.
-
#initialize(load_balancer, port, options = {}) ⇒ Listener
constructor
A new instance of Listener.
- #instance_port ⇒ Integer
- #instance_protocol ⇒ Symbol
-
#policy ⇒ LoadBalancerPolicy?
Returns the current policy for this listener.
- #policy=(policy_or_policy_name) ⇒ LoadBalancerPolicy
-
#protocol ⇒ Symbol
Returns the protocl for this listener.
-
#remove_policy ⇒ nil
Removes the current policy from this listener.
-
#server_certificate ⇒ IAM::ServerCertificate?
Returns the IAM::ServerCertificate associated with this listener, or nil if there is none.
-
#server_certificate=(server_certificate) ⇒ nil
Sets the certificate that terminates the specified listener’s SSL connections.
Constructor Details
#initialize(load_balancer, port, options = {}) ⇒ Listener
Returns a new instance of Listener.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aws/elb/listener.rb', line 30 def initialize load_balancer, port, = {} @load_balancer = load_balancer @port = port.to_i @protocol = [:protocol] @instance_port = [:instance_port] @instance_protocol = [:instance_protocol] super end |
Instance Attribute Details
#load_balancer ⇒ LoadBalancer (readonly)
43 44 45 |
# File 'lib/aws/elb/listener.rb', line 43 def load_balancer @load_balancer end |
#port ⇒ Integer (readonly)
46 47 48 |
# File 'lib/aws/elb/listener.rb', line 46 def port @port end |
Instance Method Details
#delete ⇒ nil
Deletes the listener from its load balancer.
157 158 159 160 161 162 163 164 165 |
# File 'lib/aws/elb/listener.rb', line 157 def delete client.delete_load_balancer_listeners( :load_balancer_name => load_balancer.name, :load_balancer_ports => [port]) nil end |
#exists? ⇒ Boolean
Returns true if this listener exists.
load_balancer = ELB.new.load_balancers['my-load-balancer']
listener = load_balancer.listeners[80] # port 80
listener.exists?
149 150 151 152 153 |
# File 'lib/aws/elb/listener.rb', line 149 def exists? !_description.nil? rescue AWS::Core::Resource::NotFound false end |
#instance_port ⇒ Integer
55 56 57 |
# File 'lib/aws/elb/listener.rb', line 55 def instance_port @instance_port || _description.listener.instance_port end |
#instance_protocol ⇒ Symbol
60 61 62 63 |
# File 'lib/aws/elb/listener.rb', line 60 def instance_protocol proto = @instance_protocol || _description.listener.instance_protocol proto.to_s.downcase.to_sym end |
#policy ⇒ LoadBalancerPolicy?
Returns the current policy for this listener. Returns nil if no load balancer policy has been associated with it.
106 107 108 109 |
# File 'lib/aws/elb/listener.rb', line 106 def policy policy_name = _description.policy_names.first policy_name ? load_balancer.policies[policy_name] : nil end |
#policy=(policy_or_policy_name) ⇒ LoadBalancerPolicy
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/aws/elb/listener.rb', line 114 def policy= policy_or_policy_name policy_name = policy_or_policy_name.is_a?(LoadBalancerPolicy) ? policy_or_policy_name.name : policy_or_policy_name.to_s client.set_load_balancer_policies_of_listener( :load_balancer_name => load_balancer.name, :load_balancer_port => port, :policy_names => [policy_name]) LoadBalancerPolicy.new(load_balancer, policy_name, :config => config) end |
#protocol ⇒ Symbol
Returns the protocl for this listener.
49 50 51 52 |
# File 'lib/aws/elb/listener.rb', line 49 def protocol proto = @protocol || _description.listener.protocol proto.to_s.downcase.to_sym end |
#remove_policy ⇒ nil
Removes the current policy from this listener.
130 131 132 133 134 135 136 137 138 139 |
# File 'lib/aws/elb/listener.rb', line 130 def remove_policy client.set_load_balancer_policies_of_listener( :load_balancer_name => load_balancer.name, :load_balancer_port => port, :policy_names => []) nil end |
#server_certificate ⇒ IAM::ServerCertificate?
Returns the IAM::ServerCertificate associated with this listener, or nil if there is none.
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/aws/elb/listener.rb', line 90 def server_certificate desc = _description if desc.listener.respond_to?(:ssl_certificate_id) AWS.memoize do arn = desc.listener.ssl_certificate_id iam = IAM.new(:config => config) iam.server_certificates.find{|cert| cert.arn == arn } end else nil end end |
#server_certificate=(server_certificate) ⇒ nil
Sets the certificate that terminates the specified listener’s SSL connections. The specified certificate replaces any prior certificate for this listener.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/aws/elb/listener.rb', line 74 def server_certificate= server_certificate arn = server_certificate.is_a?(IAM::ServerCertificate) ? server_certificate.arn : server_certificate client.set_load_balancer_listener_ssl_certificate( :load_balancer_name => load_balancer.name, :load_balancer_port => port, :ssl_certificate_id => arn) nil end |