| 1 | package VM::EC2::ELB; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | VM::EC2::ELB -- Object describing an Elastic Load Balancer | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use VM::EC2; | ||
| 10 | |||
| 11 | $ec2 = VM::EC2->new(...); | ||
| 12 | $lb = $ec2->create_load_balancer(%args); | ||
| 13 | or | ||
| 14 | $lb = $ec2->describe_load_balancers(-load_balancer_name=>'my-lb'); | ||
| 15 | |||
| 16 | @zones = $lb->AvailabilityZones; | ||
| 17 | $created = $lb->CreatedTime; | ||
| 18 | $dns_name = $lb->DNSName; | ||
| 19 | $health_check = $lb->HealthCheck; | ||
| 20 | @instances = $lb->Instances; | ||
| 21 | @list_desc = $lb->ListenerDescriptions; | ||
| 22 | $name = $lb->LoadBalancerName; | ||
| 23 | @policies_obj = $lb->Policies; | ||
| 24 | @policies = $lb->describe_policies(-policy_names=>'mypolicy'); | ||
| 25 | $scheme = $lb->Scheme; | ||
| 26 | $sg_name = $lb->SourceSecurityGroup; | ||
| 27 | $success = $lb->create_load_balancer_listeners(%args); | ||
| 28 | $success = $lb->enable_availability_zones_for_load_balancer(@zones); | ||
| 29 | @list = $lb->register_instances_with_load_balancer(-instances => 'i-12345678'); | ||
| 30 | $state = $lb->describe_instance_health(-instances => 'i-12345678') | ||
| 31 | $success = $lb->delete_load_balancer; | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | This object represents an Amazon Elastic Load Balancer and is returned by | ||
| 36 | VM::EC2->describe_load_balancers() and VM::EC2->create_load_balancer(). | ||
| 37 | In addition to methods to query the ELB's attributes, there are methods that | ||
| 38 | manage the ELB's lifecycle and properties. | ||
| 39 | |||
| 40 | =head1 METHODS | ||
| 41 | |||
| 42 | The following object methods are supported: | ||
| 43 | |||
| 44 | AvailabilityZones -- The enabled availability zones for the ELB in the | ||
| 45 | form of an array of L<VM::EC2::AvailabilityZone> | ||
| 46 | objects. | ||
| 47 | BackendServerDescriptions -- The backend server descriptions. | ||
| 48 | CreatedTime -- The creation date of the ELB. | ||
| 49 | DNSName -- The DNS name of the ELB. | ||
| 50 | HealthCheck -- The health check associated with the ELB in the | ||
| 51 | form of a L<VM::EC2::ELB::HealthCheck> object. | ||
| 52 | Instances -- The instances that the ELB points to, in the form | ||
| 53 | of an array of L<VM::EC2::Instance> objects. | ||
| 54 | ListenerDescriptions -- An array of L<VM::EC2::ELB::ListenerDescription> | ||
| 55 | objects. | ||
| 56 | LoadBalancerName -- The name of the ELB | ||
| 57 | Policies -- The policies of the ELB in the form of a | ||
| 58 | L<VM::EC2::ELB::Policies> object. | ||
| 59 | Scheme -- Specifies the type of ELB ('internal' is for VPC | ||
| 60 | only.) | ||
| 61 | SecurityGroups -- The security groups the ELB is a member of (VPC | ||
| 62 | only) in the form of L<VM::EC2::SecurityGroup> | ||
| 63 | objects. | ||
| 64 | SourceSecurityGroup -- The security group that the ELB is a member of | ||
| 65 | Subnets -- Provides an array of VPC subnet objects | ||
| 66 | (L<VM::EC2::VPC::Subnet>) that the ELB is part of. | ||
| 67 | VPCId -- Provides the ID of the VPC attached to the ELB. | ||
| 68 | |||
| 69 | "Unimplemented/untested" object methods related to Route 53 (return raw data/ | ||
| 70 | data structures): | ||
| 71 | |||
| 72 | CanonicalHostedZoneName -- The name of the Amazon Route 53 hosted zone that | ||
| 73 | is associated with the ELB. | ||
| 74 | CanonicalHostedZoneNameID -- The ID of the Amazon Route 53 hosted zone name | ||
| 75 | that is associated with the ELB. | ||
| 76 | |||
| 77 | The following convenience methods are supported; | ||
| 78 | |||
| 79 | active_policies -- Returns the policies that are actively in use by | ||
| 80 | the ELB in the form of L<VM::EC2::ELB::PolicyDescription> | ||
| 81 | objects. | ||
| 82 | all_policies -- Returns all policies that are associated with the | ||
| 83 | ELB in the form of L<VM::EC2::ELB::PolicyDescription> | ||
| 84 | objects. | ||
| 85 | listeners -- Provides the L<VM::EC2::ELB::Listener> objects | ||
| 86 | associated with the ELB | ||
| 87 | |||
| 88 | =head1 LIFECYCLE METHODS | ||
| 89 | |||
| 90 | =head2 $success = $elb->delete_load_balancer | ||
| 91 | =head2 $success = $elb->delete | ||
| 92 | |||
| 93 | This method deletes the ELB. Returns true on success. | ||
| 94 | |||
| 95 | =head2 $success = $elb->create_app_cookie_stickiness_policy(-cookie_name=>$cookie_name,-policy_name=>$policy_name) | ||
| 96 | |||
| 97 | Generates a stickiness policy with sticky session lifetimes that follow that of | ||
| 98 | an application-generated cookie. This policy can be associated only with | ||
| 99 | HTTP/HTTPS listeners. Returns true on success. | ||
| 100 | |||
| 101 | =head2 $success = $elb->create_lb_cookie_stickiness_policy(-cookie_expiration_period=>$secs,-policy_name=>$name) | ||
| 102 | |||
| 103 | Generates a stickiness policy with sticky session lifetimes controlled by the | ||
| 104 | lifetime of the browser (user-agent) or a specified expiration period. This | ||
| 105 | policy can be associated only with HTTP/HTTPS listeners. Returns true on | ||
| 106 | success. | ||
| 107 | |||
| 108 | =head2 $success = $elb->create_load_balancer_listeners(-listeners=>\%listener_hash); | ||
| 109 | =head2 $success = $elb->create_listeners(\%listener_hash); | ||
| 110 | |||
| 111 | Creates one or more listeners on a ELB for the specified port. If a listener | ||
| 112 | with the given port does not already exist, it will be created; otherwise, the | ||
| 113 | properties of the new listener must match the properties of the existing | ||
| 114 | listener. Returns true on success. | ||
| 115 | |||
| 116 | The passed argument must either be a L<VM::EC2::ELB:Listener> object (or arrayref of | ||
| 117 | objects) or a hash (or arrayref of hashes) containing the following keys: | ||
| 118 | |||
| 119 | Protocol -- Value as one of: HTTP, HTTPS, TCP, or SSL | ||
| 120 | LoadBalancerPort -- Value in range 1-65535 | ||
| 121 | InstancePort -- Value in range 1-65535 | ||
| 122 | and optionally: | ||
| 123 | InstanceProtocol -- Value as one of: HTTP, HTTPS, TCP, or SSL | ||
| 124 | SSLCertificateId -- Certificate ID from AWS IAM certificate list | ||
| 125 | |||
| 126 | =head2 $success = $elb->delete_load_balancer_listeners(-load_balancer_ports=>\@ports) | ||
| 127 | =head2 $success = $elb->delete_listeners(@ports) | ||
| 128 | |||
| 129 | Deletes listeners from the ELB for the specified port. Returns true on | ||
| 130 | success. | ||
| 131 | |||
| 132 | =head2 @zones = $elb->disable_availability_zones_for_load_balancer(-zones=>\@zones) | ||
| 133 | =head2 @zones = $elb->disable_availability_zones(@zones) | ||
| 134 | =head2 @zones = $elb->disable_zones(@zones) | ||
| 135 | |||
| 136 | Removes the specified EC2 Availability Zones from the set of configured | ||
| 137 | Availability Zones for the ELB. Returns a series of L<VM::EC2::AvailabilityZone> | ||
| 138 | objects now associated with the ELB. | ||
| 139 | |||
| 140 | =head2 @zones = $elb->enable_availability_zones_for_load_balancer(-zones=>\@zones) | ||
| 141 | =head2 @zones = $elb->enable_availability_zones(@zones) | ||
| 142 | =head2 @zones = $elb->enable_zones(@zones) | ||
| 143 | |||
| 144 | Adds the specified EC2 Availability Zones to the set of configured | ||
| 145 | Availability Zones for the ELB. Returns a series of L<VM::EC2::AvailabilityZone> | ||
| 146 | objects now associated with the ELB. | ||
| 147 | |||
| 148 | =head2 @instance_ids = $elb->register_instances_with_load_balancer(-instances=>\@instance_ids) | ||
| 149 | =head2 @instance_ids = $elb->register_instances(@instance_ids) | ||
| 150 | |||
| 151 | Adds new instances to the ELB. If the instance is in an availability zone that | ||
| 152 | is not registered with the ELB will be in the OutOfService state. Once the zone | ||
| 153 | is added to the ELB the instance will go into the InService state. Returns an | ||
| 154 | array of instance IDs now associated with the ELB. | ||
| 155 | |||
| 156 | =head2 @instance_ids = $elb->deregister_instances_from_load_balancer(-instances=>\@instance_ids) | ||
| 157 | =head2 @instance_ids = $elb->deregister_instances(@instance_ids) | ||
| 158 | |||
| 159 | Deregisters instances from the ELB. Once the instance is deregistered, it will | ||
| 160 | stop receiving traffic from the ELB. Returns an array of instance IDs now | ||
| 161 | associated with the ELB. | ||
| 162 | |||
| 163 | =head2 @states = $elb->describe_instance_health(-instances=>\@instance_ids) | ||
| 164 | =head2 @states = $elb->describe_instance_health(@instance_ids) | ||
| 165 | |||
| 166 | Provides the current state of the instances of the specified LoadBalancer. If no | ||
| 167 | instances are specified, the state of all the instances for the ELB is returned. | ||
| 168 | Returns an array of L<VM::EC2::ELB::InstanceState> objects. | ||
| 169 | |||
| 170 | =head2 $success = $elb->create_load_balancer_policy(-policy_name=>$name,-policy_type_name=>$type_name,-policy_attributes=>\@attrs) | ||
| 171 | =head2 $success = $elb->create_policy(-policy_name=>$name,-policy_type_name=>$type_name,-policy_attributes=>\@attrs) | ||
| 172 | |||
| 173 | Creates a new policy that contains the necessary attributes depending on the | ||
| 174 | policy type. Policies are settings that are saved for your ELB and that can be | ||
| 175 | applied to the front-end listener, or the back-end application server, | ||
| 176 | depending on your policy type. Returns true on success. | ||
| 177 | |||
| 178 | =head2 $success = $elb->delete_load_balancer_policy(-policy_name=>$policy_name) | ||
| 179 | =head2 $success = $elb->delete_policy($policy_name) | ||
| 180 | |||
| 181 | Deletes a policy from the ELB. The specified policy must not be enabled for any | ||
| 182 | listeners. Returns true on success. | ||
| 183 | |||
| 184 | =head1 CONFIGURATION METHODS | ||
| 185 | |||
| 186 | =head2 $health_check = $elb->configure_health_check(-healthy_threshold=>$cnt,-interval=>$secs,-target=>$target,-timeout=>$secs,-unhealthy_threshold=>$cnt) | ||
| 187 | |||
| 188 | This method configures the health check for a particular target service. | ||
| 189 | |||
| 190 | -target must be in the format Protocol:Port[/PathToPing]: | ||
| 191 | - Valid Protocol types are: HTTP, HTTPS, TCP, SSL | ||
| 192 | - Port must be in range 0-65535 | ||
| 193 | - PathToPing is only applicable to HTTP or HTTPS protocol | ||
| 194 | types and must be 1024 characters long or fewer. | ||
| 195 | |||
| 196 | ex: HTTP:80/index.html | ||
| 197 | |||
| 198 | =head2 $success = $elb->create_policy(-policy_name=>$name,-policy_type_name=>$type_name) | ||
| 199 | |||
| 200 | Creates a new policy that contains the necessary attributes depending on the | ||
| 201 | policy type. Returns true on success. | ||
| 202 | |||
| 203 | =head2 $success = $elb->set_load_balancer_listener_ssl_certificate(-port=>$port,-cert_id=>$cert_id) | ||
| 204 | |||
| 205 | Sets the certificate that terminates the specified listener's SSL connections. | ||
| 206 | The specified certificate replaces any prior certificate that was used on the | ||
| 207 | same ELB and port. Returns true on success. | ||
| 208 | |||
| 209 | =head2 $success = $elb->set_load_balancer_policies_of_listener(-port=>$port,-policy_names=>\@names) | ||
| 210 | =head2 $success = $elb->set_policies_of_listener(-port=>$port,-policy_names=>\@names) | ||
| 211 | |||
| 212 | Associates, updates, or disables a policy with a listener on the ELB. Multiple | ||
| 213 | policies may be associated with a listener. Returns true on success. | ||
| 214 | |||
| 215 | =head2 @groups = $elb->apply_security_groups_to_load_balancer(-security_groups=>\@groups) | ||
| 216 | =head2 @groups = $elb->apply_security_groups(@groups) | ||
| 217 | |||
| 218 | Associates one or more security groups with your ELB in VPC. The provided | ||
| 219 | security group IDs will override any currently applied security groups. | ||
| 220 | Returns a list of L<VM::EC2::SecurityGroup> objects. | ||
| 221 | |||
| 222 | =head2 @subnets = $elb->attach_load_balancer_to_subnets(-subnets=>\@subnets) | ||
| 223 | =head2 @subnets = $elb->attach_to_subnets(@subnets) | ||
| 224 | |||
| 225 | Adds one or more subnets to the set of configured subnets for the ELB. | ||
| 226 | Returns a series of L<VM::EC2::VPC::Subnet> objects corresponding to the | ||
| 227 | subnets the ELB is now attached to. | ||
| 228 | |||
| 229 | =head2 @subnets = $elb->detach_load_balancer_from_subnets(-subnets=>\@subnets) | ||
| 230 | =head2 @subnets = $elb->detach_from_subnets(@subnets) | ||
| 231 | |||
| 232 | Removes subnets from the set of configured subnets in the VPC for the ELB. | ||
| 233 | Returns a series of L<VM::EC2::VPC::Subnet> objects corresponding to the | ||
| 234 | subnets the ELB is now attached to. | ||
| 235 | |||
| 236 | =head2 $success = $elb->set_load_balancer_policies_for_backend_server(-port=>$port,-policy_names=>$names) | ||
| 237 | =head2 $success = $elb->set_policies_for_backend_server(-port=>$port,-policy_names=>$names) | ||
| 238 | |||
| 239 | Replaces the current set of policies associated with a port on which the back- | ||
| 240 | end server is listening with a new set of policies. After the policies have | ||
| 241 | been created, they can be applied here as a list. At this time, only the back- | ||
| 242 | end server authentication policy type can be applied to the back-end ports; | ||
| 243 | this policy type is composed of multiple public key policies. Returns true on | ||
| 244 | success. | ||
| 245 | |||
| 246 | =head2 $success = $elb->add_tags({ Name => Value[, Name => Value,...]); | ||
| 247 | =head2 $success = $elb->add_tags(\%tags); | ||
| 248 | |||
| 249 | Adds tags to the ELB. Up to ten tags can be applied. | ||
| 250 | |||
| 251 | =head1 INFORMATION METHODS | ||
| 252 | |||
| 253 | =head2 $state = $lb->describe_instance_health(-instances=>\@instances) | ||
| 254 | =head2 $state = $lb->describe_instance_health(@instances) | ||
| 255 | =head2 $state = $lb->describe_instance_health | ||
| 256 | |||
| 257 | Returns the current state of the instances registered with the ELB. | ||
| 258 | |||
| 259 | =head2 @policies = $lb->describe_load_balancer_policies(-policy_names=>\@names) | ||
| 260 | =head2 @policies = $lb->describe_load_balancer_policies; | ||
| 261 | |||
| 262 | =head1 STRING OVERLOADING | ||
| 263 | |||
| 264 | When used in a string context, this object will interpolate the | ||
| 265 | Elastic Load Balancer Name. | ||
| 266 | |||
| 267 | =head1 SEE ALSO | ||
| 268 | |||
| 269 | L<VM::EC2> | ||
| 270 | L<VM::EC2::Generic> | ||
| 271 | L<VM::EC2::ELB::HealthCheck> | ||
| 272 | L<VM::EC2::ELB::ListenerDescription> | ||
| 273 | L<VM::EC2::ELB::BackendServerDescription> | ||
| 274 | L<VM::EC2::ELB::Policies> | ||
| 275 | |||
| 276 | =head1 AUTHOR | ||
| 277 | |||
| 278 | Lance Kinley E<lt>lkinley@loyaltymethods.comE<gt>. | ||
| 279 | |||
| 280 | Copyright (c) 2012-2014 Loyalty Methods, Inc. | ||
| 281 | |||
| 282 | This package and its accompanying libraries is free software; you can | ||
| 283 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 284 | version 1, or at your option, any later version) or the Artistic | ||
| 285 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 286 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 287 | |||
| 288 | =cut | ||
| 289 | |||
| 290 | |||
| 291 | use strict; | ||
| 292 | use base 'VM::EC2::Generic'; | ||
| 293 | use VM::EC2::ELB::HealthCheck; | ||
| 294 | use VM::EC2::ELB::ListenerDescription; | ||
| 295 | use VM::EC2::ELB::BackendServerDescription; | ||
| 296 | use VM::EC2::ELB::Policies; | ||
| 297 | |||
| 298 | use overload | ||
| 299 | '""' => sub { | ||
| 300 | my $self = shift; | ||
| 301 | return $self->LoadBalancerName}, | ||
| 302 | fallback => 1; | ||
| 303 | |||
| 304 | sub valid_fields { | ||
| 305 | my $self = shift; | ||
| 306 | return qw(AvailabilityZones BackendServerDescriptions CanonicalHostedZoneName CanonicalHostedZoneNameID CreatedTime DNSName HealthCheck Instances ListenerDescriptions LoadBalancerName Policies Scheme SecurityGroups SourceSecurityGroup Subnets VPCId); | ||
| 307 | } | ||
| 308 | |||
| 309 | # object methods | ||
| 310 | |||
| 311 | sub AvailabilityZones { | ||
| 312 | my $self = shift; | ||
| 313 | my $zones = $self->SUPER::AvailabilityZones or return; | ||
| 314 | return $self->aws->describe_availability_zones(@{$zones->{member}}); | ||
| 315 | } | ||
| 316 | |||
| 317 | sub BackendServerDescriptions { | ||
| 318 | my $self = shift; | ||
| 319 | my $descs = $self->SUPER::BackendServerDescriptions or return; | ||
| 320 | return map { VM::EC2::ELB::BackendServerDescription->new($_,$self->aws) } @{$descs->{member}}; | ||
| 321 | } | ||
| 322 | |||
| 323 | sub HealthCheck { | ||
| 324 | my $self = shift; | ||
| 325 | my $hc = $self->SUPER::HealthCheck or return; | ||
| 326 | return VM::EC2::ELB::HealthCheck->new($hc,$self->aws); | ||
| 327 | } | ||
| 328 | |||
| 329 | sub Instances { | ||
| 330 | my $self = shift; | ||
| 331 | my $instances = $self->SUPER::Instances or return; | ||
| 332 | my @i = map { $_->{InstanceId} } @{$instances->{member}}; | ||
| 333 | return $self->aws->describe_instances(@i); | ||
| 334 | } | ||
| 335 | |||
| 336 | sub ListenerDescriptions { | ||
| 337 | my $self = shift; | ||
| 338 | my $listener_descs = $self->SUPER::ListenerDescriptions or return; | ||
| 339 | return map { VM::EC2::ELB::ListenerDescription->new($_,$self->aws) } @{$listener_descs->{member}}; | ||
| 340 | } | ||
| 341 | |||
| 342 | sub Policies { | ||
| 343 | my $self = shift; | ||
| 344 | my $policies = $self->SUPER::Policies or return; | ||
| 345 | return VM::EC2::ELB::Policies->new($policies,$self->aws); | ||
| 346 | } | ||
| 347 | |||
| 348 | sub SecurityGroups { | ||
| 349 | my $self = shift; | ||
| 350 | my $sg = $self->SUPER::SecurityGroups or return; | ||
| 351 | return $self->aws->describe_security_groups(@{$sg->{member}}); | ||
| 352 | } | ||
| 353 | |||
| 354 | sub SourceSecurityGroup { | ||
| 355 | my $self = shift; | ||
| 356 | my $ssg = $self->SUPER::SourceSecurityGroup or return; | ||
| 357 | return $ssg->{OwnerAlias} . '/' . $ssg->{GroupName}; | ||
| 358 | } | ||
| 359 | |||
| 360 | sub Subnets { | ||
| 361 | my $self = shift; | ||
| 362 | my $sn = $self->SUPER::Subnets or return; | ||
| 363 | return $self->aws->describe_subnets(@{$sn->{member}}); | ||
| 364 | } | ||
| 365 | |||
| 366 | # convenience methods | ||
| 367 | |||
| 368 | sub listeners { | ||
| 369 | my $self = shift; | ||
| 370 | return map { $_->Listener } $self->ListenerDescriptions; | ||
| 371 | } | ||
| 372 | |||
| 373 | sub active_policies { | ||
| 374 | my $self = shift; | ||
| 375 | my @policies; | ||
| 376 | foreach ($self->ListenerDescriptions) { | ||
| 377 | push @policies,$_->PolicyNames; | ||
| 378 | } | ||
| 379 | my @p = keys %{{ map { $_ => 1 } @policies }}; | ||
| 380 | return $self->aws->describe_load_balancer_policies(-load_balancer_name=>$self->LoadBalancerName,-policy_names=>\@p); | ||
| 381 | } | ||
| 382 | |||
| 383 | sub all_policies { | ||
| 384 | my $self = shift; | ||
| 385 | return $self->aws->describe_load_balancer_policies(-load_balancer_name=>$self->LoadBalancerName); | ||
| 386 | } | ||
| 387 | |||
| 388 | sub delete_load_balancer { | ||
| 389 | my $self = shift; | ||
| 390 | return $self->aws->delete_load_balancer($self->LoadBalancerName); | ||
| 391 | } | ||
| 392 | |||
| 393 | sub delete { shift->delete_load_balancer } | ||
| 394 | |||
| 395 | sub configure_health_check { | ||
| 396 | my $self = shift; | ||
| 397 | my %args = @_; | ||
| 398 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 399 | return $self->aws->configure_health_check(%args); | ||
| 400 | } | ||
| 401 | |||
| 402 | sub create_app_cookie_stickiness_policy { | ||
| 403 | my $self = shift; | ||
| 404 | my %args = @_; | ||
| 405 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 406 | return $self->aws->create_app_cookie_stickiness_policy(%args); | ||
| 407 | } | ||
| 408 | |||
| 409 | sub create_lb_cookie_stickiness_policy { | ||
| 410 | my $self = shift; | ||
| 411 | my %args = @_; | ||
| 412 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 413 | return $self->aws->create_lb_cookie_stickiness_policy(%args); | ||
| 414 | } | ||
| 415 | |||
| 416 | sub create_load_balancer_listeners { | ||
| 417 | my $self = shift; | ||
| 418 | my %args = @_; | ||
| 419 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 420 | return $self->aws->create_load_balancer_listeners(%args); | ||
| 421 | } | ||
| 422 | |||
| 423 | sub create_listeners { shift->create_load_balancer_listeners(@_) } | ||
| 424 | |||
| 425 | sub delete_load_balancer_listeners { | ||
| 426 | my $self = shift; | ||
| 427 | my %args = $self->args('-load_balancer_ports',@_); | ||
| 428 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 429 | return $self->aws->delete_load_balancer_listeners(%args); | ||
| 430 | } | ||
| 431 | |||
| 432 | sub delete_listeners { shift->delete_load_balancer_listeners(@_) } | ||
| 433 | |||
| 434 | sub disable_availability_zones_for_load_balancer { | ||
| 435 | my $self = shift; | ||
| 436 | my %args = $self->args('-availability_zones',@_); | ||
| 437 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 438 | return $self->aws->disable_availability_zones_for_load_balancer(%args); | ||
| 439 | } | ||
| 440 | |||
| 441 | sub disable_availability_zones { shift->disable_availability_zones_for_load_balancer(@_) } | ||
| 442 | sub disable_zones { shift->disable_availability_zones_for_load_balancer(@_) } | ||
| 443 | |||
| 444 | sub enable_availability_zones_for_load_balancer { | ||
| 445 | my $self = shift; | ||
| 446 | my %args = $self->args('-availability_zones',@_); | ||
| 447 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 448 | return $self->aws->enable_availability_zones_for_load_balancer(%args); | ||
| 449 | } | ||
| 450 | |||
| 451 | sub enable_availability_zones { shift->enable_availability_zones_for_load_balancer(@_) } | ||
| 452 | sub enable_zones { shift->enable_availability_zones_for_load_balancer(@_) } | ||
| 453 | |||
| 454 | sub register_instances_with_load_balancer { | ||
| 455 | my $self = shift; | ||
| 456 | my %args = $self->args('-instances',@_); | ||
| 457 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 458 | return $self->aws->register_instances_with_load_balancer(%args); | ||
| 459 | } | ||
| 460 | |||
| 461 | sub register_instances { shift->register_instances_with_load_balancer(@_) } | ||
| 462 | |||
| 463 | sub deregister_instances_from_load_balancer { | ||
| 464 | my $self = shift; | ||
| 465 | my %args = $self->args('-instances',@_); | ||
| 466 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 467 | return $self->aws->deregister_instances_from_load_balancer(%args); | ||
| 468 | } | ||
| 469 | |||
| 470 | sub deregister_instances { shift->deregister_instances_from_load_balancer(@_) } | ||
| 471 | |||
| 472 | sub set_load_balancer_listener_ssl_certificate { | ||
| 473 | my $self = shift; | ||
| 474 | my %args = @_; | ||
| 475 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 476 | return $self->aws->set_load_balancer_listener_ssl_certificate(%args); | ||
| 477 | } | ||
| 478 | |||
| 479 | sub set_listener_ssl_certificate { shift->set_load_balancer_listener_ssl_certificate(@_) } | ||
| 480 | sub set_ssl_certificate { shift->set_load_balancer_listener_ssl_certificate(@_) } | ||
| 481 | |||
| 482 | sub describe_instance_health { | ||
| 483 | my $self = shift; | ||
| 484 | my %args = $self->args('-instances',@_); | ||
| 485 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 486 | return $self->aws->describe_instance_health(%args); | ||
| 487 | } | ||
| 488 | |||
| 489 | sub create_load_balancer_policy { | ||
| 490 | my $self = shift; | ||
| 491 | my %args = @_; | ||
| 492 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 493 | return $self->aws->create_load_balancer_policy(%args); | ||
| 494 | } | ||
| 495 | |||
| 496 | sub create_policy { shift->create_load_balancer_policy(@_) } | ||
| 497 | |||
| 498 | sub delete_load_balancer_policy { | ||
| 499 | my $self = shift; | ||
| 500 | my %args = $self->args('-policy_name',@_); | ||
| 501 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 502 | return $self->aws->delete_load_balancer_policy(%args); | ||
| 503 | } | ||
| 504 | |||
| 505 | sub delete_policy { shift->delete_load_balancer_policy(@_) } | ||
| 506 | |||
| 507 | sub describe_load_balancer_policies { | ||
| 508 | my $self = shift; | ||
| 509 | my %args = $self->args('-policy_names',@_); | ||
| 510 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 511 | return $self->aws->describe_load_balancer_policies(%args); | ||
| 512 | } | ||
| 513 | |||
| 514 | sub describe_policies { shift->describe_load_balancer_policies(@_) } | ||
| 515 | |||
| 516 | sub set_load_balancer_policies_of_listener { | ||
| 517 | my $self = shift; | ||
| 518 | my %args = @_; | ||
| 519 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 520 | return $self->aws->set_load_balancer_policies_of_listener(%args); | ||
| 521 | } | ||
| 522 | |||
| 523 | sub set_policies_of_listener { shift->set_load_balancer_policies_of_listener(@_) } | ||
| 524 | sub set_policies { shift->set_load_balancer_policies_of_listener(@_) } | ||
| 525 | |||
| 526 | sub apply_security_groups_to_load_balancer { | ||
| 527 | my $self = shift; | ||
| 528 | my %args = $self->args('-security_groups',@_); | ||
| 529 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 530 | return $self->aws->apply_security_groups_to_load_balancer(%args); | ||
| 531 | } | ||
| 532 | |||
| 533 | sub apply_security_groups { shift->apply_security_groups_to_load_balancer(@_) } | ||
| 534 | |||
| 535 | sub attach_load_balancer_to_subnets { | ||
| 536 | my $self = shift; | ||
| 537 | my %args = $self->args('-subnets',@_); | ||
| 538 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 539 | return $self->aws->attach_load_balancer_to_subnets(%args); | ||
| 540 | } | ||
| 541 | |||
| 542 | sub attach_to_subnets { shift->attach_load_balancer_to_subnets(@_) } | ||
| 543 | |||
| 544 | sub detach_load_balancer_from_subnets { | ||
| 545 | my $self = shift; | ||
| 546 | my %args = $self->args('-subnets',@_); | ||
| 547 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 548 | return $self->aws->detach_load_balancer_from_subnets(%args); | ||
| 549 | } | ||
| 550 | |||
| 551 | sub detach_from_subnets { shift->detach_load_balancer_from_subnets(@_) } | ||
| 552 | |||
| 553 | sub set_load_balancer_policies_for_backend_server { | ||
| 554 | my $self = shift; | ||
| 555 | my %args = @_; | ||
| 556 | $args{-load_balancer_name} = $self->LoadBalancerName; | ||
| 557 | return $self->aws->set_load_balancer_policies_for_backend_server(%args); | ||
| 558 | } | ||
| 559 | |||
| 560 | sub set_policies_for_backend_server { shift->set_load_balancer_policies_for_backend_server(@_) } | ||
| 561 | |||
| 562 | sub args { | ||
| 563 | my $self = shift; | ||
| 564 | my $default_param_name = shift; | ||
| 565 | return unless @_; | ||
| 566 | return @_ if $_[0] =~ /^-/; | ||
| 567 | return ($default_param_name => \@_); | ||
| 568 | } | ||
| 569 | |||
| 570 | # the following functions override Generic | ||
| 571 | sub add_tags { | ||
| 572 | my $self = shift; | ||
| 573 | my $tags = ref $_[0] && ref $_[0] eq 'HASH' ? shift : {@_}; | ||
| 574 | return $self->aws->add_load_balancer_tags(-load_balancer_names => $self->LoadBalancerName, -tags => $tags); | ||
| 575 | } | ||
| 576 | |||
| 577 | sub tags { | ||
| 578 | my $self = shift; | ||
| 579 | my $tags = $self->aws->describe_load_balancer_tags(-load_balancer_names => $self->LoadBalancerName); | ||
| 580 | return $tags->{$self->LoadBalancerName}; | ||
| 581 | } | ||
| 582 | |||
| 583 | sub delete_tags { | ||
| 584 | my $self = shift; | ||
| 585 | my $tags = shift; | ||
| 586 | return $self->aws->remove_load_balancer_tags(-load_balancer_names => $self->LoadBalancerName, -tags => $tags); | ||
| 587 | } | ||
| 588 | |||
| 589 | |||
| 590 | 1; |