Python and AWS Cookbook.pdf

(4699 KB) Pobierz
779505792.009.png
779505792.010.png
Python and AWS Cookbook
Mitch Garnaat
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
779505792.011.png 779505792.012.png 779505792.001.png 779505792.002.png 779505792.003.png 779505792.004.png 779505792.005.png 779505792.006.png
 
Python and AWS Cookbook
by Mitch Garnaat
Copyright © 2012 Mitch Garnaat. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles ( http://my.safaribooksonline.com ) . For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com .
Editors: Julie Steele and Meghan Blanchette
Production Editor: Teresa Elsey
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Revision History for the First Edition:
2011-10-21 First release
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Python and AWS Cookbook , the image of a sand grouse, and related trade dress are
trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-30544-4
[LSI]
1319206024
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
1.
General Info . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 A Quick Note About Python
1
1.2 Installing boto
1
1.3 Getting Started with Amazon Web Services
4
1.4 Using boto with Eucalyptus
7
1.5 Using boto with Google Cloud Storage
8
1.6 Finding Available Regions for AWS
9
1.7 Enabling Debug Output with boto
10
1.8 Controlling Socket Timeouts in boto
10
2.
EC2 Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1 Launching an Instance
11
2.2 Keeping Track of Instances with Tags
15
2.3 Accessing the Console Log
17
2.4 Uploading Your Own SSH Keypair
17
2.5 Synchronizing SSH Keypairs Across EC2 Regions
18
2.6 Associate an Elastic IP Address with an Instance
19
2.7 Attach a Persistent EBS Volume to an Instance
20
2.8 Back Up Your EBS Volumes
22
2.9 Restore a Volume from a Snapshot
23
2.10 Clone an Existing Instance
24
2.11 Find All Running EC2 Instances
26
2.12 Monitoring the Performance of Your Instance
27
2.13 Getting Notifications
31
2.14 Storing Custom Data in CloudWatch
36
2.15 Executing Custom Scripts upon Instance Startup
37
3.
S3 Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.1 Create a Bucket
47
iii
779505792.007.png 779505792.008.png
Zgłoś jeśli naruszono regulamin