Class: AWS::ELB::BackendServerPolicyCollection
- Inherits:
-
Object
- Object
- AWS::ELB::BackendServerPolicyCollection
- Includes:
- Core::Collection::Simple
- Defined in:
- lib/aws/elb/backend_server_policy_collection.rb
Overview
Helps manage policies assigned to backend server instnace ports.
Creating a Backend Server Policy
Creating a backend server policy can be a bit tricky. A BackendServerAuthenticationPolicyType policy only has one attribute, a list of public key policies.
Before you can assign a policy to a backend server instance port you must create on of the appropriate type:
# step 1, create one (or more) PublicKeyPolicyType policies
public_key1 = <<-KEY
-----BEGIN CERTIFICATE-----
MIICaTCCAdICCQDuvCF4erLGSjANBgkqhkiG9w0BAQUFADB5MQswCQYDVQQGEwJa
WjENMAsGA1UECBMERkFLRTENMAsGA1UEBxMERkFLRTENMAsGA1UEChMERkFLRTEN
MAsGA1UECxMERkFLRTENMAsGA1UEAxMERkFLRTEfMB0GCSqGSIb3DQEJARYQZmFr
ZUBleGFtcGxlLmNvbTAeFw0xMTA4MTAyMjE0NDVaFw0xMjA4MDkyMjE0NDVaMHkx
CzAJBgNVBAYTAlpaMQ0wCwYDVQQIEwRGQUtFMQ0wCwYDVQQHEwRGQUtFMQ0wCwYD
VQQKEwRGQUtFMQ0wCwYDVQQLEwRGQUtFMQ0wCwYDVQQDEwRGQUtFMR8wHQYJKoZI
hvcNAQkBFhBmYWtlQGV4YW1wbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
iQKBgQC4vy7K2LCgYJs7AbxdanPEwL4KLC9gi1LqzkRWShEaz8COUZswcOkevLQy
SMFTXAvmH1FVqNO97wVG6ydxi+LNE7Jub62QQnsK420y+nXRTytxrboH1eAiAIEt
ZoUKaOymfAN8l/MJbcPH0rTYNdni99B+UMPWmFeRg/BeWiy2hwIDAQABMA0GCSqG
SIb3DQEBBQUAA4GBAD+VNA6ia8TXa2lJgvmoGYCLGcCaccz7Nv/u4/oqv8qMPvdZ
5DZxDLIExOSHiFGwWg5m8NgcirH2diveyRBgNhgC6S6DntkEMvAV0yvaQgHtUO53
o50MymfqtoVcebZcXbiDVAXW1cPEHKLBXecX6/LZ+GOzEsUOxgt7Xs9uabqp
-----END CERTIFICATE-----
KEY
public_key_policy = load_balancer.policies.create("pkp",
'PublicKeyPolicyType', 'PublicKey' => public_key.strip)
# step 2, create the backend server policy, passing the public key policy
name = 'backend-policy'
type = 'BackendServerAuthenticationPolicyType'
attributes = {
# note: you can pass more than one public key policy here
'PublicKeyPolicyName' => [public_key_policy]
}
backend_policy = @load_balancer.policies.create(name, type, attributes)
'BackendServerAuthenticationPolicyType', attributes)
Once you have created a backend server authentication policy, you can assign it to a backend instance port:
load_balancer.backend_server_policies[80] = backend_policy
If you want to remove the policy you can pass nil instead.
# removes the policy from instance port 80
load_balancer.backend_server_policies[80] = nil
You can also get the current policy:
load_balancer.backend_server_policies[80] # returns a policy or nil
Instance Attribute Summary collapse
- #load_balancer ⇒ LoadBalancer readonly
Instance Method Summary collapse
-
#[](instance_port) ⇒ LoadBalancerPolicy?
Returns the policy currently assigned to the given instance port.
-
#[]=(instance_port, policy) ⇒ nil
Sets the policy for the given backend server instance port.
-
#initialize(load_balancer, options = {}) ⇒ BackendServerPolicyCollection
constructor
A new instance of BackendServerPolicyCollection.
Methods included from Core::Collection::Simple
Methods included from Core::Collection
#each, #each_batch, #enum, #first, #in_groups_of, #page
Constructor Details
#initialize(load_balancer, options = {}) ⇒ BackendServerPolicyCollection
Returns a new instance of BackendServerPolicyCollection.
81 82 83 84 |
# File 'lib/aws/elb/backend_server_policy_collection.rb', line 81 def initialize load_balancer, = {} @load_balancer = load_balancer super end |
Instance Attribute Details
#load_balancer ⇒ LoadBalancer (readonly)
87 88 89 |
# File 'lib/aws/elb/backend_server_policy_collection.rb', line 87 def load_balancer @load_balancer end |
Instance Method Details
#[](instance_port) ⇒ LoadBalancerPolicy?
Returns the policy currently assigned to the given instance port.
98 99 100 |
# File 'lib/aws/elb/backend_server_policy_collection.rb', line 98 def [] instance_port enum(:instance_port => instance_port).first end |
#[]=(instance_port, policy) ⇒ nil
Sets the policy for the given backend server instance port.
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/aws/elb/backend_server_policy_collection.rb', line 112 def []= instance_port, policy client.set_load_balancer_policies_for_backend_server( :load_balancer_name => load_balancer.name, :instance_port => instance_port.to_i, :policy_names => [policy_name(policy)].compact) nil end |