2
0

Zend_Service_Amazon_Ec2-Instance.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.service.amazon.ec2.instance">
  4. <title>Zend_Service_Amazon_Ec2: Instances</title>
  5. <sect2 id="zend.service.amazon.ec2.instance.types">
  6. <title>Instance Types</title>
  7. <para>
  8. Amazon EC2 instances are grouped into two families: standard and
  9. High-CPU. Standard instances have memory to CPU ratios suitable
  10. for most general purpose applications; High-CPU instances have
  11. proportionally more CPU resources than memory (RAM) and are well
  12. suited for compute-intensive applications. When selecting instance
  13. types, you might want to use less powerful instance types for your
  14. web server instances and more powerful instance types for your
  15. database instances. Additionally, you might want to run CPU instance
  16. types for CPU-intensive data processing tasks.
  17. </para>
  18. <para>
  19. One of the advantages of EC2 is that you pay by the instance hour,
  20. which makes it convenient and inexpensive to test the performance of
  21. your application on different instance families and types. One good
  22. way to determine the most appropriate instance family and instance
  23. type is to launch test instances and benchmark your application.
  24. </para>
  25. <note>
  26. <title>Instance Types</title>
  27. <para>
  28. The instance types are defined as constants in the code. Column eight
  29. in the table is the defined constant name
  30. </para>
  31. </note>
  32. <table id="zend.service.amazon.ec2.instance.types-table">
  33. <title>Available Instance Types</title>
  34. <tgroup cols="8">
  35. <thead>
  36. <row>
  37. <entry>Type</entry>
  38. <entry>CPU</entry>
  39. <entry>Memory</entry>
  40. <entry>Storage</entry>
  41. <entry>Platform</entry>
  42. <entry>I/O</entry>
  43. <entry>Name</entry>
  44. <entry>Constant Name</entry>
  45. </row>
  46. </thead>
  47. <tbody>
  48. <row>
  49. <entry><code>Small</code></entry>
  50. <entry><para>
  51. 1 EC2 Compute Unit (1 virtual core with 1 EC2
  52. Compute Unit)
  53. </para></entry>
  54. <entry><para>
  55. 1.7 GB
  56. </para></entry>
  57. <entry><para>
  58. 160 GB instance storage (150 GB plus 10 GB root
  59. partition)
  60. </para></entry>
  61. <entry><para>
  62. 32-bit
  63. </para></entry>
  64. <entry><para>
  65. Moderate
  66. </para></entry>
  67. <entry><para>
  68. m1.small
  69. </para></entry>
  70. <entry><classname>Zend_Service_Amazon_Ec2_Instance::SMALL</classname></entry>
  71. </row>
  72. <row>
  73. <entry><code>Large</code></entry>
  74. <entry><para>
  75. 4 EC2 Compute Units (2 virtual cores with 2 EC2
  76. Compute Units each)
  77. </para></entry>
  78. <entry><para>
  79. 7.5 GB
  80. </para></entry>
  81. <entry><para>
  82. 850 GB instance storage (2 x 420 GB plus 10
  83. GB root partition)
  84. </para></entry>
  85. <entry><para>
  86. 64-bit
  87. </para></entry>
  88. <entry><para>
  89. High
  90. </para></entry>
  91. <entry><para>
  92. m1.large
  93. </para></entry>
  94. <entry><classname>Zend_Service_Amazon_Ec2_Instance::LARGE</classname></entry>
  95. </row>
  96. <row>
  97. <entry><code>Extra Large</code></entry>
  98. <entry><para>
  99. 8 EC2 Compute Units (4 virtual cores with 2 EC2
  100. Compute Units each)
  101. </para></entry>
  102. <entry><para>
  103. 15 GB
  104. </para></entry>
  105. <entry><para>
  106. 1,690 GB instance storage (4 x 420 GB plus 10
  107. GB root partition)
  108. </para></entry>
  109. <entry><para>
  110. 64-bit
  111. </para></entry>
  112. <entry><para>
  113. High
  114. </para></entry>
  115. <entry><para>
  116. m1.xlarge
  117. </para></entry>
  118. <entry><classname>Zend_Service_Amazon_Ec2_Instance::XLARGE</classname></entry>
  119. </row>
  120. <row>
  121. <entry><code>High-CPU Medium</code></entry>
  122. <entry><para>
  123. 5 EC2 Compute Units (2 virtual cores with 2.5 EC2
  124. Compute Units each)
  125. </para></entry>
  126. <entry><para>
  127. 1.7 GB
  128. </para></entry>
  129. <entry><para>
  130. 350 GB instance storage (340 GB plus 10
  131. GB root partition)
  132. </para></entry>
  133. <entry><para>
  134. 32-bit
  135. </para></entry>
  136. <entry><para>
  137. Moderate
  138. </para></entry>
  139. <entry><para>
  140. c1.medium
  141. </para></entry>
  142. <entry><classname>Zend_Service_Amazon_Ec2_Instance::HCPU_MEDIUM</classname></entry>
  143. </row>
  144. <row>
  145. <entry><code>High-CPU Extra Large</code></entry>
  146. <entry><para>
  147. 20 EC2 Compute Units (8 virtual cores with 2.5 EC2
  148. Compute Units each)
  149. </para></entry>
  150. <entry><para>
  151. 7 GB
  152. </para></entry>
  153. <entry><para>
  154. 1,690 GB instance storage (4 x 420 GB plus 10
  155. GB root partition)
  156. </para></entry>
  157. <entry><para>
  158. 64-bit
  159. </para></entry>
  160. <entry><para>
  161. High
  162. </para></entry>
  163. <entry><para>
  164. c1.xlarge
  165. </para></entry>
  166. <entry><classname>Zend_Service_Amazon_Ec2_Instance::HCPU_XLARGE</classname></entry>
  167. </row>
  168. </tbody>
  169. </tgroup>
  170. </table>
  171. </sect2>
  172. <sect2 id="zend.service.amazon.ec2.instance.operations">
  173. <title>Running Amazon EC2 Instances</title>
  174. <para>
  175. This section describes the operation methods for maintaining Amazon EC2 Instances.
  176. </para>
  177. <example id="zend.service.amazon.ec2.instance.operations.run">
  178. <title>Starting New Ec2 Instances</title>
  179. <para>
  180. <code>run</code> will launch a specified number of EC2 Instances.
  181. <code>run</code> takes an array of parameters to start, below is a table
  182. containing the valid values.
  183. </para>
  184. <para>
  185. <table id="zend.service.amazon.ec2.instance.operations.run-table">
  186. <title>Valid Run Options</title>
  187. <tgroup cols="3">
  188. <thead>
  189. <row>
  190. <entry>Name</entry>
  191. <entry>Description</entry>
  192. <entry>Required</entry>
  193. </row>
  194. </thead>
  195. <tbody>
  196. <row>
  197. <entry><code>imageId</code></entry>
  198. <entry><para>
  199. ID of the AMI with which to launch instances.
  200. </para></entry>
  201. <entry><para>Yes</para></entry>
  202. </row>
  203. <row>
  204. <entry><code>minCount</code></entry>
  205. <entry><para>
  206. Minimum number of instances to launch. Default: 1
  207. </para></entry>
  208. <entry><para>No</para></entry>
  209. </row>
  210. <row>
  211. <entry><code>maxCount</code></entry>
  212. <entry><para>
  213. Maximum number of instances to launch. Default: 1
  214. </para></entry>
  215. <entry><para>No</para></entry>
  216. </row>
  217. <row>
  218. <entry><code>keyName</code></entry>
  219. <entry><para>
  220. Name of the key pair with which to launch instances.
  221. If you do not provide a key, all instances will
  222. be inaccessible.
  223. </para></entry>
  224. <entry><para>No</para></entry>
  225. </row>
  226. <row>
  227. <entry><code>securityGroup</code></entry>
  228. <entry><para>
  229. Names of the security groups with which to associate
  230. the instances.
  231. </para></entry>
  232. <entry><para>No</para></entry>
  233. </row>
  234. <row>
  235. <entry><code>userData</code></entry>
  236. <entry><para>
  237. The user data available to the launched instances.
  238. This should not be Base64 encoded.
  239. </para></entry>
  240. <entry><para>No</para></entry>
  241. </row>
  242. <row>
  243. <entry><code>instanceType</code></entry>
  244. <entry><para>
  245. Specifies the instance type. Default: m1.small
  246. </para></entry>
  247. <entry><para>No</para></entry>
  248. </row>
  249. <row>
  250. <entry><code>placement</code></entry>
  251. <entry><para>
  252. Specifies the availability zone in which to
  253. launch the instance(s). By default, Amazon
  254. EC2 selects an availability zone for you.
  255. </para></entry>
  256. <entry><para>No</para></entry>
  257. </row>
  258. <row>
  259. <entry><code>kernelId</code></entry>
  260. <entry><para>
  261. The ID of the kernel with which to launch
  262. the instance.
  263. </para></entry>
  264. <entry><para>No</para></entry>
  265. </row>
  266. <row>
  267. <entry><code>ramdiskId</code></entry>
  268. <entry><para>
  269. The ID of the RAM disk with which to launch
  270. the instance.
  271. </para></entry>
  272. <entry><para>No</para></entry>
  273. </row>
  274. <row>
  275. <entry><code>blockDeviceVirtualName</code></entry>
  276. <entry><para>
  277. Specifies the virtual name to map to the
  278. corresponding device name. For example:
  279. instancestore0
  280. </para></entry>
  281. <entry><para>No</para></entry>
  282. </row>
  283. <row>
  284. <entry><code>blockDeviceName</code></entry>
  285. <entry><para>
  286. Specifies the device to which you are
  287. mapping a virtual name. For example: sdb
  288. </para></entry>
  289. <entry><para>No</para></entry>
  290. </row>
  291. </tbody>
  292. </tgroup>
  293. </table>
  294. </para>
  295. <para>
  296. <code>run</code> will return information about each instance
  297. that is starting up.
  298. </para>
  299. <programlisting language="php"><![CDATA[
  300. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  301. 'aws_secret_key');
  302. $return = $ec2_instance->run(array('imageId' => 'ami-509320',
  303. 'keyName' => 'myKey',
  304. 'securityGroup' => array('web',
  305. 'default')));
  306. ]]></programlisting>
  307. </example>
  308. <example id="zend.service.amazon.ec2.instance.operations.reboot">
  309. <title>Rebooting an Ec2 Instances</title>
  310. <para>
  311. <code>reboot</code> will reboot one or more instances.
  312. </para>
  313. <para>
  314. This operation is asynchronous; it only queues a request to
  315. reboot the specified instance(s). The operation will succeed
  316. if the instances are valid and belong to the user. Requests
  317. to reboot terminated instances are ignored.
  318. </para>
  319. <para>
  320. <code>reboot</code> returns boolean true or false
  321. </para>
  322. <programlisting language="php"><![CDATA[
  323. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  324. 'aws_secret_key');
  325. $return = $ec2_instance->reboot('instanceId');
  326. ]]></programlisting>
  327. </example>
  328. <example id="zend.service.amazon.ec2.instance.operations.terminate">
  329. <title>Terminating an Ec2 Instances</title>
  330. <para>
  331. <code>terminate</code> shuts down one or more instances. This
  332. operation is idempotent; if you terminate an instance more
  333. than once, each call will succeed.
  334. </para>
  335. <para>
  336. <code>terminate</code> returns boolean true or false
  337. </para>
  338. <programlisting language="php"><![CDATA[
  339. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  340. 'aws_secret_key');
  341. $return = $ec2_instance->terminate('instanceId');
  342. ]]></programlisting>
  343. </example>
  344. <note>
  345. <title>Terminated Instances</title>
  346. <para>Terminated instances will remain visible after termination
  347. (approximately one hour).</para>
  348. </note>
  349. </sect2>
  350. <sect2 id="zend.service.amazon.ec2.instance.utility">
  351. <title>Amazon Instance Utilities</title>
  352. <para>
  353. In this section you will find out how to retreive information, the console
  354. output and see if an instance contains a product code.
  355. </para>
  356. <example id="zend.service.amazon.ec2.instance.utility.describe">
  357. <title>Describing Instances</title>
  358. <para>
  359. <code>describe</code> returns information about instances that you own.
  360. </para>
  361. <para>
  362. If you specify one or more instance IDs, Amazon EC2 returns information
  363. for those instances. If you do not specify instance IDs, Amazon EC2
  364. returns information for all relevant instances. If you specify an invalid
  365. instance ID, a fault is returned. If you specify an instance that you do
  366. not own, it will not be included in the returned results.
  367. </para>
  368. <para>
  369. <code>describe</code> will return an array containing information on the
  370. instance.
  371. </para>
  372. <programlisting language="php"><![CDATA[
  373. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  374. 'aws_secret_key');
  375. $return = $ec2_instance->describe('instanceId');
  376. ]]></programlisting>
  377. </example>
  378. <note>
  379. <title>Terminated Instances</title>
  380. <para>Recently terminated instances might appear in the returned results.
  381. This interval is usually less than one hour. If you do not want terminated
  382. instances to be returned, pass in a second variable of boolean true to
  383. <code>describe</code> and the terminated instances will be ignored.</para>
  384. </note>
  385. <example id="zend.service.amazon.ec2.instance.utility.describebyimageid">
  386. <title>Describing Instances By Image Id</title>
  387. <para>
  388. <code>describeByImageId</code> is functionally the same as <code>describe</code>
  389. but it will only return the instances that are using the provided imageId.
  390. </para>
  391. <para>
  392. <code>describeByImageId</code> will return an array containing information on the
  393. instances thare were started by the passed in imageId
  394. </para>
  395. <programlisting language="php"><![CDATA[
  396. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  397. 'aws_secret_key');
  398. $return = $ec2_instance->describeByImageId('imageId');
  399. ]]></programlisting>
  400. </example>
  401. <note>
  402. <title>Terminated Instances</title>
  403. <para>Recently terminated instances might appear in the returned results.
  404. This interval is usually less than one hour. If you do not want terminated
  405. instances to be returned, pass in a second variable of boolean true to
  406. <code>describe</code> and the terminated instances will be ignored.</para>
  407. </note>
  408. <example id="zend.service.amazon.ec2.instance.utility.consoleOutput">
  409. <title>Retreiving Console Output</title>
  410. <para>
  411. <code>consoleOutput</code> retrieves console output for the specified
  412. instance.
  413. </para>
  414. <para>
  415. Instance console output is buffered and posted shortly after instance
  416. boot, reboot, and termination. Amazon EC2 preserves the most recent
  417. 64 KB output which will be available for at least one hour after the
  418. most recent post.
  419. </para>
  420. <para>
  421. <code>consoleOutput</code> returns an array containing the
  422. <code>instanceId</code>, <code>timestamp</code> from the last output
  423. and the <code>output</code> from the console.
  424. </para>
  425. <programlisting language="php"><![CDATA[
  426. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  427. 'aws_secret_key');
  428. $return = $ec2_instance->consoleOutput('instanceId');
  429. ]]></programlisting>
  430. </example>
  431. <example id="zend.service.amazon.ec2.instance.utility.confirmproduct">
  432. <title>Confirm Product Code on an Instance</title>
  433. <para>
  434. <code>confirmProduct</code> returns true if the specified product code
  435. is attached to the specified instance. The operation returns false if
  436. the product code is not attached to the instance.
  437. </para>
  438. <para>
  439. The <code>confirmProduct</code> operation can only be executed by the
  440. owner of the AMI. This feature is useful when an AMI owner is providing
  441. support and wants to verify whether a user's instance is eligible.
  442. </para>
  443. <programlisting language="php"><![CDATA[
  444. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  445. 'aws_secret_key');
  446. $return = $ec2_instance->terminate('productCode', 'instanceId');
  447. ]]></programlisting>
  448. </example>
  449. </sect2>
  450. </sect1>