Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: third_party/gsutil/boto/docs/source/ec2_tut.rst

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 There are two ways to do this in boto. The first is::
16
17 >>> from boto.ec2.connection import EC2Connection
18 >>> conn = EC2Connection('<AWS_ACCESS_KEY_ID>', '<AWS_SECRET_ACCESS_KEY>')
19
20 At this point the variable conn will point to an EC2Connection object. In
21 this example, the AWS access key and AWS secret key are passed in to the
22 method explicitely. Alternatively, you can set the boto config environment vari ables
23 and then call the constructor without any arguments, like this::
24
25 >>> conn = EC2Connection()
26
27 There is also a shortcut function in the boto package, called connect_ec2
28 that may provide a slightly easier means of creating a connection::
29
30 >>> import boto
31 >>> conn = boto.connect_ec2()
32
33 In either case, conn will point to an EC2Connection object which we will
34 use throughout the remainder of this tutorial.
35
36 Launching Instances
37 -------------------
38
39 Possibly, the most important and common task you'll use EC2 for is to launch,
40 stop and terminate instances. In its most primitive form, you can launch an
41 instance as follows::
42
43 >>> conn.run_instances('<ami-image-id>')
44
45 This will launch an instance in the specified region with the default parameters .
46 You will not be able to SSH into this machine, as it doesn't have a security
47 group set. See :doc:`security_groups` for details on creating one.
48
49 Now, let's say that you already have a key pair, want a specific type of
50 instance, and you have your :doc:`security group <security_groups>` all setup.
51 In this case we can use the keyword arguments to accomplish that::
52
53 >>> conn.run_instances(
54 '<ami-image-id>',
55 key_name='myKey',
56 instance_type='c1.xlarge',
57 security_groups=['your-security-group-here'])
58
59 The main caveat with the above call is that it is possible to request an
60 instance type that is not compatible with the provided AMI (for example, the
61 instance was created for a 64-bit instance and you choose a m1.small instance_ty pe).
62 For more details on the plethora of possible keyword parameters, be sure to
63 check out boto's :doc:`EC2 API reference <ref/ec2>`.
64
65 Stopping Instances
66 ------------------
67 Once you have your instances up and running, you might wish to shut them down
68 if they're not in use. Please note that this will only de-allocate virtual
69 hardware resources (as well as instance store drives), but won't destroy your
70 EBS volumes -- this means you'll pay nominal provisioned EBS storage fees
71 even if your instance is stopped. To do this, you can do so as follows::
72
73 >>> conn.stop_instances(instance_ids=['instance-id-1','instance-id-2', ...])
74
75 This will request a 'graceful' stop of each of the specified instances. If you
76 wish to request the equivalent of unplugging your instance(s), simply add
77 ``force=True`` keyword argument to the call above. Please note that stop
78 instance is not allowed with Spot instances.
79
80 Terminating Instances
81 ---------------------
82 Once you are completely done with your instance and wish to surrender both
83 virtual hardware, root EBS volume and all other underlying components
84 you can request instance termination. To do so you can use the call bellow::
85
86 >>> conn.terminate_instances(instance_ids=['instance-id-1','instance-id-2', ...])
87
88 Please use with care since once you request termination for an instance there
89 is no turning back.
90
OLDNEW
« no previous file with comments | « third_party/gsutil/boto/docs/source/dynamodb_tut.rst ('k') | third_party/gsutil/boto/docs/source/elb_tut.rst » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698