1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.service.amazon.ec2.elasticip">
<title>Zend_Service_Amazon_Ec2: Elastic IP Addresses</title>
<para>
By default, all Amazon EC2 instances are assigned two IP addresses at
launch: a private (RFC 1918) address and a public address that is mapped
to the private IP address through Network Address Translation (NAT).
</para>
<para>
If you use dynamic DNS to map an existing DNS name to a new instance's
public IP address, it might take up to 24 hours for the IP address to propagate
through the Internet. As a result, new instances might not receive traffic while
terminated instances continue to receive requests.
</para>
<para>
To solve this problem, Amazon EC2 provides elastic IP addresses. Elastic IP addresses
are static IP addresses designed for dynamic cloud computing. Elastic IP addresses
are associated with your account, not specific instances. Any elastic IP addresses
that you associate with your account remain associated with your account until you
explicitly release them. Unlike traditional static IP addresses, however, elastic IP
addresses allow you to mask instance or Availability Zone failures by rapidly remapping
your public IP addresses to any instance in your account.
</para>
<example id="zend.service.amazon.ec2.elasticip.allocate">
<title>Allocating a new Elastic IP</title>
<para>
<code>allocate</code> will assign your account a new Elastic IP Address.
</para>
<para>
<code>allocate</code> returns the newly allocated ip.
</para>
<programlisting language="php"><![CDATA[
$ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
$ip = $ec2_eip->allocate();
// print out your newly allocated elastic ip address;
print $ip;
]]></programlisting>
</example>
<example id="zend.service.amazon.ec2.elasticip.describe">
<title>Describing Allocated Elastic IP Addresses</title>
<para>
<code>describe</code> has an optional parameter to describe all
of your allocated Elastic IP addresses or just some of your
allocated addresses.
</para>
<para>
<code>describe</code> returns an array that contains information on each Elastic IP
Address which contains the publicIp and the instanceId if it is assocated.
</para>
<programlisting language="php"><![CDATA[
$ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
// describe all
$ips = $ec2_eip->describe();
// describe a subset
$ips = $ec2_eip->describe(array('ip1', 'ip2', 'ip3'));
// describe a single ip address
$ip = $ec2_eip->describe('ip1');
]]></programlisting>
</example>
<example id="zend.service.amazon.ec2.elasticip.release">
<title>Releasing Elastic IP</title>
<para>
<code>release</code> will release an Elastic IP to Amazon.
</para>
<para>
Returns a boolean <constant>TRUE</constant> or <constant>FALSE</constant>.
</para>
<programlisting language="php"><![CDATA[
$ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
$ec2_eip->release('ipaddress');
]]></programlisting>
</example>
<example id="zend.service.amazon.ec2.elasticip.associate">
<title>Associates an Elastic IP to an Instance</title>
<para>
<code>associate</code> will assign an Elastic IP to an
already running instance.
</para>
<para>
Returns a boolean <constant>TRUE</constant> or <constant>FALSE</constant>.
</para>
<programlisting language="php"><![CDATA[
$ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
$ec2_eip->associate('instance_id', 'ipaddress');
]]></programlisting>
</example>
<example id="zend.service.amazon.ec2.elasticip.disassociate">
<title>Disassociate an Elastic IP from an instance</title>
<para>
<code>disassociate</code> will disassociate an Elastic IP from an instance.
If you terminate an Instance it will automaticly disassociate the Elastic
IP address for you.
</para>
<para>
Returns a boolean <constant>TRUE</constant> or <constant>FALSE</constant>.
</para>
<programlisting language="php"><![CDATA[
$ec2_eip = new Zend_Service_Amazon_Ec2_Elasticip('aws_key','aws_secret_key');
$ec2_eip->disassociate('ipaddress');
]]></programlisting>
</example>
</sect1>
|