forked from migurski/Extractotron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-instance.py
More file actions
36 lines (26 loc) · 1.03 KB
/
Copy pathrun-instance.py
File metadata and controls
36 lines (26 loc) · 1.03 KB
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
""" Run an extractor instance.
"""
from optparse import OptionParser
from boto.ec2 import EC2Connection
parser = OptionParser(usage="%prog [options] <aws key> <aws secret> <s3 bucket>")
defaults = dict(ami_id='ami-e2af508b', type='m1.small')
parser.set_defaults(**defaults)
parser.add_option('--ami-id', dest='ami_id',
help='AMI ID, default %(ami_id)s' % defaults)
parser.add_option('--type', dest='type',
help='Instance type, default %(type)s' % defaults)
if __name__ == '__main__':
try:
options, (aws_key, aws_secret, s3_bucket) = parser.parse_args()
except ValueError:
parser.print_usage()
exit(1)
conn = EC2Connection(aws_key, aws_secret)
user_data = """#!/bin/sh
K=%(aws_key)s
S=%(aws_secret)s
B=%(s3_bucket)s
U=https://raw.github.com/migurski/Extractotron/master/extract.sh
curl -s $U | KEY=$K SECRET=$S BUCKET=$B sh > /mnt/progress.txt 2>&1
""" % locals()
print conn.run_instances(options.ami_id, instance_type=options.type, user_data=user_data)