2
0

Zend_Service_Amazon_Ec2-Instance.xml 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  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>
  51. <para>
  52. 1 <constant>EC2</constant> Compute Unit (1 virtual core with 1
  53. <constant>EC2</constant> Compute Unit)
  54. </para>
  55. </entry>
  56. <entry><para>1.7 GB</para></entry>
  57. <entry>
  58. <para>160 GB instance storage (150 GB plus 10 GB root partition)</para>
  59. </entry>
  60. <entry><para>32-bit</para></entry>
  61. <entry><para>Moderate</para></entry>
  62. <entry><para>m1.small</para></entry>
  63. <entry><constant>Zend_Service_Amazon_Ec2_Instance::SMALL</constant></entry>
  64. </row>
  65. <row>
  66. <entry><code>Large</code></entry>
  67. <entry>
  68. <para>
  69. 4 <constant>EC2</constant> Compute Units (2 virtual cores with 2
  70. <constant>EC2</constant> Compute Units each)
  71. </para>
  72. </entry>
  73. <entry><para>7.5 GB</para></entry>
  74. <entry>
  75. <para>
  76. 850 GB instance storage (2 x 420 GB plus 10 GB root partition)
  77. </para>
  78. </entry>
  79. <entry><para>64-bit</para></entry>
  80. <entry><para>High</para></entry>
  81. <entry><para>m1.large</para></entry>
  82. <entry><constant>Zend_Service_Amazon_Ec2_Instance::LARGE</constant></entry>
  83. </row>
  84. <row>
  85. <entry><code>Extra Large</code></entry>
  86. <entry>
  87. <para>
  88. 8 <constant>EC2</constant> Compute Units (4 virtual cores with 2
  89. <constant>EC2</constant> Compute Units each)
  90. </para>
  91. </entry>
  92. <entry><para>15 GB</para></entry>
  93. <entry>
  94. <para>
  95. 1,690 GB instance storage (4 x 420 GB plus 10 GB root partition)
  96. </para>
  97. </entry>
  98. <entry><para>64-bit</para></entry>
  99. <entry><para>High</para></entry>
  100. <entry><para>m1.xlarge</para></entry>
  101. <entry><constant>Zend_Service_Amazon_Ec2_Instance::XLARGE</constant></entry>
  102. </row>
  103. <row>
  104. <entry><code>High-CPU Medium</code></entry>
  105. <entry>
  106. <para>
  107. 5 <constant>EC2</constant> Compute Units (2 virtual cores with 2.5
  108. <constant>EC2</constant> Compute Units each)
  109. </para>
  110. </entry>
  111. <entry><para>1.7 GB</para></entry>
  112. <entry>
  113. <para>350 GB instance storage (340 GB plus 10 GB root partition)</para>
  114. </entry>
  115. <entry><para>32-bit</para></entry>
  116. <entry><para>Moderate</para></entry>
  117. <entry><para>c1.medium</para></entry>
  118. <entry>
  119. <constant>Zend_Service_Amazon_Ec2_Instance::HCPU_MEDIUM</constant>
  120. </entry>
  121. </row>
  122. <row>
  123. <entry><code>High-CPU Extra Large</code></entry>
  124. <entry>
  125. <para>
  126. 20 <constant>EC2</constant> Compute Units (8 virtual cores with 2.5
  127. <constant>EC2</constant> Compute Units each)
  128. </para>
  129. </entry>
  130. <entry><para>7 GB</para></entry>
  131. <entry>
  132. <para>
  133. 1,690 GB instance storage (4 x 420 GB plus 10 GB root partition)
  134. </para>
  135. </entry>
  136. <entry><para>64-bit</para></entry>
  137. <entry><para>High</para></entry>
  138. <entry><para>c1.xlarge</para></entry>
  139. <entry>
  140. <constant>Zend_Service_Amazon_Ec2_Instance::HCPU_XLARGE</constant>
  141. </entry>
  142. </row>
  143. </tbody>
  144. </tgroup>
  145. </table>
  146. </sect2>
  147. <sect2 id="zend.service.amazon.ec2.instance.operations">
  148. <title>Running Amazon EC2 Instances</title>
  149. <para>
  150. This section describes the operation methods for maintaining Amazon EC2 Instances.
  151. </para>
  152. <example id="zend.service.amazon.ec2.instance.operations.run">
  153. <title>Starting New Ec2 Instances</title>
  154. <para>
  155. <code>run</code> will launch a specified number of EC2 Instances.
  156. <code>run</code> takes an array of parameters to start, below is a table
  157. containing the valid values.
  158. </para>
  159. <para>
  160. <table id="zend.service.amazon.ec2.instance.operations.run-table">
  161. <title>Valid Run Options</title>
  162. <tgroup cols="3">
  163. <thead>
  164. <row>
  165. <entry>Name</entry>
  166. <entry>Description</entry>
  167. <entry>Required</entry>
  168. </row>
  169. </thead>
  170. <tbody>
  171. <row>
  172. <entry><code>imageId</code></entry>
  173. <entry>
  174. <para>
  175. ID of the <acronym>AMI</acronym> with which to launch
  176. instances.
  177. </para>
  178. </entry>
  179. <entry><para>Yes</para></entry>
  180. </row>
  181. <row>
  182. <entry><code>minCount</code></entry>
  183. <entry>
  184. <para>Minimum number of instances to launch. Default: 1</para>
  185. </entry>
  186. <entry><para>No</para></entry>
  187. </row>
  188. <row>
  189. <entry><code>maxCount</code></entry>
  190. <entry>
  191. <para>Maximum number of instances to launch. Default: 1</para>
  192. </entry>
  193. <entry><para>No</para></entry>
  194. </row>
  195. <row>
  196. <entry><code>keyName</code></entry>
  197. <entry>
  198. <para>
  199. Name of the key pair with which to launch instances.
  200. If you do not provide a key, all instances will
  201. be inaccessible.
  202. </para>
  203. </entry>
  204. <entry><para>No</para></entry>
  205. </row>
  206. <row>
  207. <entry><code>securityGroup</code></entry>
  208. <entry>
  209. <para>
  210. Names of the security groups with which to associate
  211. the instances.
  212. </para>
  213. </entry>
  214. <entry><para>No</para></entry>
  215. </row>
  216. <row>
  217. <entry><code>userData</code></entry>
  218. <entry>
  219. <para>
  220. The user data available to the launched instances.
  221. This should not be Base64 encoded.
  222. </para>
  223. </entry>
  224. <entry><para>No</para></entry>
  225. </row>
  226. <row>
  227. <entry><code>instanceType</code></entry>
  228. <entry>
  229. <para>
  230. Specifies the instance type. Default: m1.small
  231. </para>
  232. </entry>
  233. <entry><para>No</para></entry>
  234. </row>
  235. <row>
  236. <entry><code>placement</code></entry>
  237. <entry>
  238. <para>
  239. Specifies the availability zone in which to
  240. launch the instance(s). By default, Amazon
  241. <constant>EC2</constant> selects an availability zone for
  242. you.
  243. </para>
  244. </entry>
  245. <entry><para>No</para></entry>
  246. </row>
  247. <row>
  248. <entry><code>kernelId</code></entry>
  249. <entry>
  250. <para>
  251. The ID of the kernel with which to launch
  252. the instance.
  253. </para>
  254. </entry>
  255. <entry><para>No</para></entry>
  256. </row>
  257. <row>
  258. <entry><code>ramdiskId</code></entry>
  259. <entry>
  260. <para>
  261. The ID of the <acronym>RAM</acronym> disk with which to
  262. launch the instance.
  263. </para>
  264. </entry>
  265. <entry><para>No</para></entry>
  266. </row>
  267. <row>
  268. <entry><code>blockDeviceVirtualName</code></entry>
  269. <entry>
  270. <para>
  271. Specifies the virtual name to map to the
  272. corresponding device name. For example:
  273. instancestore0
  274. </para>
  275. </entry>
  276. <entry><para>No</para></entry>
  277. </row>
  278. <row>
  279. <entry><code>blockDeviceName</code></entry>
  280. <entry>
  281. <para>
  282. Specifies the device to which you are
  283. mapping a virtual name. For example: sdb
  284. </para>
  285. </entry>
  286. <entry><para>No</para></entry>
  287. </row>
  288. <row>
  289. <entry><code>monitor</code></entry>
  290. <entry>
  291. <para>
  292. Turn on <acronym>AWS</acronym> CloudWatch Instance
  293. Monitoring
  294. </para>
  295. </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 <constant>TRUE</constant> or
  328. <constant>FALSE</constant>
  329. </para>
  330. <programlisting language="php"><![CDATA[
  331. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  332. 'aws_secret_key');
  333. $return = $ec2_instance->reboot('instanceId');
  334. ]]></programlisting>
  335. </example>
  336. <example id="zend.service.amazon.ec2.instance.operations.terminate">
  337. <title>Terminating an Ec2 Instances</title>
  338. <para>
  339. <code>terminate</code> shuts down one or more instances. This
  340. operation is idempotent; if you terminate an instance more
  341. than once, each call will succeed.
  342. </para>
  343. <para>
  344. <code>terminate</code> returns boolean <constant>TRUE</constant> or
  345. <constant>FALSE</constant>
  346. </para>
  347. <programlisting language="php"><![CDATA[
  348. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  349. 'aws_secret_key');
  350. $return = $ec2_instance->terminate('instanceId');
  351. ]]></programlisting>
  352. </example>
  353. <note>
  354. <title>Terminated Instances</title>
  355. <para>Terminated instances will remain visible after termination
  356. (approximately one hour).</para>
  357. </note>
  358. </sect2>
  359. <sect2 id="zend.service.amazon.ec2.instance.utility">
  360. <title>Amazon Instance Utilities</title>
  361. <para>
  362. In this section you will find out how to retreive information, the console
  363. output and see if an instance contains a product code.
  364. </para>
  365. <example id="zend.service.amazon.ec2.instance.utility.describe">
  366. <title>Describing Instances</title>
  367. <para>
  368. <code>describe</code> returns information about instances that you own.
  369. </para>
  370. <para>
  371. If you specify one or more instance IDs, Amazon EC2 returns information
  372. for those instances. If you do not specify instance IDs, Amazon EC2
  373. returns information for all relevant instances. If you specify an invalid
  374. instance ID, a fault is returned. If you specify an instance that you do
  375. not own, it will not be included in the returned results.
  376. </para>
  377. <para>
  378. <code>describe</code> will return an array containing information on the
  379. instance.
  380. </para>
  381. <programlisting language="php"><![CDATA[
  382. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  383. 'aws_secret_key');
  384. $return = $ec2_instance->describe('instanceId');
  385. ]]></programlisting>
  386. </example>
  387. <note>
  388. <title>Terminated Instances</title>
  389. <para>
  390. Recently terminated instances might appear in the returned results. This interval is
  391. usually less than one hour. If you do not want terminated instances to be returned,
  392. pass in a second variable of boolean <constant>TRUE</constant> to
  393. <code>describe</code> and the terminated instances will be ignored.
  394. </para>
  395. </note>
  396. <example id="zend.service.amazon.ec2.instance.utility.describebyimageid">
  397. <title>Describing Instances By Image Id</title>
  398. <para>
  399. <code>describeByImageId</code> is functionally the same as <code>describe</code>
  400. but it will only return the instances that are using the provided imageId.
  401. </para>
  402. <para>
  403. <code>describeByImageId</code> will return an array containing information on the
  404. instances thare were started by the passed in imageId
  405. </para>
  406. <programlisting language="php"><![CDATA[
  407. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  408. 'aws_secret_key');
  409. $return = $ec2_instance->describeByImageId('imageId');
  410. ]]></programlisting>
  411. </example>
  412. <note>
  413. <title>Terminated Instances</title>
  414. <para>
  415. Recently terminated instances might appear in the returned results. This
  416. interval is usually less than one hour. If you do not want terminated
  417. instances to be returned, pass in a second variable of boolean
  418. <constant>TRUE</constant> to <code>describe</code> and the terminated instances
  419. will be ignored.
  420. </para>
  421. </note>
  422. <example id="zend.service.amazon.ec2.instance.utility.consoleOutput">
  423. <title>Retreiving Console Output</title>
  424. <para>
  425. <code>consoleOutput</code> retrieves console output for the specified
  426. instance.
  427. </para>
  428. <para>
  429. Instance console output is buffered and posted shortly after instance
  430. boot, reboot, and termination. Amazon EC2 preserves the most recent
  431. 64 KB output which will be available for at least one hour after the
  432. most recent post.
  433. </para>
  434. <para>
  435. <code>consoleOutput</code> returns an array containing the
  436. <code>instanceId</code>, <code>timestamp</code> from the last output
  437. and the <code>output</code> from the console.
  438. </para>
  439. <programlisting language="php"><![CDATA[
  440. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  441. 'aws_secret_key');
  442. $return = $ec2_instance->consoleOutput('instanceId');
  443. ]]></programlisting>
  444. </example>
  445. <example id="zend.service.amazon.ec2.instance.utility.confirmproduct">
  446. <title>Confirm Product Code on an Instance</title>
  447. <para>
  448. <code>confirmProduct</code> returns <constant>TRUE</constant> if the specified
  449. product code is attached to the specified instance. The operation returns
  450. <constant>FALSE</constant> if the product code is not attached to the instance.
  451. </para>
  452. <para>
  453. The <code>confirmProduct</code> operation can only be executed by the owner of the
  454. <acronym>AMI</acronym>. This feature is useful when an <acronym>AMI</acronym> owner
  455. is providing support and wants to verify whether a user's instance is eligible.
  456. </para>
  457. <programlisting language="php"><![CDATA[
  458. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  459. 'aws_secret_key');
  460. $return = $ec2_instance->confirmProduct('productCode', 'instanceId');
  461. ]]></programlisting>
  462. </example>
  463. <example id="zend.service.amazon.ec2.instance.utility.monitor">
  464. <title>Turn on CloudWatch Monitoring on an Instance(s)</title>
  465. <para>
  466. <code>monitor</code> returns the list of instances and their
  467. current state of the CloudWatch Monitoring. If the instance
  468. does not currently have Monitoring enabled it will be turned on.
  469. </para>
  470. <programlisting language="php"><![CDATA[
  471. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  472. 'aws_secret_key');
  473. $return = $ec2_instance->monitor('instanceId');
  474. ]]></programlisting>
  475. </example>
  476. <example id="zend.service.amazon.ec2.instance.utility.unmonitor">
  477. <title>Turn off CloudWatch Monitoring on an Instance(s)</title>
  478. <para>
  479. <code>monitor</code> returns the list of instances and their
  480. current state of the CloudWatch Monitoring. If the instance
  481. currently has Monitoring enabled it will be turned off.
  482. </para>
  483. <programlisting language="php"><![CDATA[
  484. $ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
  485. 'aws_secret_key');
  486. $return = $ec2_instance->unmonitor('instanceId');
  487. ]]></programlisting>
  488. </example>
  489. </sect2>
  490. </sect1>