File: Zend_Service_Amazon_Ec2-Instance.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (609 lines) | stat: -rw-r--r-- 25,186 bytes parent folder | download | duplicates (2)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.service.amazon.ec2.instance">
    <title>Zend_Service_Amazon_Ec2: Instances</title>

    <sect2 id="zend.service.amazon.ec2.instance.types">
        <title>Instance Types</title>

        <para>
            Amazon EC2 instances are grouped into two families: standard and
            High-CPU. Standard instances have memory to <acronym>CPU</acronym> ratios suitable
            for most general purpose applications; High-CPU instances have
            proportionally more <acronym>CPU</acronym> resources than memory (RAM) and are well
            suited for compute-intensive applications. When selecting instance
            types, you might want to use less powerful instance types for your
            web server instances and more powerful instance types for your
            database instances. Additionally, you might want to run <acronym>CPU</acronym> instance
            types for <acronym>CPU</acronym>-intensive data processing tasks.
        </para>

        <para>
            One of the advantages of EC2 is that you pay by the instance hour,
            which makes it convenient and inexpensive to test the performance of
            your application on different instance families and types. One good
            way to determine the most appropriate instance family and instance
            type is to launch test instances and benchmark your application.
        </para>

        <note>
            <title>Instance Types</title>

            <para>
                The instance types are defined as constants in the code. Column eight
                in the table is the defined constant name
            </para>
        </note>

        <table id="zend.service.amazon.ec2.instance.types-table">
            <title>Available Instance Types</title>

            <tgroup cols="8">
                <thead>
                    <row>
                        <entry>Type</entry>
                        <entry><acronym>CPU</acronym></entry>
                        <entry>Memory</entry>
                        <entry>Storage</entry>
                        <entry>Platform</entry>
                        <entry>I/O</entry>
                        <entry>Name</entry>
                        <entry>Constant Name</entry>
                    </row>
                </thead>

                <tbody>
                    <row>
                        <entry><code>Small</code></entry>

                        <entry>
                            <para>
                                1 <constant>EC2</constant> Compute Unit (1 virtual core with 1
                                <constant>EC2</constant> Compute Unit)
                            </para>
                        </entry>

                        <entry><para>1.7 GB</para></entry>

                        <entry>
                            <para>160 GB instance storage (150 GB plus 10 GB root partition)</para>
                        </entry>

                        <entry><para>32-bit</para></entry>
                        <entry><para>Moderate</para></entry>
                        <entry><para>m1.small</para></entry>
                        <entry><constant>Zend_Service_Amazon_Ec2_Instance::SMALL</constant></entry>
                    </row>

                    <row>
                        <entry><code>Large</code></entry>

                        <entry>
                            <para>
                                4 <constant>EC2</constant> Compute Units (2 virtual cores with 2
                                <constant>EC2</constant> Compute Units each)
                            </para>
                        </entry>

                        <entry><para>7.5 GB</para></entry>

                        <entry>
                            <para>
                                850 GB instance storage (2 x 420 GB plus 10 GB root partition)
                            </para>
                        </entry>

                        <entry><para>64-bit</para></entry>
                        <entry><para>High</para></entry>
                        <entry><para>m1.large</para></entry>
                        <entry><constant>Zend_Service_Amazon_Ec2_Instance::LARGE</constant></entry>
                    </row>

                    <row>
                        <entry><code>Extra Large</code></entry>
                        <entry>
                            <para>
                                8 <constant>EC2</constant> Compute Units (4 virtual cores with 2
                                <constant>EC2</constant> Compute Units each)
                            </para>
                        </entry>

                        <entry><para>15 GB</para></entry>

                        <entry>
                            <para>
                                1,690 GB instance storage (4 x 420 GB plus 10 GB root partition)
                            </para>
                        </entry>

                        <entry><para>64-bit</para></entry>
                        <entry><para>High</para></entry>
                        <entry><para>m1.xlarge</para></entry>
                        <entry><constant>Zend_Service_Amazon_Ec2_Instance::XLARGE</constant></entry>
                    </row>

                    <row>
                        <entry><code>High-CPU Medium</code></entry>

                        <entry>
                            <para>
                                5 <constant>EC2</constant> Compute Units (2 virtual cores with 2.5
                                <constant>EC2</constant> Compute Units each)
                            </para>
                        </entry>

                        <entry><para>1.7 GB</para></entry>

                        <entry>
                            <para>350 GB instance storage (340 GB plus 10 GB root partition)</para>
                        </entry>

                        <entry><para>32-bit</para></entry>
                        <entry><para>Moderate</para></entry>
                        <entry><para>c1.medium</para></entry>

                        <entry>
                            <constant>Zend_Service_Amazon_Ec2_Instance::HCPU_MEDIUM</constant>
                        </entry>
                    </row>

                    <row>
                        <entry><code>High-CPU Extra Large</code></entry>

                        <entry>
                            <para>
                                20 <constant>EC2</constant> Compute Units (8 virtual cores with 2.5
                                <constant>EC2</constant> Compute Units each)
                            </para>
                        </entry>

                        <entry><para>7 GB</para></entry>

                        <entry>
                            <para>
                                1,690 GB instance storage (4 x 420 GB plus 10 GB root partition)
                            </para>
                        </entry>

                        <entry><para>64-bit</para></entry>
                        <entry><para>High</para></entry>
                        <entry><para>c1.xlarge</para></entry>

                        <entry>
                            <constant>Zend_Service_Amazon_Ec2_Instance::HCPU_XLARGE</constant>
                        </entry>
                    </row>
                </tbody>
            </tgroup>
        </table>
    </sect2>

    <sect2 id="zend.service.amazon.ec2.instance.operations">
        <title>Running Amazon EC2 Instances</title>

        <para>
            This section describes the operation methods for maintaining Amazon EC2 Instances.
        </para>

        <example id="zend.service.amazon.ec2.instance.operations.run">
            <title>Starting New Ec2 Instances</title>

            <para>
                <code>run</code> will launch a specified number of EC2 Instances.
                <code>run</code> takes an array of parameters to start, below is a table
                containing the valid values.
            </para>

            <para>
                <table id="zend.service.amazon.ec2.instance.operations.run-table">
                    <title>Valid Run Options</title>

                    <tgroup cols="3">
                        <thead>
                            <row>
                                <entry>Name</entry>
                                <entry>Description</entry>
                                <entry>Required</entry>
                            </row>
                        </thead>

                        <tbody>
                            <row>
                                <entry><code>imageId</code></entry>

                                <entry>
                                    <para>
                                        ID of the <acronym>AMI</acronym> with which to launch
                                        instances.
                                    </para>
                                </entry>

                                <entry><para>Yes</para></entry>
                            </row>

                            <row>
                                <entry><code>minCount</code></entry>

                                <entry>
                                    <para>Minimum number of instances to launch. Default: 1</para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>maxCount</code></entry>

                                <entry>
                                    <para>Maximum number of instances to launch. Default: 1</para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>keyName</code></entry>

                                <entry>
                                    <para>
                                        Name of the key pair with which to launch instances.
                                        If you do not provide a key, all instances will
                                        be inaccessible.
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>securityGroup</code></entry>

                                <entry>
                                    <para>
                                        Names of the security groups with which to associate
                                        the instances.
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>userData</code></entry>

                                <entry>
                                    <para>
                                        The user data available to the launched instances.
                                        This should not be Base64 encoded.
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>instanceType</code></entry>

                                <entry>
                                    <para>
                                        Specifies the instance type. Default: m1.small
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>placement</code></entry>

                                <entry>
                                    <para>
                                        Specifies the availability zone in which to
                                        launch the instance(s). By default, Amazon
                                        <constant>EC2</constant> selects an availability zone for
                                        you.
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>kernelId</code></entry>

                                <entry>
                                    <para>
                                        The ID of the kernel with which to launch
                                        the instance.
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>ramdiskId</code></entry>

                                <entry>
                                    <para>
                                        The ID of the <acronym>RAM</acronym> disk with which to
                                        launch the instance.
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>blockDeviceVirtualName</code></entry>

                                <entry>
                                    <para>
                                        Specifies the virtual name to map to the
                                        corresponding device name. For example:
                                        instancestore0
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>

                            <row>
                                <entry><code>blockDeviceName</code></entry>

                                <entry>
                                    <para>
                                         Specifies the device to which you are
                                         mapping a virtual name. For example: sdb
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>
                            <row>
                                <entry><code>monitor</code></entry>

                                <entry>
                                    <para>
                                         Turn on <acronym>AWS</acronym> CloudWatch Instance
                                         Monitoring
                                    </para>
                                </entry>

                                <entry><para>No</para></entry>
                            </row>
                        </tbody>
                    </tgroup>
                </table>
            </para>

            <para>
                <code>run</code> will return information about each instance
                that is starting up.
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->run(array('imageId' => 'ami-509320',
                                   'keyName' => 'myKey',
                                   'securityGroup' => array('web',
                                                            'default')));
]]></programlisting>
        </example>

        <example id="zend.service.amazon.ec2.instance.operations.reboot">
            <title>Rebooting an Ec2 Instances</title>

            <para>
                <code>reboot</code> will reboot one or more instances.
            </para>

            <para>
                This operation is asynchronous; it only queues a request to
                reboot the specified instance(s). The operation will succeed
                if the instances are valid and belong to the user. Requests
                to reboot terminated instances are ignored.
            </para>

            <para>
                <code>reboot</code> returns boolean <constant>TRUE</constant> or
                <constant>FALSE</constant>
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->reboot('instanceId');
]]></programlisting>
        </example>

        <example id="zend.service.amazon.ec2.instance.operations.terminate">
            <title>Terminating an Ec2 Instances</title>

            <para>
                <code>terminate</code> shuts down one or more instances. This
                operation is idempotent; if you terminate an instance more
                than once, each call will succeed.
            </para>

            <para>
                <code>terminate</code> returns boolean <constant>TRUE</constant> or
                <constant>FALSE</constant>
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->terminate('instanceId');
]]></programlisting>
        </example>

        <note>
            <title>Terminated Instances</title>
            <para>Terminated instances will remain visible after termination
            (approximately one hour).</para>
        </note>
    </sect2>

    <sect2 id="zend.service.amazon.ec2.instance.utility">
        <title>Amazon Instance Utilities</title>

        <para>
            In this section you will find out how to retreive information, the console
            output and see if an instance contains a product code.
        </para>

        <example id="zend.service.amazon.ec2.instance.utility.describe">
            <title>Describing Instances</title>

            <para>
                <code>describe</code> returns information about instances that you own.
            </para>

            <para>
                If you specify one or more instance IDs, Amazon EC2 returns information
                for those instances. If you do not specify instance IDs, Amazon EC2
                returns information for all relevant instances. If you specify an invalid
                instance ID, a fault is returned. If you specify an instance that you do
                not own, it will not be included in the returned results.
            </para>

            <para>
                <code>describe</code> will return an array containing information on the
                instance.
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->describe('instanceId');
]]></programlisting>
        </example>

        <note>
            <title>Terminated Instances</title>

            <para>
                Recently terminated instances might appear in the returned results. This interval is
                usually less than one hour. If you do not want terminated instances to be returned,
                pass in a second variable of boolean <constant>TRUE</constant> to
                <code>describe</code> and the terminated instances will be ignored.
            </para>
        </note>

        <example id="zend.service.amazon.ec2.instance.utility.describebyimageid">
            <title>Describing Instances By Image Id</title>

            <para>
                <code>describeByImageId</code> is functionally the same as <code>describe</code>
                but it will only return the instances that are using the provided imageId.
            </para>

            <para>
                <code>describeByImageId</code> will return an array containing information on the
                instances thare were started by the passed in imageId
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->describeByImageId('imageId');
]]></programlisting>
        </example>

        <note>
            <title>Terminated Instances</title>

            <para>
                Recently terminated instances might appear in the returned results. This
                interval is usually less than one hour. If you do not want terminated
                instances to be returned, pass in a second variable of boolean
                <constant>TRUE</constant> to <code>describe</code> and the terminated instances
                will be ignored.
            </para>
        </note>

        <example id="zend.service.amazon.ec2.instance.utility.consoleOutput">
            <title>Retreiving Console Output</title>

            <para>
                <code>consoleOutput</code> retrieves console output for the specified
                instance.
            </para>

            <para>
                Instance console output is buffered and posted shortly after instance
                boot, reboot, and termination. Amazon EC2 preserves the most recent
                64 KB output which will be available for at least one hour after the
                most recent post.
            </para>

            <para>
                <code>consoleOutput</code> returns an array containing the
                <code>instanceId</code>, <code>timestamp</code> from the last output
                and the <code>output</code> from the console.
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->consoleOutput('instanceId');
]]></programlisting>
        </example>

        <example id="zend.service.amazon.ec2.instance.utility.confirmproduct">
            <title>Confirm Product Code on an Instance</title>

            <para>
                <code>confirmProduct</code> returns <constant>TRUE</constant> if the specified
                product code is attached to the specified instance. The operation returns
                <constant>FALSE</constant> if the product code is not attached to the instance.
            </para>

            <para>
                The <code>confirmProduct</code> operation can only be executed by the owner of the
                <acronym>AMI</acronym>. This feature is useful when an <acronym>AMI</acronym> owner
                is providing support and wants to verify whether a user's instance is eligible.
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->confirmProduct('productCode', 'instanceId');
]]></programlisting>
        </example>

        <example id="zend.service.amazon.ec2.instance.utility.monitor">
            <title>Turn on CloudWatch Monitoring on an Instance(s)</title>

            <para>
                <code>monitor</code> returns the list of instances and their
                current state of the CloudWatch Monitoring. If the instance
                does not currently have Monitoring enabled it will be turned on.
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->monitor('instanceId');
]]></programlisting>
        </example>

        <example id="zend.service.amazon.ec2.instance.utility.unmonitor">
            <title>Turn off CloudWatch Monitoring on an Instance(s)</title>

            <para>
                <code>monitor</code> returns the list of instances and their
                current state of the CloudWatch Monitoring. If the instance
                currently has Monitoring enabled it will be turned off.
            </para>

            <programlisting language="php"><![CDATA[
$ec2_instance = new Zend_Service_Amazon_Ec2_Instance('aws_key',
                                                     'aws_secret_key');
$return = $ec2_instance->unmonitor('instanceId');
]]></programlisting>
        </example>
    </sect2>
</sect1>