register_instances_with_load_balancer ( $load_balancer_name, $instances, $opt )

Adds new instances to the LoadBalancer.

Once the instance is registered, it starts receiving traffic and requests from the LoadBalancer. Any instance that is not in any of the Availability Zones registered for the LoadBalancer will be moved to the OutOfService state. It will move to the InService state when the Availability Zone is added to the LoadBalancer.

In order for this call to be successful, the client must have created the LoadBalancer. The client must provide the same account credentials as those that were used to create the LoadBalancer.

Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly.

Access

public

Parameters

Parameter

Type

Required

Description

$load_balancer_name

string

Required

The name associated with the LoadBalancer. The name must be unique within the client AWS account.

$instances

array

Required

A list of instance IDs that should be registered with the LoadBalancer.

When the instance is stopped and then restarted, the IP addresses associated with your instance changes. Elastic Load Balancing cannot recognize the new IP address, which prevents it from routing traffic to your instances. We recommend that you de-register your Amazon EC2 instances from your load balancer after you stop your instance, and then register the load balancer with your instance after you’ve restarted. To de-register your instances from load balancer, use DeregisterInstancesFromLoadBalancer action.

  • x - array - Optional - This represents a simple array index.
    • InstanceId - string - Optional - Provides an EC2 instance ID.

$opt

array

Optional

An associative array of parameters that can have the following keys:

  • curlopts - array - Optional - A set of values to pass directly into curl_setopt(), where the key is a pre-defined CURLOPT_* constant.
  • returnCurlHandle - boolean - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.

Returns

Type

Description

CFResponse

A CFResponse object containing a parsed HTTP response.

Examples

Register one or more EC2 instances with a load balancer.

To set up a new load balancer for one or more instances, you need to:

  1. Create a new load balancer with create_load_balancer().
  2. Register one or more EC2 instances with the load balancer using register_instances_with_load_balancer().
$elb = new AmazonELB();

$response = $elb->register_instances_with_load_balancer('my-load-balancer', array(
	array('InstanceId' => 'i-7e8d2913'),
	array('InstanceId' => 'i-8f9e4217')
));

// Success?
var_dump($response->isOK());
Result:
bool(true)

Related Methods

Source

Method defined in services/elb.class.php | Toggle source view (12 lines) | View on GitHub

public function register_instances_with_load_balancer($load_balancer_name, $instances, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['LoadBalancerName'] = $load_balancer_name;
    
    // Required list + map
    $opt = array_merge($opt, CFComplexType::map(array(
        'Instances' => (is_array($instances) ? $instances : array($instances))
    ), 'member'));

    return $this->authenticate('RegisterInstancesWithLoadBalancer', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback