| OLD | NEW | 
| (Empty) |  | 
 |   1 .. _ec2_tut: | 
 |   2  | 
 |   3 ======================================= | 
 |   4 An Introduction to boto's EC2 interface | 
 |   5 ======================================= | 
 |   6  | 
 |   7 This tutorial focuses on the boto interface to the Elastic Compute Cloud | 
 |   8 from Amazon Web Services.  This tutorial assumes that you have already | 
 |   9 downloaded and installed boto. | 
 |  10  | 
 |  11 Creating a Connection | 
 |  12 --------------------- | 
 |  13  | 
 |  14 The first step in accessing EC2 is to create a connection to the service. | 
 |  15 The recommended way of doing this in boto is:: | 
 |  16  | 
 |  17     >>> from boto.ec2 | 
 |  18     >>> conn = boto.ec2.connect_to_region("us-east-1", | 
 |  19     ...    aws_access_key_id='<aws access key>', | 
 |  20     ...    aws_secret_access_key='<aws secret key>') | 
 |  21  | 
 |  22 At this point the variable ``conn`` will point to an EC2Connection object.  In | 
 |  23 this example, the AWS access key and AWS secret key are passed in to the method | 
 |  24 explicitly.  Alternatively, you can set the boto config environment variables | 
 |  25 and then simply specify which region you want as follows:: | 
 |  26  | 
 |  27     >>> conn = boto.ec2.connect_to_region("us-east-1") | 
 |  28  | 
 |  29 In either case, conn will point to an EC2Connection object which we will | 
 |  30 use throughout the remainder of this tutorial. | 
 |  31  | 
 |  32 Launching Instances | 
 |  33 ------------------- | 
 |  34  | 
 |  35 Possibly, the most important and common task you'll use EC2 for is to launch, | 
 |  36 stop and terminate instances. In its most primitive form, you can launch an | 
 |  37 instance as follows:: | 
 |  38  | 
 |  39     >>> conn.run_instances('<ami-image-id>') | 
 |  40  | 
 |  41 This will launch an instance in the specified region with the default parameters
    . | 
 |  42 You will not be able to SSH into this machine, as it doesn't have a security | 
 |  43 group set. See :doc:`security_groups` for details on creating one. | 
 |  44  | 
 |  45 Now, let's say that you already have a key pair, want a specific type of | 
 |  46 instance, and you have your :doc:`security group <security_groups>` all setup. | 
 |  47 In this case we can use the keyword arguments to accomplish that:: | 
 |  48  | 
 |  49     >>> conn.run_instances( | 
 |  50             '<ami-image-id>', | 
 |  51             key_name='myKey', | 
 |  52             instance_type='c1.xlarge', | 
 |  53             security_groups=['your-security-group-here']) | 
 |  54  | 
 |  55 The main caveat with the above call is that it is possible to request an | 
 |  56 instance type that is not compatible with the provided AMI (for example, the | 
 |  57 instance was created for a 64-bit instance and you choose a m1.small instance_ty
    pe). | 
 |  58 For more details on the plethora of possible keyword parameters, be sure to | 
 |  59 check out boto's :doc:`EC2 API reference <ref/ec2>`. | 
 |  60  | 
 |  61 Stopping Instances | 
 |  62 ------------------ | 
 |  63 Once you have your instances up and running, you might wish to shut them down | 
 |  64 if they're not in use. Please note that this will only de-allocate virtual | 
 |  65 hardware resources (as well as instance store drives), but won't destroy your | 
 |  66 EBS volumes -- this means you'll pay nominal provisioned EBS storage fees | 
 |  67 even if your instance is stopped. To do this, you can do so as follows:: | 
 |  68  | 
 |  69     >>> conn.stop_instances(instance_ids=['instance-id-1','instance-id-2', ...]) | 
 |  70  | 
 |  71 This will request a 'graceful' stop of each of the specified instances. If you | 
 |  72 wish to request the equivalent of unplugging your instance(s), simply add | 
 |  73 ``force=True`` keyword argument to the call above. Please note that stop | 
 |  74 instance is not allowed with Spot instances. | 
 |  75  | 
 |  76 Terminating Instances | 
 |  77 --------------------- | 
 |  78 Once you are completely done with your instance and wish to surrender both | 
 |  79 virtual hardware, root EBS volume and all other underlying components | 
 |  80 you can request instance termination. To do so you can use the call bellow:: | 
 |  81  | 
 |  82     >>> conn.terminate_instances(instance_ids=['instance-id-1','instance-id-2', 
    ...]) | 
 |  83  | 
 |  84 Please use with care since once you request termination for an instance there | 
 |  85 is no turning back. | 
 |  86  | 
| OLD | NEW |