associate_address ( $instance_id, $public_ip, $opt )

The AssociateAddress operation associates an elastic IP address with an instance.

If the IP address is currently assigned to another instance, the IP address is assigned to the new instance. This is an idempotent operation. If you enter it more than once, Amazon EC2 does not return an error.

Access

public

Parameters

Parameter

Type

Required

Description

$instance_id

string

Required

The instance to associate with the IP address.

$public_ip

string

Required

IP address that you are assigning to the instance.

$opt

array

Optional

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

  • AllocationId - string - Optional - The allocation ID that AWS returned when you allocated the elastic IP address for use with Amazon VPC.
  • NetworkInterfaceId - string - Optional -
  • PrivateIpAddress - string - Optional -
  • AllowReassociation - boolean - Optional -
  • 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

AmazonEC2 - Associate Address

// Instantiate the class
$ec2 = new AmazonEC2();

$response = $ec2->associate_address('i-1f549375', '184.73.247.11');

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

Related Methods

Source

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

public function associate_address($instance_id, $public_ip, $opt = null)
{
    if (!$opt) $opt = array();
    $opt['InstanceId'] = $instance_id;
    $opt['PublicIp'] = $public_ip;
    
    return $this->authenticate('AssociateAddress', $opt);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback