1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.service.amazon.ec2.elasticip">
4 <title>Zend_Service_Amazon_Ec2: Elastic IP Addresses</title>
7 By default, all Amazon EC2 instances are assigned two IP addresses at
8 launch: a private (RFC 1918) address and a public address that is mapped
9 to the private IP address through Network Address Translation (NAT).
13 If you use dynamic DNS to map an existing DNS name to a new instance's
14 public IP address, it might take up to 24 hours for the IP address to propagate
15 through the Internet. As a result, new instances might not receive traffic while
16 terminated instances continue to receive requests.
20 To solve this problem, Amazon EC2 provides elastic IP addresses. Elastic IP addresses
21 are static IP addresses designed for dynamic cloud computing. Elastic IP addresses
22 are associated with your account, not specific instances. Any elastic IP addresses
23 that you associate with your account remain associated with your account until you
24 explicitly release them. Unlike traditional static IP addresses, however, elastic IP
25 addresses allow you to mask instance or Availability Zone failures by rapidly remapping
26 your public IP addresses to any instance in your account.
29 <example id="zend.service.amazon.ec2.elasticip.allocate">
30 <title>Allocating a new Elastic IP</title>
33 <code>allocate</code> will assign your account a new Elastic IP Address.
37 <code>allocate</code> returns the newly allocated ip.
40 <programlisting language="php"><![CDATA[
41 $ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
42 $ip = $ec2_eip->allocate();
44 // print out your newly allocated elastic ip address;
49 <example id="zend.service.amazon.ec2.elasticip.describe">
50 <title>Describing Allocated Elastic IP Addresses</title>
53 <code>describe</code> has an optional paramater to describe all
54 of your allocated Elastic IP addresses or just some of your
59 <code>describe</code> returns an array that contains information on each Elastic IP
60 Address which contains the publicIp and the instanceId if it is assocated.
63 <programlisting language="php"><![CDATA[
64 $ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
66 $ips = $ec2_eip->describe();
69 $ips = $ec2_eip->describe(array('ip1', 'ip2', 'ip3'));
71 // describe a single ip address
72 $ip = $ec2_eip->describe('ip1');
76 <example id="zend.service.amazon.ec2.elasticip.release">
77 <title>Releasing Elastic IP</title>
80 <code>release</code> will release an Elastic IP to Amazon.
84 Returns a boolean <constant>TRUE</constant> or <constant>FALSE</constant>.
87 <programlisting language="php"><![CDATA[
88 $ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
89 $ec2_eip->release('ipaddress');
93 <example id="zend.service.amazon.ec2.elasticip.associate">
94 <title>Associates an Elastic IP to an Instance</title>
97 <code>associate</code> will assign an Elastic IP to an
98 already running instance.
102 Returns a boolean <constant>TRUE</constant> or <constant>FALSE</constant>.
105 <programlisting language="php"><![CDATA[
106 $ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
107 $ec2_eip->associate('instance_id', 'ipaddress');
111 <example id="zend.service.amazon.ec2.elasticip.disassociate">
112 <title>Disassociate an Elastic IP from an instance</title>
115 <code>disassociate</code> will disassociate an Elastic IP from an instance.
116 If you terminate an Instance it will automaticly disassociate the Elastic
121 Returns a boolean <constant>TRUE</constant> or <constant>FALSE</constant>.
124 <programlisting language="php"><![CDATA[
125 $ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
126 $ec2_eip->disassociate('ipaddress');