Zend_Service_Amazon_Ec2-Elasticip.xml 4.6 KB

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