Zend_Service_Amazon_Ec2-Instance.xml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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 <acronym>CPU</acronym> ratios suitable
  10. for most general purpose applications; High-CPU instances have
  11. proportionally more <acronym>CPU</acronym> 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 <acronym>CPU</acronym> instance
  16. types for <acronym>CPU</acronym>-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><acronym>CPU</acronym></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 <constant>EC2</constant> Compute Unit (1 virtual core with 1 <constant>EC2</constant>
  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><constant>Zend_Service_Amazon_Ec2_Instance::SMALL</constant></entry>
  71. </row>
  72. <row>
  73. <entry><code>Large</code></entry>
  74. <entry><para>
  75. 4 <constant>EC2</constant> Compute Units (2 virtual cores with 2 <constant>EC2</constant>
  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><constant>Zend_Service_Amazon_Ec2_Instance::LARGE</constant></entry>
  95. </row>
  96. <row>
  97. <entry><code>Extra Large</code></entry>
  98. <entry><para>
  99. 8 <constant>EC2</constant> Compute Units (4 virtual cores with 2 <constant>EC2</constant>
  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><constant>Zend_Service_Amazon_Ec2_Instance::XLARGE</constant></entry>
  119. </row>
  120. <row>
  121. <entry><code>High-CPU Medium</code></entry>
  122. <entry><para>
  123. 5 <constant>EC2</constant> Compute Units (2 virtual cores with 2.5 <constant>EC2</constant>
  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><constant>Zend_Service_Amazon_Ec2_Instance::HCPU_MEDIUM</constant></entry>
  143. </row>
  144. <row>
  145. <entry><code>High-CPU Extra Large</code></entry>
  146. <entry><para>
  147. 20 <constant>EC2</constant> Compute Units (8 virtual cores with 2.5 <constant>EC2</constant>
  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><constant>Zend_Service_Amazon_Ec2_Instance::HCPU_XLARGE</constant></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 <acronym>AMI</acronym> 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. <constant>EC2</constant> 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 <acronym>RAM</acronym> 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. <row>
  292. <entry><code>monitor</code></entry>
  293. <entry><para>
  294. Turn on <acronym>AWS</acronym> CloudWatch Instance Monitoring
  295. </para></entry>
  296. <entry><para>No</para></entry>
  297. </row>
  298. </tbody>
  299. </tgroup>
  300. </table>
  301. </para>
  302. <para>
  303. <code>run</code> will return information about each instance
  304. that is starting up.
  305. </para>
  306. <programlisting language="php"><![CDATA[
  307. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  308. 'aws_secret_key');
  309. $return = $ec2_instance->run(array('imageId' => 'ami-509320',
  310. 'keyName' => 'myKey',
  311. 'securityGroup' => array('web',
  312. 'default')));
  313. ]]></programlisting>
  314. </example>
  315. <example id="zend.service.amazon.ec2.instance.operations.reboot">
  316. <title>Rebooting an Ec2 Instances</title>
  317. <para>
  318. <code>reboot</code> will reboot one or more instances.
  319. </para>
  320. <para>
  321. This operation is asynchronous; it only queues a request to
  322. reboot the specified instance(s). The operation will succeed
  323. if the instances are valid and belong to the user. Requests
  324. to reboot terminated instances are ignored.
  325. </para>
  326. <para>
  327. <code>reboot</code> returns boolean true or false
  328. </para>
  329. <programlisting language="php"><![CDATA[
  330. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  331. 'aws_secret_key');
  332. $return = $ec2_instance->reboot('instanceId');
  333. ]]></programlisting>
  334. </example>
  335. <example id="zend.service.amazon.ec2.instance.operations.terminate">
  336. <title>Terminating an Ec2 Instances</title>
  337. <para>
  338. <code>terminate</code> shuts down one or more instances. This
  339. operation is idempotent; if you terminate an instance more
  340. than once, each call will succeed.
  341. </para>
  342. <para>
  343. <code>terminate</code> returns boolean true or false
  344. </para>
  345. <programlisting language="php"><![CDATA[
  346. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  347. 'aws_secret_key');
  348. $return = $ec2_instance->terminate('instanceId');
  349. ]]></programlisting>
  350. </example>
  351. <note>
  352. <title>Terminated Instances</title>
  353. <para>Terminated instances will remain visible after termination
  354. (approximately one hour).</para>
  355. </note>
  356. </sect2>
  357. <sect2 id="zend.service.amazon.ec2.instance.utility">
  358. <title>Amazon Instance Utilities</title>
  359. <para>
  360. In this section you will find out how to retreive information, the console
  361. output and see if an instance contains a product code.
  362. </para>
  363. <example id="zend.service.amazon.ec2.instance.utility.describe">
  364. <title>Describing Instances</title>
  365. <para>
  366. <code>describe</code> returns information about instances that you own.
  367. </para>
  368. <para>
  369. If you specify one or more instance IDs, Amazon EC2 returns information
  370. for those instances. If you do not specify instance IDs, Amazon EC2
  371. returns information for all relevant instances. If you specify an invalid
  372. instance ID, a fault is returned. If you specify an instance that you do
  373. not own, it will not be included in the returned results.
  374. </para>
  375. <para>
  376. <code>describe</code> will return an array containing information on the
  377. instance.
  378. </para>
  379. <programlisting language="php"><![CDATA[
  380. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  381. 'aws_secret_key');
  382. $return = $ec2_instance->describe('instanceId');
  383. ]]></programlisting>
  384. </example>
  385. <note>
  386. <title>Terminated Instances</title>
  387. <para>Recently terminated instances might appear in the returned results.
  388. This interval is usually less than one hour. If you do not want terminated
  389. instances to be returned, pass in a second variable of boolean true to
  390. <code>describe</code> and the terminated instances will be ignored.</para>
  391. </note>
  392. <example id="zend.service.amazon.ec2.instance.utility.describebyimageid">
  393. <title>Describing Instances By Image Id</title>
  394. <para>
  395. <code>describeByImageId</code> is functionally the same as <code>describe</code>
  396. but it will only return the instances that are using the provided imageId.
  397. </para>
  398. <para>
  399. <code>describeByImageId</code> will return an array containing information on the
  400. instances thare were started by the passed in imageId
  401. </para>
  402. <programlisting language="php"><![CDATA[
  403. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  404. 'aws_secret_key');
  405. $return = $ec2_instance->describeByImageId('imageId');
  406. ]]></programlisting>
  407. </example>
  408. <note>
  409. <title>Terminated Instances</title>
  410. <para>Recently terminated instances might appear in the returned results.
  411. This interval is usually less than one hour. If you do not want terminated
  412. instances to be returned, pass in a second variable of boolean true to
  413. <code>describe</code> and the terminated instances will be ignored.</para>
  414. </note>
  415. <example id="zend.service.amazon.ec2.instance.utility.consoleOutput">
  416. <title>Retreiving Console Output</title>
  417. <para>
  418. <code>consoleOutput</code> retrieves console output for the specified
  419. instance.
  420. </para>
  421. <para>
  422. Instance console output is buffered and posted shortly after instance
  423. boot, reboot, and termination. Amazon EC2 preserves the most recent
  424. 64 KB output which will be available for at least one hour after the
  425. most recent post.
  426. </para>
  427. <para>
  428. <code>consoleOutput</code> returns an array containing the
  429. <code>instanceId</code>, <code>timestamp</code> from the last output
  430. and the <code>output</code> from the console.
  431. </para>
  432. <programlisting language="php"><![CDATA[
  433. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  434. 'aws_secret_key');
  435. $return = $ec2_instance->consoleOutput('instanceId');
  436. ]]></programlisting>
  437. </example>
  438. <example id="zend.service.amazon.ec2.instance.utility.confirmproduct">
  439. <title>Confirm Product Code on an Instance</title>
  440. <para>
  441. <code>confirmProduct</code> returns true if the specified product code
  442. is attached to the specified instance. The operation returns false if
  443. the product code is not attached to the instance.
  444. </para>
  445. <para>
  446. The <code>confirmProduct</code> operation can only be executed by the
  447. owner of the <acronym>AMI</acronym>. This feature is useful when an <acronym>AMI</acronym> owner is providing
  448. support and wants to verify whether a user's instance is eligible.
  449. </para>
  450. <programlisting language="php"><![CDATA[
  451. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  452. 'aws_secret_key');
  453. $return = $ec2_instance->confirmProduct('productCode', 'instanceId');
  454. ]]></programlisting>
  455. </example>
  456. <example id="zend.service.amazon.ec2.instance.utility.monitor">
  457. <title>Turn on CloudWatch Monitoring on an Instance(s)</title>
  458. <para>
  459. <code>monitor</code> returns the list of instances and their
  460. current state of the CloudWatch Monitoring. If the instance
  461. does not currently have Monitoring enabled it will be turned on.
  462. </para>
  463. <programlisting language="php"><![CDATA[
  464. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  465. 'aws_secret_key');
  466. $return = $ec2_instance->monitor('instanceId');
  467. ]]></programlisting>
  468. </example>
  469. <example id="zend.service.amazon.ec2.instance.utility.unmonitor">
  470. <title>Turn off CloudWatch Monitoring on an Instance(s)</title>
  471. <para>
  472. <code>monitor</code> returns the list of instances and their
  473. current state of the CloudWatch Monitoring. If the instance
  474. currently has Monitoring enabled it will be turned off.
  475. </para>
  476. <programlisting language="php"><![CDATA[
  477. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  478. 'aws_secret_key');
  479. $return = $ec2_instance->unmonitor('instanceId');
  480. ]]></programlisting>
  481. </example>
  482. </sect2>
  483. </sect1>