| 1 | package VM::EC2::REST::elastic_load_balancer; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use VM::EC2 ''; # important not to import anything! | ||
| 5 | package VM::EC2; # add methods to VM::EC2 | ||
| 6 | require VM::EC2::ELB::ParmParser; | ||
| 7 | |||
| 8 | VM::EC2::Dispatch->register( | ||
| 9 | AddTags => sub { exists shift->{AddTagsResult} }, | ||
| 10 | ApplySecurityGroupsToLoadBalancer => 'elb_member_list,SecurityGroups', | ||
| 11 | AttachLoadBalancerToSubnets => 'elb_member_list,Subnets', | ||
| 12 | ConfigureHealthCheck => 'fetch_one_result,HealthCheck,VM::EC2::ELB::HealthCheck', | ||
| 13 | CreateAppCookieStickinessPolicy => sub { exists shift->{CreateAppCookieStickinessPolicyResult} }, | ||
| 14 | CreateLBCookieStickinessPolicy => sub { exists shift->{CreateLBCookieStickinessPolicyResult} }, | ||
| 15 | CreateLoadBalancer => sub { shift->{CreateLoadBalancerResult}{DNSName} }, | ||
| 16 | CreateLoadBalancerListeners => sub { exists shift->{CreateLoadBalancerListenersResult} }, | ||
| 17 | CreateLoadBalancerPolicy => sub { exists shift->{CreateLoadBalancerPolicyResult} }, | ||
| 18 | DeleteLoadBalancer => sub { exists shift->{DeleteLoadBalancerResult} }, | ||
| 19 | DeleteLoadBalancerListeners => sub { exists shift->{DeleteLoadBalancerListenersResult} }, | ||
| 20 | DeleteLoadBalancerPolicy => sub { exists shift->{DeleteLoadBalancerPolicyResult} }, | ||
| 21 | DeregisterInstancesFromLoadBalancer => 'elb_member_list,Instances,InstanceId', | ||
| 22 | DescribeInstanceHealth => 'fetch_members,InstanceStates,VM::EC2::ELB::InstanceState', | ||
| 23 | DescribeLoadBalancerAttributes => 'fetch_one_result,LoadBalancerAttributes,VM::EC2::ELB::Attributes', | ||
| 24 | DescribeLoadBalancerPolicies => 'fetch_members,PolicyDescriptions,VM::EC2::ELB::PolicyDescription', | ||
| 25 | DescribeLoadBalancerPolicyTypes => 'fetch_members,PolicyTypeDescriptions,VM::EC2::ELB::PolicyTypeDescription', | ||
| 26 | DescribeLoadBalancers => 'fetch_members,LoadBalancerDescriptions,VM::EC2::ELB', | ||
| 27 | DescribeTags => 'fetch_members,TagDescriptions,VM::EC2::ELB::TagDescription', | ||
| 28 | DetachLoadBalancerFromSubnets => 'elb_member_list,Subnets', | ||
| 29 | DisableAvailabilityZonesForLoadBalancer => | ||
| 30 | 'elb_member_list,AvailabilityZones', | ||
| 31 | EnableAvailabilityZonesForLoadBalancer => | ||
| 32 | 'elb_member_list,AvailabilityZones', | ||
| 33 | ModifyLoadBalancerAttributes => 'fetch_one_result,LoadBalancerAttributes,VM::EC2::ELB::Attributes', | ||
| 34 | RegisterInstancesWithLoadBalancer => 'elb_member_list,Instances,InstanceId', | ||
| 35 | SetLoadBalancerListenerSSLCertificate => | ||
| 36 | sub { exists shift->{SetLoadBalancerListenerSSLCertificateResult} }, | ||
| 37 | SetLoadBalancerPoliciesForBackendServer => | ||
| 38 | sub { exists shift->{SetLoadBalancerPoliciesForBackendServerResult} }, | ||
| 39 | SetLoadBalancerPoliciesOfListener => sub { exists shift->{SetLoadBalancerPoliciesOfListenerResult} }, | ||
| 40 | ); | ||
| 41 | |||
| 42 | sub elb_call { | ||
| 43 | my $self = shift; | ||
| 44 | (my $endpoint = $self->{endpoint}) =~ s/ec2/elasticloadbalancing/; | ||
| 45 | local $self->{endpoint} = $endpoint; | ||
| 46 | local $self->{version} = '2012-06-01'; | ||
| 47 | $self->call(@_); | ||
| 48 | } | ||
| 49 | |||
| 50 | my $VEP = 'VM::EC2::ELB::ParmParser'; | ||
| 51 | |||
| 52 | =head1 NAME VM::EC2::REST::elastic_load_balancer | ||
| 53 | |||
| 54 | =head1 SYNOPSIS | ||
| 55 | |||
| 56 | use VM::EC2 ':elb'; | ||
| 57 | |||
| 58 | =head1 METHODS | ||
| 59 | |||
| 60 | The methods in this module allow you to retrieve information about | ||
| 61 | Elastic Load Balancers, create new ELBs, and change the properties of | ||
| 62 | the ELBs. | ||
| 63 | |||
| 64 | Implemented: | ||
| 65 | AddTags | ||
| 66 | ApplySecurityGroupsToLoadBalancer | ||
| 67 | AttachLoadBalancerToSubnets | ||
| 68 | ConfigureHealthCheck | ||
| 69 | CreateAppCookieStickinessPolicy | ||
| 70 | CreateLBCookieStickinessPolicy | ||
| 71 | CreateLoadBalancer | ||
| 72 | CreateLoadBalancerListeners | ||
| 73 | CreateLoadBalancerPolicy | ||
| 74 | DeleteLoadBalancer | ||
| 75 | DeleteLoadBalancerListeners | ||
| 76 | DeleteLoadBalancerPolicy | ||
| 77 | DeregisterInstancesFromLoadBalancer | ||
| 78 | DescribeInstanceHealth | ||
| 79 | DescribeLoadBalancerAttributes | ||
| 80 | DescribeLoadBalancerPolicies | ||
| 81 | DescribeLoadBalancerPolicyTypes | ||
| 82 | DescribeLoadBalancers | ||
| 83 | DescribeTags | ||
| 84 | DetachLoadBalancerFromSubnets | ||
| 85 | DisableAvailabilityZonesForLoadBalancer | ||
| 86 | EnableAvailabilityZonesForLoadBalancer | ||
| 87 | ModifyLoadBalancerAttributes | ||
| 88 | RegisterInstancesWithLoadBalancer | ||
| 89 | RemoveTags | ||
| 90 | SetLoadBalancerListenerSSLCertificate | ||
| 91 | SetLoadBalancerPoliciesForBackendServer | ||
| 92 | SetLoadBalancerPoliciesOfListener | ||
| 93 | |||
| 94 | Unimplemented: | ||
| 95 | (none) | ||
| 96 | |||
| 97 | The primary object manipulated by these methods is | ||
| 98 | L<VM::EC2::ELB>. Please see the L<VM::EC2::ELB> manual page | ||
| 99 | |||
| 100 | =head2 $success = $ec2->tag_load_balancer(-load_balancer_names => $name, -tags => { key => value, [key2 => value2], ... }) | ||
| 101 | |||
| 102 | Adds one or more tags for the specified load balancer. Each load balancer can | ||
| 103 | have a maximum of 10 tags. Each tag consists of a key and an optional value. | ||
| 104 | |||
| 105 | Tag keys must be unique for each load balancer. | ||
| 106 | If a tag with the same key is already associated with the load balancer, this | ||
| 107 | action will update the value of the key. | ||
| 108 | |||
| 109 | Arguments: | ||
| 110 | |||
| 111 | -load_balancer_names The name of the load balancer to tag. You can specify a | ||
| 112 | maximum of one load balancer name. | ||
| 113 | |||
| 114 | -tags Hashref of tag key/value pairs. | ||
| 115 | |||
| 116 | Returns true on success. | ||
| 117 | |||
| 118 | =cut | ||
| 119 | |||
| 120 | sub add_load_balancer_tags { | ||
| 121 | my $self = shift; | ||
| 122 | my %args = $self->args('-tags',@_); | ||
| 123 | $args{'-load_balancer_names'} ||= $args{-lb_name}; | ||
| 124 | $args{'-load_balancer_names'} ||= $args{-lb_names}; | ||
| 125 | $args{'-load_balancer_names'} ||= $args{-load_balancer_name}; | ||
| 126 | $args{'-load_balancer_names'} || | ||
| 127 | croak "describe_load_balancer_tags(): -load_balancer_names argument missing"; | ||
| 128 | my @params = $VEP->format_parms(\%args, | ||
| 129 | { | ||
| 130 | member_list_parm => 'LoadBalancerNames', | ||
| 131 | member_key_value_parm => 'Tags', | ||
| 132 | }); | ||
| 133 | return $self->elb_call('AddTags',@params); | ||
| 134 | } | ||
| 135 | |||
| 136 | =head2 %tags = $ec2->describe_load_balancer_tags(-load_balancer_name=>\@names) | ||
| 137 | |||
| 138 | =head2 %tags = $ec2->describe_load_balancer_tags(@names) | ||
| 139 | |||
| 140 | Describes the tags associated with one or more load balancers. | ||
| 141 | |||
| 142 | Arguments: | ||
| 143 | |||
| 144 | -load_balancer_names The name of the load balancers to retrieve tags for. | ||
| 145 | |||
| 146 | Returns a hash of hashes in this format: | ||
| 147 | |||
| 148 | { | ||
| 149 | 'LBName' => | ||
| 150 | { | ||
| 151 | TagName => TagValue, | ||
| 152 | TagName => TagValue, | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | =cut | ||
| 157 | |||
| 158 | sub describe_load_balancer_tags { | ||
| 159 | my $self = shift; | ||
| 160 | my %args = $self->args('-load_balancer_names',@_); | ||
| 161 | $args{'-load_balancer_names'} ||= $args{-lb_name}; | ||
| 162 | $args{'-load_balancer_names'} ||= $args{-lb_names}; | ||
| 163 | $args{'-load_balancer_names'} ||= $args{-load_balancer_name}; | ||
| 164 | $args{'-load_balancer_names'} || | ||
| 165 | croak "describe_load_balancer_tags(): -load_balancer_names argument missing"; | ||
| 166 | my @params = $VEP->format_parms(\%args, | ||
| 167 | { | ||
| 168 | member_list_parm => 'LoadBalancerNames', | ||
| 169 | }); | ||
| 170 | my @tag_descs = $self->elb_call('DescribeTags',@params); | ||
| 171 | my %tags; | ||
| 172 | foreach my $desc (@tag_descs) { | ||
| 173 | $tags{$desc->LoadBalancerName} = $desc->Tags; | ||
| 174 | } | ||
| 175 | return wantarray ? %tags : \%tags; | ||
| 176 | } | ||
| 177 | |||
| 178 | =head2 $success = $ec2->remove_load_balancer_tags(-load_balancer_names => $name, -tags => [ name1,[name2,name3,...] ]) | ||
| 179 | |||
| 180 | =head2 $success = $ec2->remove_load_balancer_tags(-load_balancer_names => $name, -tags => $tag) | ||
| 181 | |||
| 182 | =cut | ||
| 183 | |||
| 184 | sub remove_load_balancer_tags { | ||
| 185 | my $self = shift; | ||
| 186 | my %args = $self->args('-load_balancer_names',@_); | ||
| 187 | $args{'-load_balancer_names'} ||= $args{-lb_name}; | ||
| 188 | $args{'-load_balancer_names'} ||= $args{-lb_names}; | ||
| 189 | $args{'-load_balancer_names'} ||= $args{-load_balancer_name}; | ||
| 190 | $args{'-load_balancer_names'} || | ||
| 191 | croak "remove_load_balancer_tags(): -load_balancer_names argument missing"; | ||
| 192 | $args{-tags} || | ||
| 193 | croak "remove_load_balancer_tags(): -tags argument missing"; | ||
| 194 | my $tags = $args{-tags}; | ||
| 195 | my @tags = ref $tags eq 'ARRAY' ? @$tags : ($tags); | ||
| 196 | my @taglist; | ||
| 197 | push @taglist, { Key => $_ } foreach @tags; | ||
| 198 | $args{-tags} = \@taglist; | ||
| 199 | my @params = $VEP->format_parms(\%args, | ||
| 200 | { | ||
| 201 | member_list_parm => 'LoadBalancerNames', | ||
| 202 | member_hash_parm => 'Tags', | ||
| 203 | }); | ||
| 204 | return $self->elb_call('RemoveTags',@params); | ||
| 205 | } | ||
| 206 | |||
| 207 | =head2 $attrs = $ec2->describe_load_balancer_attributes(-load_balancer_name => $name) | ||
| 208 | |||
| 209 | Returns detailed information about all of the attributes associated with the | ||
| 210 | specified load balancer. | ||
| 211 | |||
| 212 | Arguments: | ||
| 213 | |||
| 214 | -load_balancer_name Name of the ELB to return information on. | ||
| 215 | |||
| 216 | Returns a L<VM::EC2::ELB::Attributes> object. | ||
| 217 | |||
| 218 | =cut | ||
| 219 | |||
| 220 | sub describe_load_balancer_attributes { | ||
| 221 | my $self = shift; | ||
| 222 | my %args = $self->args('-load_balancer_name',@_); | ||
| 223 | $args{'-load_balancer_name'} ||= $args{-lb_name}; | ||
| 224 | $args{'-load_balancer_name'} ||= $args{-lb_names}; | ||
| 225 | $args{'-load_balancer_name'} ||= $args{-load_balancer_names}; | ||
| 226 | $args{'-load_balancer_name'} || | ||
| 227 | croak "describe_load_balancer_attributes(): -load_balancer_name argument missing"; | ||
| 228 | my @params = $VEP->format_parms(\%args, | ||
| 229 | { | ||
| 230 | single_parm => 'LoadBalancerName', | ||
| 231 | }); | ||
| 232 | return $self->elb_call('DescribeLoadBalancerAttributes',@params); | ||
| 233 | } | ||
| 234 | |||
| 235 | =head2 $attr = $ec2->modify_load_balancer_attributes(%args) | ||
| 236 | |||
| 237 | Modifies the attributes of a specified load balancer. | ||
| 238 | |||
| 239 | Arguments: | ||
| 240 | |||
| 241 | -load_balancer_name Name of the ELB to change attributes on. (Required) | ||
| 242 | |||
| 243 | One or more of the following arguments are required: | ||
| 244 | |||
| 245 | -access_log A hashref of attribute values for AccessLog | ||
| 246 | ex: -access_log => { Enabled => 'false' } | ||
| 247 | |||
| 248 | -connection_draining A hashref of attribute values for ConnectionDraining | ||
| 249 | ex: -connection_draining => { Enabled => 'false' } | ||
| 250 | |||
| 251 | -connection_settings A hashref of attribute values for ConnectionSettings | ||
| 252 | ex: -connection_settings => { IdleTimeout => 30 } | ||
| 253 | |||
| 254 | -cross_zone_load_balancing A hashref of attribute values for | ||
| 255 | CrossZoneLoadBalancing. ex: | ||
| 256 | -cross_zone_load_balancing => { Enabled => 'true' } | ||
| 257 | |||
| 258 | Returns a L<VM::EC2::ELB::Attributes> object. | ||
| 259 | |||
| 260 | =cut | ||
| 261 | |||
| 262 | sub modify_load_balancer_attributes { | ||
| 263 | my $self = shift; | ||
| 264 | my %args = $self->args('-load_balancer_name',@_); | ||
| 265 | $args{'-load_balancer_name'} ||= $args{-lb_name}; | ||
| 266 | $args{'-load_balancer_name'} ||= $args{-lb_names}; | ||
| 267 | $args{'-load_balancer_name'} ||= $args{-load_balancer_names}; | ||
| 268 | $args{'-load_balancer_name'} or | ||
| 269 | croak "modify_load_balancer_attributes(): -load_balancer_name argument missing"; | ||
| 270 | ($args{-access_log} || $args{-connection_draining} || | ||
| 271 | $args{-connection_settings} || $args{-cross_zone_load_balancing}) or | ||
| 272 | croak "modify_load_balancer_attributes(): missing attribute parameter"; | ||
| 273 | my @params = $VEP->format_parms(\%args, | ||
| 274 | { | ||
| 275 | single_parm => 'LoadBalancerName', | ||
| 276 | elb_attr_parm => [qw(AccessLog ConnectionDraining | ||
| 277 | ConnectionSettings | ||
| 278 | CrossZoneLoadBalancing)], | ||
| 279 | }); | ||
| 280 | return $self->elb_call('ModifyLoadBalancerAttributes',@params); | ||
| 281 | } | ||
| 282 | |||
| 283 | =head2 @lbs = $ec2->describe_load_balancers(-load_balancer_name=>\@names) | ||
| 284 | |||
| 285 | =head2 @lbs = $ec2->describe_load_balancers(@names) | ||
| 286 | |||
| 287 | Provides detailed configuration information for the specified ELB(s). | ||
| 288 | |||
| 289 | Optional parameters are: | ||
| 290 | |||
| 291 | -load_balancer_names Name of the ELB to return information on. | ||
| 292 | This can be a string scalar, or an arrayref. | ||
| 293 | |||
| 294 | -lb_name,-lb_names, | ||
| 295 | -load_balancer_name Aliases for -load_balancer_names | ||
| 296 | |||
| 297 | Returns a series of L<VM::EC2::ELB> objects. | ||
| 298 | |||
| 299 | =cut | ||
| 300 | |||
| 301 | sub describe_load_balancers { | ||
| 302 | my $self = shift; | ||
| 303 | my %args = $self->args('-load_balancer_names',@_); | ||
| 304 | $args{'-load_balancer_names'} ||= $args{-lb_name}; | ||
| 305 | $args{'-load_balancer_names'} ||= $args{-lb_names}; | ||
| 306 | $args{'-load_balancer_names'} ||= $args{-load_balancer_name}; | ||
| 307 | my @params = $VEP->format_parms(\%args, | ||
| 308 | { | ||
| 309 | member_list_parm => 'LoadBalancerNames', | ||
| 310 | }); | ||
| 311 | return $self->elb_call('DescribeLoadBalancers',@params); | ||
| 312 | } | ||
| 313 | |||
| 314 | =head2 $success = $ec2->delete_load_balancer(-load_balancer_name=>$name) | ||
| 315 | |||
| 316 | =head2 $success = $ec2->delete_load_balancer($name) | ||
| 317 | |||
| 318 | Deletes the specified ELB. | ||
| 319 | |||
| 320 | Arguments: | ||
| 321 | |||
| 322 | -load_balancer_name -- The name of the ELB to delete | ||
| 323 | |||
| 324 | -lb_name -- Alias for -load_balancer_name | ||
| 325 | |||
| 326 | Returns true on successful deletion. NOTE: This API call will return | ||
| 327 | success regardless of existence of the ELB. | ||
| 328 | |||
| 329 | =cut | ||
| 330 | |||
| 331 | sub delete_load_balancer { | ||
| 332 | my $self = shift; | ||
| 333 | my %args = $self->args('-load_balancer_name',@_); | ||
| 334 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 335 | $args{-load_balancer_name} or | ||
| 336 | croak "delete_load_balancer(): -load_balancer_name argument missing"; | ||
| 337 | my @params = $VEP->format_parms(\%args, | ||
| 338 | { | ||
| 339 | single_parm => 'LoadBalancerName', | ||
| 340 | }); | ||
| 341 | return $self->elb_call('DeleteLoadBalancer',@params); | ||
| 342 | } | ||
| 343 | |||
| 344 | =head2 $healthcheck = $ec2->configure_health_check(-load_balancer_name => $name, | ||
| 345 | -healthy_threshold => $cnt, | ||
| 346 | -interval => $secs, | ||
| 347 | -target => $target, | ||
| 348 | -timeout => $secs, | ||
| 349 | -unhealthy_threshold => $cnt) | ||
| 350 | |||
| 351 | Defines an application healthcheck for the instances. | ||
| 352 | |||
| 353 | All Parameters are required. | ||
| 354 | |||
| 355 | -load_balancer_name Name of the ELB. | ||
| 356 | |||
| 357 | -healthy_threashold Specifies the number of consecutive health probe successes | ||
| 358 | required before moving the instance to the Healthy state. | ||
| 359 | |||
| 360 | -interval Specifies the approximate interval, in seconds, between | ||
| 361 | health checks of an individual instance. | ||
| 362 | |||
| 363 | -target Must be a string in the form: Protocol:Port[/PathToPing] | ||
| 364 | - Valid Protocol types are: HTTP, HTTPS, TCP, SSL | ||
| 365 | - Port must be in range 1-65535 | ||
| 366 | - PathToPing is only applicable to HTTP or HTTPS protocol | ||
| 367 | types and must be 1024 characters long or fewer. | ||
| 368 | |||
| 369 | -timeout Specifies the amount of time, in seconds, during which no | ||
| 370 | response means a failed health probe. | ||
| 371 | |||
| 372 | -unhealthy_threashold Specifies the number of consecutive health probe failures | ||
| 373 | required before moving the instance to the Unhealthy state. | ||
| 374 | |||
| 375 | -lb_name Alias for -load_balancer_name | ||
| 376 | |||
| 377 | Returns a L<VM::EC2::ELB::HealthCheck> object. | ||
| 378 | |||
| 379 | =cut | ||
| 380 | |||
| 381 | sub configure_health_check { | ||
| 382 | my $self = shift; | ||
| 383 | my %args = @_; | ||
| 384 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 385 | $args{-load_balancer_name} or | ||
| 386 | croak "configure_health_check(): -load_balancer_name argument missing"; | ||
| 387 | $args{-healthy_threshold} && $args{-interval} && | ||
| 388 | $args{-target} && $args{-timeout} && $args{-unhealthy_threshold} or | ||
| 389 | croak "configure_health_check(): healthcheck argument missing"; | ||
| 390 | my @params = $VEP->format_parms(\%args, | ||
| 391 | { | ||
| 392 | single_parm => 'LoadBalancerName', | ||
| 393 | 'HealthCheck.single_parm' => | ||
| 394 | [ qw(HealthyThreshold Interval Target | ||
| 395 | Timeout UnhealthyThreshold) | ||
| 396 | ], | ||
| 397 | }); | ||
| 398 | return $self->elb_call('ConfigureHealthCheck',@params); | ||
| 399 | } | ||
| 400 | |||
| 401 | =head2 $success = $ec2->create_app_cookie_stickiness_policy(-load_balancer_name => $name, | ||
| 402 | -cookie_name => $cookie, | ||
| 403 | -policy_name => $policy) | ||
| 404 | |||
| 405 | Generates a stickiness policy with sticky session lifetimes that follow that of | ||
| 406 | an application-generated cookie. This policy can be associated only with | ||
| 407 | HTTP/HTTPS listeners. | ||
| 408 | |||
| 409 | Required arguments: | ||
| 410 | |||
| 411 | -load_balancer_name Name of the ELB. | ||
| 412 | |||
| 413 | -cookie_name Name of the application cookie used for stickiness. | ||
| 414 | |||
| 415 | -policy_name The name of the policy being created. The name must | ||
| 416 | be unique within the set of policies for this ELB. | ||
| 417 | |||
| 418 | -lb_name Alias for -load_balancer_name | ||
| 419 | |||
| 420 | Returns true on successful execution. | ||
| 421 | |||
| 422 | =cut | ||
| 423 | |||
| 424 | sub create_app_cookie_stickiness_policy { | ||
| 425 | my $self = shift; | ||
| 426 | my %args = @_; | ||
| 427 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 428 | $args{-load_balancer_name} or | ||
| 429 | croak "create_app_cookie_stickiness_policy(): -load_balancer_name argument missing"; | ||
| 430 | $args{-cookie_name} && $args{-policy_name} or | ||
| 431 | croak "create_app_cookie_stickiness_policy(): -cookie_name or -policy_name option missing"; | ||
| 432 | my @params = $VEP->format_parms(\%args, | ||
| 433 | { | ||
| 434 | single_parm => [qw(LoadBalancerName CookieName PolicyName)], | ||
| 435 | }); | ||
| 436 | return $self->elb_call('CreateAppCookieStickinessPolicy',@params); | ||
| 437 | } | ||
| 438 | |||
| 439 | =head2 $success = $ec2->create_lb_cookie_stickiness_policy(-load_balancer_name => $name, | ||
| 440 | -cookie_expiration_period => $secs, | ||
| 441 | -policy_name => $policy) | ||
| 442 | |||
| 443 | Generates a stickiness policy with sticky session lifetimes controlled by the | ||
| 444 | lifetime of the browser (user-agent) or a specified expiration period. This | ||
| 445 | policy can be associated only with HTTP/HTTPS listeners. | ||
| 446 | |||
| 447 | Required arguments: | ||
| 448 | |||
| 449 | -load_balancer_name Name of the ELB. | ||
| 450 | |||
| 451 | -cookie_expiration_period The time period in seconds after which the | ||
| 452 | cookie should be considered stale. Not | ||
| 453 | specifying this parameter indicates that the | ||
| 454 | sticky session will last for the duration of | ||
| 455 | the browser session. OPTIONAL | ||
| 456 | |||
| 457 | -policy_name The name of the policy being created. The name | ||
| 458 | must be unique within the set of policies for | ||
| 459 | this ELB. | ||
| 460 | |||
| 461 | -lb_name Alias for -load_balancer_name | ||
| 462 | |||
| 463 | Returns true on successful execution. | ||
| 464 | |||
| 465 | =cut | ||
| 466 | |||
| 467 | sub create_lb_cookie_stickiness_policy { | ||
| 468 | my $self = shift; | ||
| 469 | my %args = @_; | ||
| 470 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 471 | $args{-load_balancer_name} or | ||
| 472 | croak "create_lb_cookie_stickiness_policy(): -load_balancer_name argument missing"; | ||
| 473 | $args{-cookie_expiration_period} && $args{-policy_name} or | ||
| 474 | croak "create_lb_cookie_stickiness_policy(): -cookie_expiration_period or -policy_name option missing"; | ||
| 475 | my @params = $VEP->format_parms(\%args, | ||
| 476 | { | ||
| 477 | single_parm => [qw(LoadBalancerName CookieExpirationPeriod PolicyName)], | ||
| 478 | }); | ||
| 479 | return $self->elb_call('CreateLBCookieStickinessPolicy',@params); | ||
| 480 | } | ||
| 481 | |||
| 482 | =head2 $lb = $ec2->create_load_balancer(-load_balancer_name => $name, | ||
| 483 | -listeners => \@listeners, | ||
| 484 | -availability_zones => \@zones, | ||
| 485 | -scheme => $scheme, | ||
| 486 | ) | ||
| 487 | |||
| 488 | Creates a new ELB. | ||
| 489 | |||
| 490 | Required arguments: | ||
| 491 | |||
| 492 | -load_balancer_name Name of the ELB. | ||
| 493 | |||
| 494 | -listeners Must either be a L<VM::EC2::ELB:Listener> object | ||
| 495 | (or arrayref of objects) or a hashref (or arrayref | ||
| 496 | of hashrefs) containing the following keys: | ||
| 497 | |||
| 498 | Protocol -- Value as one of: HTTP, HTTPS, TCP, or SSL | ||
| 499 | LoadBalancerPort -- Value in range 1-65535 | ||
| 500 | InstancePort -- Value in range 1-65535 | ||
| 501 | and optionally: | ||
| 502 | InstanceProtocol -- Value as one of: HTTP, HTTPS, TCP, or SSL | ||
| 503 | SSLCertificateId -- Certificate ID from AWS IAM certificate list | ||
| 504 | |||
| 505 | |||
| 506 | -availability_zones Literal string or array of strings containing valid | ||
| 507 | availability zones. Optional if subnets are | ||
| 508 | specified in a VPC usage scenario. | ||
| 509 | |||
| 510 | Optional arguments: | ||
| 511 | |||
| 512 | -scheme The type of ELB. By default, Elastic Load Balancing | ||
| 513 | creates an Internet-facing LoadBalancer with a | ||
| 514 | publicly resolvable DNS name, which resolves to | ||
| 515 | public IP addresses. Specify the value 'internal' | ||
| 516 | for this option to create an internal LoadBalancer | ||
| 517 | with a DNS name that resolves to private IP addresses. | ||
| 518 | This option is only available in a VPC. | ||
| 519 | |||
| 520 | -security_groups The security groups assigned to your ELB within your | ||
| 521 | VPC. String or arrayref. | ||
| 522 | |||
| 523 | -subnets A list of subnet IDs in your VPC to attach to your | ||
| 524 | ELB. String or arrayref. REQUIRED if availability | ||
| 525 | zones are not specified above. | ||
| 526 | |||
| 527 | -tags A list of tags to assign to the load balancer. | ||
| 528 | Hashref of tag key/value pairs. | ||
| 529 | ex: { Name => Value, Name => Value, ... } | ||
| 530 | |||
| 531 | Argument aliases: | ||
| 532 | |||
| 533 | -zones Alias for -availability_zones | ||
| 534 | -lb_name Alias for -load_balancer_name | ||
| 535 | |||
| 536 | Returns a L<VM::EC2::ELB> object if successful. | ||
| 537 | |||
| 538 | =cut | ||
| 539 | |||
| 540 | sub create_load_balancer { | ||
| 541 | my $self = shift; | ||
| 542 | my %args = @_; | ||
| 543 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 544 | $args{-availability_zones } ||= $args{-zones}; | ||
| 545 | $args{-load_balancer_name} or | ||
| 546 | croak "create_load_balancer(): -load_balancer_name argument missing"; | ||
| 547 | $args{-listeners} or | ||
| 548 | croak "create_load_balancer(): -listeners option missing"; | ||
| 549 | $args{-availability_zones} || $args{-subnets} or | ||
| 550 | croak "create_load_balancer(): -availability_zones option is required if subnets are not specified"; | ||
| 551 | my @params = $VEP->format_parms(\%args, | ||
| 552 | { | ||
| 553 | single_parm => [qw(LoadBalancerName Scheme)], | ||
| 554 | member_list_parm => [qw(AvailabilityZones SecurityGroups Subnets)], | ||
| 555 | elb_listeners_parm => 'Listeners', | ||
| 556 | member_key_value_parm => 'Tags', | ||
| 557 | }); | ||
| 558 | return unless $self->elb_call('CreateLoadBalancer',@params); | ||
| 559 | return eval { | ||
| 560 | my $elb; | ||
| 561 | local $SIG{ALRM} = sub {die "timeout"}; | ||
| 562 | alarm(60); | ||
| 563 | until ($elb = $self->describe_load_balancers($args{-load_balancer_name})) { sleep 1 } | ||
| 564 | alarm(0); | ||
| 565 | $elb; | ||
| 566 | }; | ||
| 567 | } | ||
| 568 | |||
| 569 | |||
| 570 | =head2 $success = $ec2->create_load_balancer_listeners(-load_balancer_name => $name, | ||
| 571 | -listeners => \@listeners) | ||
| 572 | |||
| 573 | Creates one or more listeners on a ELB for the specified port. If a listener | ||
| 574 | with the given port does not already exist, it will be created; otherwise, the | ||
| 575 | properties of the new listener must match the properties of the existing | ||
| 576 | listener. | ||
| 577 | |||
| 578 | -listeners Must either be a L<VM::EC2::ELB:Listener> object (or arrayref of | ||
| 579 | objects) or a hash (or arrayref of hashes) containing the | ||
| 580 | following keys: | ||
| 581 | |||
| 582 | Protocol -- Value as one of: HTTP, HTTPS, TCP, or SSL | ||
| 583 | LoadBalancerPort -- Value in range 1-65535 | ||
| 584 | InstancePort -- Value in range 1-65535 | ||
| 585 | and optionally: | ||
| 586 | InstanceProtocol -- Value as one of: HTTP, HTTPS, TCP, or SSL | ||
| 587 | SSLCertificateId -- Certificate ID from AWS IAM certificate list | ||
| 588 | |||
| 589 | -lb_name Alias for -load_balancer_name | ||
| 590 | |||
| 591 | Returns true on successful execution. | ||
| 592 | |||
| 593 | =cut | ||
| 594 | |||
| 595 | sub create_load_balancer_listeners { | ||
| 596 | my $self = shift; | ||
| 597 | my %args = @_; | ||
| 598 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 599 | $args{-load_balancer_name} or | ||
| 600 | croak "create_load_balancer_listeners(): -load_balancer_name argument missing"; | ||
| 601 | $args{-listeners} or | ||
| 602 | croak "create_load_balancer_listeners(): -listeners option missing"; | ||
| 603 | |||
| 604 | my @params = $VEP->format_parms(\%args, | ||
| 605 | { | ||
| 606 | single_parm => 'LoadBalancerName', | ||
| 607 | }); | ||
| 608 | push @params, $self->_listener_parm($args{-listeners}); | ||
| 609 | return $self->elb_call('CreateLoadBalancerListeners',@params); | ||
| 610 | } | ||
| 611 | |||
| 612 | =head2 $success = $ec2->delete_load_balancer_listeners(-load_balancer_name => $name, | ||
| 613 | -load_balancer_ports => \@ports) | ||
| 614 | |||
| 615 | Deletes listeners from the ELB for the specified port. | ||
| 616 | |||
| 617 | Arguments: | ||
| 618 | |||
| 619 | -load_balancer_name The name of the ELB | ||
| 620 | |||
| 621 | -load_balancer_ports An arrayref of strings or literal string containing | ||
| 622 | the port numbers. | ||
| 623 | |||
| 624 | -ports Alias for -load_balancer_ports | ||
| 625 | |||
| 626 | -lb_name Alias for -load_balancer_name | ||
| 627 | |||
| 628 | Returns true on successful execution. | ||
| 629 | |||
| 630 | =cut | ||
| 631 | |||
| 632 | sub delete_load_balancer_listeners { | ||
| 633 | my $self = shift; | ||
| 634 | my %args = @_; | ||
| 635 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 636 | $args{-load_balancer_ports} ||= $args{-ports}; | ||
| 637 | $args{-load_balancer_name} or | ||
| 638 | croak "delete_load_balancer_listeners(): -load_balancer_name argument missing"; | ||
| 639 | $args{-load_balancer_ports} or | ||
| 640 | croak "delete_load_balancer_listeners(): -load_balancer_ports argument missing"; | ||
| 641 | my @params = $VEP->format_parms(\%args, | ||
| 642 | { | ||
| 643 | single_parm => 'LoadBalancerName', | ||
| 644 | member_list_parm => 'LoadBalancerPorts', | ||
| 645 | }); | ||
| 646 | return $self->elb_call('DeleteLoadBalancerListeners',@params); | ||
| 647 | } | ||
| 648 | |||
| 649 | =head2 @z = $ec2->disable_availability_zones_for_load_balancer(-load_balancer_name => $name, | ||
| 650 | -availability_zones => \@zones) | ||
| 651 | |||
| 652 | Removes the specified EC2 Availability Zones from the set of configured | ||
| 653 | Availability Zones for the ELB. There must be at least one Availability Zone | ||
| 654 | registered with a LoadBalancer at all times. Instances registered with the ELB | ||
| 655 | that are in the removed Availability Zone go into the OutOfService state. | ||
| 656 | |||
| 657 | Arguments: | ||
| 658 | |||
| 659 | -load_balancer_name The name of the ELB | ||
| 660 | |||
| 661 | -availability_zones Arrayref or literal string of availability zone names | ||
| 662 | (ie. us-east-1a) | ||
| 663 | |||
| 664 | -zones Alias for -availability_zones | ||
| 665 | |||
| 666 | -lb_name Alias for -load_balancer_name | ||
| 667 | |||
| 668 | |||
| 669 | Returns an array of L<VM::EC2::AvailabilityZone> objects now associated with the ELB. | ||
| 670 | |||
| 671 | =cut | ||
| 672 | |||
| 673 | sub disable_availability_zones_for_load_balancer { | ||
| 674 | my $self = shift; | ||
| 675 | my %args = @_; | ||
| 676 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 677 | $args{-availability_zones} ||= $args{-zones}; | ||
| 678 | $args{-load_balancer_name} or | ||
| 679 | croak "disable_availability_zones_for_load_balancer(): -load_balancer_name argument missing"; | ||
| 680 | $args{-availability_zones} or | ||
| 681 | croak "disable_availability_zones_for_load_balancer(): -availability_zones argument missing"; | ||
| 682 | my @params = $VEP->format_parms(\%args, | ||
| 683 | { | ||
| 684 | single_parm => 'LoadBalancerName', | ||
| 685 | member_list_parm => 'AvailabilityZones', | ||
| 686 | }); | ||
| 687 | my @zones = $self->elb_call('DisableAvailabilityZonesForLoadBalancer',@params) or return; | ||
| 688 | return $self->describe_availability_zones(@zones); | ||
| 689 | } | ||
| 690 | |||
| 691 | =head2 @z = $ec2->enable_availability_zones_for_load_balancer(-load_balancer_name => $name, | ||
| 692 | -availability_zones => \@zones) | ||
| 693 | |||
| 694 | Adds one or more EC2 Availability Zones to the ELB. The ELB evenly distributes | ||
| 695 | requests across all its registered Availability Zones that contain instances. | ||
| 696 | |||
| 697 | Arguments: | ||
| 698 | |||
| 699 | -load_balancer_name The name of the ELB | ||
| 700 | |||
| 701 | -availability_zones Array or literal string of availability zone names | ||
| 702 | (ie. us-east-1a) | ||
| 703 | |||
| 704 | -zones Alias for -availability_zones | ||
| 705 | |||
| 706 | -lb_name Alias for -load_balancer_name | ||
| 707 | |||
| 708 | Returns an array of L<VM::EC2::AvailabilityZone> objects now associated with the ELB. | ||
| 709 | |||
| 710 | =cut | ||
| 711 | |||
| 712 | sub enable_availability_zones_for_load_balancer { | ||
| 713 | my $self = shift; | ||
| 714 | my %args = @_; | ||
| 715 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 716 | $args{-availability_zones} ||= $args{-zones}; | ||
| 717 | $args{-load_balancer_name} or | ||
| 718 | croak "enable_availability_zones_for_load_balancer(): -load_balancer_name argument missing"; | ||
| 719 | $args{-availability_zones} or | ||
| 720 | croak "enable_availability_zones_for_load_balancer(): -availability_zones argument missing"; | ||
| 721 | my @params = $VEP->format_parms(\%args, | ||
| 722 | { | ||
| 723 | single_parm => 'LoadBalancerName', | ||
| 724 | member_list_parm => 'AvailabilityZones', | ||
| 725 | }); | ||
| 726 | my @zones = $self->elb_call('EnableAvailabilityZonesForLoadBalancer',@params) or return; | ||
| 727 | return $self->describe_availability_zones(@zones); | ||
| 728 | } | ||
| 729 | |||
| 730 | =head2 @i = $ec2->register_instances_with_load_balancer(-load_balancer_name => $name, | ||
| 731 | -instances => \@instance_ids) | ||
| 732 | |||
| 733 | Adds new instances to the ELB. If the instance is in an availability zone that | ||
| 734 | is not registered with the ELB will be in the OutOfService state. Once the zone | ||
| 735 | is added to the ELB the instance will go into the InService state. | ||
| 736 | |||
| 737 | Arguments: | ||
| 738 | |||
| 739 | -load_balancer_name The name of the ELB | ||
| 740 | |||
| 741 | -instances An arrayref or literal string of Instance IDs. | ||
| 742 | |||
| 743 | -lb_name Alias for -load_balancer_name | ||
| 744 | |||
| 745 | Returns an array of instances now associated with the ELB in the form of | ||
| 746 | L<VM::EC2::Instance> objects. | ||
| 747 | |||
| 748 | =cut | ||
| 749 | |||
| 750 | sub register_instances_with_load_balancer { | ||
| 751 | my $self = shift; | ||
| 752 | my %args = @_; | ||
| 753 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 754 | $args{-instances} ||= $args{-instance_id}; | ||
| 755 | $args{-load_balancer_name} or | ||
| 756 | croak "register_instances_with_load_balancer(): -load_balancer_name argument missing"; | ||
| 757 | $args{-instances} or | ||
| 758 | croak "register_instances_with_load_balancer(): -instances argument missing"; | ||
| 759 | my @params = $VEP->format_parms(\%args, | ||
| 760 | { | ||
| 761 | single_parm => 'LoadBalancerName', | ||
| 762 | elb_instance_id_list => 'Instances', | ||
| 763 | }); | ||
| 764 | my @i = $self->elb_call('RegisterInstancesWithLoadBalancer',@params) or return; | ||
| 765 | return $self->describe_instances(@i); | ||
| 766 | } | ||
| 767 | |||
| 768 | =head2 @i = $ec2->deregister_instances_from_load_balancer(-load_balancer_name => $name, | ||
| 769 | -instances => \@instance_ids) | ||
| 770 | |||
| 771 | Deregisters instances from the ELB. Once the instance is deregistered, it will | ||
| 772 | stop receiving traffic from the ELB. | ||
| 773 | |||
| 774 | Arguments: | ||
| 775 | |||
| 776 | -load_balancer_name The name of the ELB | ||
| 777 | |||
| 778 | -instances An arrayref or literal string of Instance IDs. | ||
| 779 | |||
| 780 | -lb_name Alias for -load_balancer_name | ||
| 781 | |||
| 782 | Returns an array of instances now associated with the ELB in the form of | ||
| 783 | L<VM::EC2::Instance> objects. | ||
| 784 | |||
| 785 | =cut | ||
| 786 | |||
| 787 | sub deregister_instances_from_load_balancer { | ||
| 788 | my $self = shift; | ||
| 789 | my %args = @_; | ||
| 790 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 791 | $args{-instances} ||= $args{-instance_id}; | ||
| 792 | $args{-load_balancer_name} or | ||
| 793 | croak "deregister_instances_from_load_balancer(): -load_balancer_name argument missing"; | ||
| 794 | $args{-instances} or | ||
| 795 | croak "deregister_instances_from_load_balancer(): -instances argument missing"; | ||
| 796 | my @params = $VEP->format_parms(\%args, | ||
| 797 | { | ||
| 798 | single_parm => 'LoadBalancerName', | ||
| 799 | elb_instance_id_list => 'Instances', | ||
| 800 | }); | ||
| 801 | my @i = $self->elb_call('DeregisterInstancesFromLoadBalancer',@params) or return; | ||
| 802 | return $self->describe_instances(@i); | ||
| 803 | } | ||
| 804 | |||
| 805 | =head2 $success = $ec2->set_load_balancer_listener_ssl_certificate(-load_balancer_name => $name, | ||
| 806 | -load_balancer_port => $port, | ||
| 807 | -ssl_certificate_id => $cert_id) | ||
| 808 | |||
| 809 | Sets the certificate that terminates the specified listener's SSL connections. | ||
| 810 | The specified certificate replaces any prior certificate that was used on the | ||
| 811 | same ELB and port. | ||
| 812 | |||
| 813 | Required arguments: | ||
| 814 | |||
| 815 | -load_balancer_name The name of the the ELB. | ||
| 816 | |||
| 817 | -load_balancer_port The port that uses the specified SSL certificate. | ||
| 818 | |||
| 819 | -ssl_certificate_id The ID of the SSL certificate chain to use. See the | ||
| 820 | AWS Identity and Access Management documentation under | ||
| 821 | Managing Server Certificates for more information. | ||
| 822 | |||
| 823 | Alias arguments: | ||
| 824 | |||
| 825 | -lb_name Alias for -load_balancer_name | ||
| 826 | |||
| 827 | -port Alias for -load_balancer_port | ||
| 828 | |||
| 829 | -cert_id Alias for -ssl_certificate_id | ||
| 830 | |||
| 831 | Returns true on successful execution. | ||
| 832 | |||
| 833 | =cut | ||
| 834 | |||
| 835 | sub set_load_balancer_listener_ssl_certificate { | ||
| 836 | my $self = shift; | ||
| 837 | my %args = @_; | ||
| 838 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 839 | $args{-load_balancer_port} ||= $args{-port}; | ||
| 840 | $args{-ssl_certificate_id} ||= $args{-cert_id}; | ||
| 841 | $args{-load_balancer_name} or | ||
| 842 | croak "set_load_balancer_listener_ssl_certificate(): -load_balancer_name argument missing"; | ||
| 843 | $args{-load_balancer_port} or | ||
| 844 | croak "set_load_balancer_listener_ssl_certificate(): -load_balancer_port argument missing"; | ||
| 845 | $args{-ssl_certificate_id} or | ||
| 846 | croak "set_load_balancer_listener_ssl_certificate(): -ssl_certificate_id argument missing"; | ||
| 847 | my @params = $VEP->format_parms(\%args, | ||
| 848 | { | ||
| 849 | single_parm => [qw(LoadBalancerName LoadBalancerPort)], | ||
| 850 | }); | ||
| 851 | push @params,('SSLCertificateId'=>$args{-ssl_certificate_id}) if $args{-ssl_certificate_id}; | ||
| 852 | return $self->elb_call('SetLoadBalancerListenerSSLCertificate',@params); | ||
| 853 | } | ||
| 854 | |||
| 855 | =head2 @states = $ec2->describe_instance_health(-load_balancer_name => $name, | ||
| 856 | -instances => \@instance_ids) | ||
| 857 | |||
| 858 | Returns the current state of the instances of the specified LoadBalancer. If no | ||
| 859 | instances are specified, the state of all the instances for the ELB is returned. | ||
| 860 | |||
| 861 | Required arguments: | ||
| 862 | |||
| 863 | -load_balancer_name The name of the ELB | ||
| 864 | |||
| 865 | Optional parameters: | ||
| 866 | |||
| 867 | -instances Literal string or arrayref of Instance IDs | ||
| 868 | |||
| 869 | -lb_name Alias for -load_balancer_name | ||
| 870 | |||
| 871 | -instance_id Alias for -instances | ||
| 872 | |||
| 873 | Returns an array of L<VM::EC2::ELB::InstanceState> objects. | ||
| 874 | |||
| 875 | =cut | ||
| 876 | |||
| 877 | sub describe_instance_health { | ||
| 878 | my $self = shift; | ||
| 879 | my %args = @_; | ||
| 880 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 881 | $args{-instances} ||= $args{-instance_id}; | ||
| 882 | $args{-load_balancer_name} or | ||
| 883 | croak "describe_instance_health(): -load_balancer_name argument missing"; | ||
| 884 | my @params = $VEP->format_parms(\%args, | ||
| 885 | { | ||
| 886 | single_parm => 'LoadBalancerName', | ||
| 887 | elb_instance_id_list => 'Instances', | ||
| 888 | }); | ||
| 889 | return $self->elb_call('DescribeInstanceHealth',@params); | ||
| 890 | } | ||
| 891 | |||
| 892 | =head2 $success = $ec2->create_load_balancer_policy(-load_balancer_name => $name, | ||
| 893 | -policy_name => $policy, | ||
| 894 | -policy_type_name => $type_name, | ||
| 895 | -policy_attributes => \@attrs) | ||
| 896 | |||
| 897 | Creates a new policy that contains the necessary attributes depending on the | ||
| 898 | policy type. Policies are settings that are saved for your ELB and that can be | ||
| 899 | applied to the front-end listener, or the back-end application server, | ||
| 900 | depending on your policy type. | ||
| 901 | |||
| 902 | Required Arguments: | ||
| 903 | |||
| 904 | -load_balancer_name The name associated with the LoadBalancer for which the | ||
| 905 | policy is being created. This name must be unique within | ||
| 906 | the client AWS account. | ||
| 907 | |||
| 908 | -policy_name The name of the ELB policy being created. The name must | ||
| 909 | be unique within the set of policies for this ELB. | ||
| 910 | |||
| 911 | -policy_type_name The name of the base policy type being used to create | ||
| 912 | this policy. To get the list of policy types, use the | ||
| 913 | describe_load_balancer_policy_types function. | ||
| 914 | |||
| 915 | Optional Arguments: | ||
| 916 | |||
| 917 | -policy_attributes or hashref containing AttributeName and AttributeValue | ||
| 918 | or | ||
| 919 | Arrayref of VM::EC2::ELB::PolicyAttribute object or single object | ||
| 920 | |||
| 921 | -lb_name Alias for -load_balancer_name | ||
| 922 | |||
| 923 | Returns true if successful. | ||
| 924 | |||
| 925 | =cut | ||
| 926 | |||
| 927 | sub create_load_balancer_policy { | ||
| 928 | my $self = shift; | ||
| 929 | my %args = @_; | ||
| 930 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 931 | $args{-load_balancer_name} or | ||
| 932 | croak "create_load_balancer_policy(): -load_balancer_name argument missing"; | ||
| 933 | $args{-policy_name} or | ||
| 934 | croak "create_load_balancer_policy(): -policy_name argument missing"; | ||
| 935 | $args{-policy_type_name} or | ||
| 936 | croak "create_load_balancer_policy(): -policy_type_name argument missing"; | ||
| 937 | my @params = $VEP->format_parms(\%args, | ||
| 938 | { | ||
| 939 | single_parm => [qw(LoadBalancerName | ||
| 940 | PolicyName | ||
| 941 | PolicyTypeName)], | ||
| 942 | elb_attr_name_value_parm => 'PolicyAttributes', | ||
| 943 | }); | ||
| 944 | return $self->elb_call('CreateLoadBalancerPolicy',@params); | ||
| 945 | } | ||
| 946 | |||
| 947 | =head2 $success = $ec2->delete_load_balancer_policy(-load_balancer_name => $name, | ||
| 948 | -policy_name => $policy) | ||
| 949 | |||
| 950 | Deletes a policy from the ELB. The specified policy must not be enabled for any | ||
| 951 | listeners. | ||
| 952 | |||
| 953 | Arguments: | ||
| 954 | |||
| 955 | -load_balancer_name The name of the ELB | ||
| 956 | |||
| 957 | -policy_name The name of the ELB policy | ||
| 958 | |||
| 959 | -lb_name Alias for -load_balancer_name | ||
| 960 | |||
| 961 | Returns true if successful. | ||
| 962 | |||
| 963 | =cut | ||
| 964 | |||
| 965 | sub delete_load_balancer_policy { | ||
| 966 | my $self = shift; | ||
| 967 | my %args = @_; | ||
| 968 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 969 | $args{-load_balancer_name} or | ||
| 970 | croak "delete_load_balancer_policy(): -load_balancer_name argument missing"; | ||
| 971 | $args{-policy_name} or | ||
| 972 | croak "delete_load_balancer_policy(): -policy_name argument missing"; | ||
| 973 | my @params = $VEP->format_parms(\%args, | ||
| 974 | { | ||
| 975 | single_parm => [qw(LoadBalancerName PolicyName)], | ||
| 976 | }); | ||
| 977 | return $self->elb_call('DeleteLoadBalancerPolicy',@params); | ||
| 978 | } | ||
| 979 | |||
| 980 | =head2 @policy_descs = $ec2->describe_load_balancer_policies(-load_balancer_name => $name, | ||
| 981 | -policy_names => \@names) | ||
| 982 | |||
| 983 | Returns detailed descriptions of ELB policies. If you specify an ELB name, the | ||
| 984 | operation returns either the descriptions of the specified policies, or | ||
| 985 | descriptions of all the policies created for the ELB. If you don't specify a ELB | ||
| 986 | name, the operation returns descriptions of the specified sample policies, or | ||
| 987 | descriptions of all the sample policies. The names of the sample policies have | ||
| 988 | the ELBSample- prefix. | ||
| 989 | |||
| 990 | Optional Arguments: | ||
| 991 | |||
| 992 | -load_balancer_name The name of the ELB. | ||
| 993 | |||
| 994 | -policy_names The names of ELB policies created or ELB sample policy names. | ||
| 995 | |||
| 996 | -lb_name Alias for -load_balancer_name | ||
| 997 | |||
| 998 | Returns an array of L<VM::EC2::ELB::PolicyDescription> objects if successful. | ||
| 999 | |||
| 1000 | =cut | ||
| 1001 | |||
| 1002 | sub describe_load_balancer_policies { | ||
| 1003 | my $self = shift; | ||
| 1004 | my %args = @_; | ||
| 1005 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1006 | $args{-policy_names} ||= $args{-policy_name}; | ||
| 1007 | $args{-load_balancer_name} or | ||
| 1008 | croak "describe_load_balancer_policies(): -load_balancer_name argument missing"; | ||
| 1009 | my @params = $VEP->format_parms(\%args, | ||
| 1010 | { | ||
| 1011 | single_parm => 'LoadBalancerName', | ||
| 1012 | member_list_parm => 'PolicyNames', | ||
| 1013 | }); | ||
| 1014 | return $self->elb_call('DescribeLoadBalancerPolicies',@params); | ||
| 1015 | } | ||
| 1016 | |||
| 1017 | =head2 @policy_types = $ec2->describe_load_balancer_policy_types(-policy_type_names => \@names) | ||
| 1018 | |||
| 1019 | Returns meta-information on the specified ELB policies defined by the Elastic | ||
| 1020 | Load Balancing service. The policy types that are returned from this action can | ||
| 1021 | be used in a create_load_balander_policy call to instantiate specific policy | ||
| 1022 | configurations that will be applied to an ELB. | ||
| 1023 | |||
| 1024 | Required arguemnts: | ||
| 1025 | |||
| 1026 | -load_balancer_name The name of the ELB. | ||
| 1027 | |||
| 1028 | Optional arguments: | ||
| 1029 | |||
| 1030 | -policy_type_names Literal string or arrayref of policy type names | ||
| 1031 | |||
| 1032 | -names Alias for -policy_type_names | ||
| 1033 | |||
| 1034 | Returns an array of L<VM::EC2::ELB::PolicyTypeDescription> objects if successful. | ||
| 1035 | |||
| 1036 | =cut | ||
| 1037 | |||
| 1038 | sub describe_load_balancer_policy_types { | ||
| 1039 | my $self = shift; | ||
| 1040 | my %args = @_; | ||
| 1041 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1042 | $args{-policy_type_names} ||= $args{-names}; | ||
| 1043 | $args{-load_balancer_name} or | ||
| 1044 | croak "describe_load_balancer_policies(): -load_balancer_name argument missing"; | ||
| 1045 | my @params = $VEP->format_parms(\%args, | ||
| 1046 | { | ||
| 1047 | single_parm => 'LoadBalancerName', | ||
| 1048 | member_list_parm => 'PolicyTypeNames', | ||
| 1049 | }); | ||
| 1050 | return $self->elb_call('DescribeLoadBalancerPolicyTypes',@params); | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | =head2 $success = $ec2->set_load_balancer_policies_of_listener(-load_balancer_name => $name, | ||
| 1054 | -load_balancer_port => $port, | ||
| 1055 | -policy_names => \@names) | ||
| 1056 | |||
| 1057 | Associates, updates, or disables a policy with a listener on the ELB. Multiple | ||
| 1058 | policies may be associated with a listener. | ||
| 1059 | |||
| 1060 | Required arguments: | ||
| 1061 | |||
| 1062 | -load_balancer_name The name associated with the ELB. | ||
| 1063 | |||
| 1064 | -load_balancer_port The external port of the LoadBalancer with which this | ||
| 1065 | policy applies to. | ||
| 1066 | |||
| 1067 | -policy_names List of policies to be associated with the listener. | ||
| 1068 | Currently this list can have at most one policy. If the | ||
| 1069 | list is empty, the current policy is removed from the | ||
| 1070 | listener. String or arrayref. | ||
| 1071 | |||
| 1072 | Returns true if successful. | ||
| 1073 | |||
| 1074 | =cut | ||
| 1075 | |||
| 1076 | sub set_load_balancer_policies_of_listener { | ||
| 1077 | my $self = shift; | ||
| 1078 | my %args = @_; | ||
| 1079 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1080 | $args{-load_balancer_port} ||= $args{-port}; | ||
| 1081 | $args{-load_balancer_name} or | ||
| 1082 | croak "set_load_balancer_policies_of_listener(): -load_balancer_name argument missing"; | ||
| 1083 | $args{-load_balancer_port} or | ||
| 1084 | croak "set_load_balancer_policies_of_listener(): -load_balancer_port argument missing"; | ||
| 1085 | $args{-policy_names} or | ||
| 1086 | croak "set_load_balancer_policies_of_listener(): -policy_names argument missing"; | ||
| 1087 | my @params = $VEP->format_parms(\%args, | ||
| 1088 | { | ||
| 1089 | single_parm => [qw(LoadBalancerName LoadBalancerPort)], | ||
| 1090 | member_list_parm => 'PolicyNames', | ||
| 1091 | }); | ||
| 1092 | return $self->elb_call('SetLoadBalancerPoliciesOfListener',@params); | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | =head2 @sgs = $ec2->apply_security_groups_to_load_balancer(-load_balancer_name => $name, | ||
| 1096 | -security_groups => \@groups) | ||
| 1097 | |||
| 1098 | Associates one or more security groups with your ELB in VPC. The provided | ||
| 1099 | security group IDs will override any currently applied security groups. | ||
| 1100 | |||
| 1101 | Required arguments: | ||
| 1102 | |||
| 1103 | -load_balancer_name The name associated with the ELB. | ||
| 1104 | |||
| 1105 | -security_groups A list of security group IDs to associate with your ELB in | ||
| 1106 | VPC. The security group IDs must be provided as the ID and | ||
| 1107 | not the security group name (For example, sg-123456). | ||
| 1108 | String or arrayref. | ||
| 1109 | |||
| 1110 | Returns a series of L<VM::EC2::SecurityGroup> objects. | ||
| 1111 | |||
| 1112 | =cut | ||
| 1113 | |||
| 1114 | sub apply_security_groups_to_load_balancer { | ||
| 1115 | my $self = shift; | ||
| 1116 | my %args = @_; | ||
| 1117 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1118 | $args{-load_balancer_name} or | ||
| 1119 | croak "apply_security_groups_to_load_balancer(): -load_balancer_name argument missing"; | ||
| 1120 | $args{-security_groups} or | ||
| 1121 | croak "apply_security_groups_to_load_balancer(): -security_groups argument missing"; | ||
| 1122 | my @params = $VEP->format_parms(\%args, | ||
| 1123 | { | ||
| 1124 | single_parm => 'LoadBalancerName', | ||
| 1125 | member_list_parm => 'SecurityGroups', | ||
| 1126 | }); | ||
| 1127 | my @g = $self->elb_call('ApplySecurityGroupsToLoadBalancer',@params) or return; | ||
| 1128 | return $self->describe_security_groups(@g); | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | =head2 @subnets = $ec2->attach_load_balancer_to_subnets(-load_balancer_name => $name, | ||
| 1132 | -subnets => \@subnets) | ||
| 1133 | |||
| 1134 | Adds one or more subnets to the set of configured subnets for the ELB. | ||
| 1135 | |||
| 1136 | Required arguments: | ||
| 1137 | |||
| 1138 | -load_balancer_name The name associated with the ELB. | ||
| 1139 | |||
| 1140 | -subnets A list of subnet IDs to add for the ELB. String or | ||
| 1141 | arrayref. | ||
| 1142 | |||
| 1143 | Returns a series of L<VM::EC2::VPC::Subnet> objects corresponding to the | ||
| 1144 | subnets the ELB is now attached to. | ||
| 1145 | |||
| 1146 | =cut | ||
| 1147 | |||
| 1148 | sub attach_load_balancer_to_subnets { | ||
| 1149 | my $self = shift; | ||
| 1150 | my %args = @_; | ||
| 1151 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1152 | $args{-load_balancer_name} or | ||
| 1153 | croak "attach_load_balancer_to_subnets(): -load_balancer_name argument missing"; | ||
| 1154 | $args{-subnets} or | ||
| 1155 | croak "attach_load_balancer_to_subnets(): -subnets argument missing"; | ||
| 1156 | my @params = $VEP->format_parms(\%args, | ||
| 1157 | { | ||
| 1158 | single_parm => 'LoadBalancerName', | ||
| 1159 | member_list_parm => 'Subnets', | ||
| 1160 | }); | ||
| 1161 | my @sn = $self->elb_call('AttachLoadBalancerToSubnets',@params) or return; | ||
| 1162 | return $self->describe_subnets(@sn); | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | =head2 @subnets = $ec2->detach_load_balancer_from_subnets(-load_balancer_name => $name, | ||
| 1166 | -subnets => \@subnets) | ||
| 1167 | |||
| 1168 | Removes subnets from the set of configured subnets in the VPC for the ELB. | ||
| 1169 | |||
| 1170 | Required arguments: | ||
| 1171 | |||
| 1172 | -load_balancer_name The name associated with the ELB. | ||
| 1173 | |||
| 1174 | -subnets A list of subnet IDs to add for the ELB. String or | ||
| 1175 | arrayref. | ||
| 1176 | |||
| 1177 | Returns a series of L<VM::EC2::VPC::Subnet> objects corresponding to the | ||
| 1178 | subnets the ELB is now attached to. | ||
| 1179 | |||
| 1180 | =cut | ||
| 1181 | |||
| 1182 | sub detach_load_balancer_from_subnets { | ||
| 1183 | my $self = shift; | ||
| 1184 | my %args = @_; | ||
| 1185 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1186 | $args{-load_balancer_name} or | ||
| 1187 | croak "detach_load_balancer_from_subnets(): -load_balancer_name argument missing"; | ||
| 1188 | $args{-subnets} or | ||
| 1189 | croak "detach_load_balancer_from_subnets(): -subnets argument missing"; | ||
| 1190 | my @params = $VEP->format_parms(\%args, | ||
| 1191 | { | ||
| 1192 | single_parm => 'LoadBalancerName', | ||
| 1193 | member_list_parm => 'Subnets', | ||
| 1194 | }); | ||
| 1195 | my @sn = $self->elb_call('DetachLoadBalancerFromSubnets',@params) or return; | ||
| 1196 | return $self->describe_subnets(@sn); | ||
| 1197 | } | ||
| 1198 | |||
| 1199 | =head2 $success = $ec2->set_load_balancer_policies_for_backend_server(-instance_port => $port, | ||
| 1200 | -load_balancer_name => $name, | ||
| 1201 | -policy_names => \@policies) | ||
| 1202 | |||
| 1203 | Replaces the current set of policies associated with a port on which the back- | ||
| 1204 | end server is listening with a new set of policies. After the policies have | ||
| 1205 | been created, they can be applied here as a list. At this time, only the back- | ||
| 1206 | end server authentication policy type can be applied to the back-end ports; | ||
| 1207 | this policy type is composed of multiple public key policies. | ||
| 1208 | |||
| 1209 | Required arguments: | ||
| 1210 | |||
| 1211 | -load_balancer_name The name associated with the ELB. | ||
| 1212 | |||
| 1213 | -instance_port The port number associated with the back-end server. | ||
| 1214 | |||
| 1215 | -policy_names List of policy names to be set. If the list is empty, | ||
| 1216 | then all current polices are removed from the back-end | ||
| 1217 | server. | ||
| 1218 | |||
| 1219 | Aliases: | ||
| 1220 | |||
| 1221 | -port Alias for -instance_port | ||
| 1222 | -lb_name Alias for -load_balancer_name | ||
| 1223 | |||
| 1224 | Returns true if successful. | ||
| 1225 | |||
| 1226 | =cut | ||
| 1227 | |||
| 1228 | sub set_load_balancer_policies_for_backend_server { | ||
| 1229 | my $self = shift; | ||
| 1230 | my %args = @_; | ||
| 1231 | $args{-load_balancer_name} ||= $args{-lb_name}; | ||
| 1232 | $args{-instance_port} ||= $args{-port}; | ||
| 1233 | $args{-load_balancer_name} or | ||
| 1234 | croak "set_load_balancer_policies_for_backend_server(): -load_balancer_name argument missing"; | ||
| 1235 | $args{-instance_port} or | ||
| 1236 | croak "set_load_balancer_policies_for_backend_server(): -instance_port argument missing"; | ||
| 1237 | $args{-policy_names} or | ||
| 1238 | croak "set_load_balancer_policies_for_backend_server(): -policy_names argument missing"; | ||
| 1239 | my @params = $VEP->format_parms(\%args, | ||
| 1240 | { | ||
| 1241 | single_parm => [qw(LoadBalancerName InstancePort)], | ||
| 1242 | member_list_parm => 'PolicyNames', | ||
| 1243 | }); | ||
| 1244 | return $self->elb_call('SetLoadBalancerPoliciesForBackendServer',@params); | ||
| 1245 | } | ||
| 1246 | |||
| 1247 | =head1 SEE ALSO | ||
| 1248 | |||
| 1249 | L<VM::EC2> | ||
| 1250 | |||
| 1251 | =head1 AUTHOR | ||
| 1252 | |||
| 1253 | Lance Kinley E<lt>lkinley@loyaltymethods.com<gt>. | ||
| 1254 | Lincoln Stein E<lt>lincoln.stein@gmail.comE<gt>. | ||
| 1255 | |||
| 1256 | Copyright (c) 2012 Loyalty Methods, Inc. | ||
| 1257 | Copyright (c) 2012 Ontario Institute for Cancer Research | ||
| 1258 | |||
| 1259 | This package and its accompanying libraries is free software; you can | ||
| 1260 | redistribute it and/or modify it under the terms of the GPL (either | ||
| 1261 | version 1, or at your option, any later version) or the Artistic | ||
| 1262 | License 2.0. Refer to LICENSE for the full license text. In addition, | ||
| 1263 | please see DISCLAIMER.txt for disclaimers of warranty. | ||
| 1264 | |||
| 1265 | =cut | ||
| 1266 | |||
| 1267 | |||
| 1268 | 1; |