私はEC2をいじっていますが、これが私のシナリオです:
1 回: 必要なキー ペアを使用して EC2 インスタンスを作成しました。
毎日 :
fire up an EC2 instance.
send a file of IDs to EC2 micro-instance from local machine.
fire a python script to process the IDs and generate an output file.
fetch the output file to the local machine from the EC2 instance.
stop the EC2 instance.
要因 :
I am using the same EC2 instance every time I want to process this file.
I want to keep costs down, so I want to cron the whole process to start and stop at a certain time interval.
大まかなコード:
from boto.ec2.connection import EC2Connection
AWS_ACCESS_KEY_ID = 'yourkey'
AWS_SECRET_ACCESS_KEY = 'yoursecret'
conn = EC2Connection(AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY)
reservation = conn.run_instances('ami-5647a33f', instance_type='m1.micro', key_name='mykey')
instance = reservation.instances[0]
while not instance.update() == 'running':
time.sleep(5)
## Fetch the file from local machine
## --> Do the processing here --<
## send the file back to the local machine
# time up for the day, stop it
instance.stop()
現在、EC2 インスタンスを手動で開始および停止し、ファイルを前後に rsync しています。このステップをなくしたい。これが最善の方法ですか、それとも何か提案はありますか? ローカル マシンからのサンプル入力ファイル (abc.txt) を使用してコードにいくつかの行を追加し、ec2 でファイルの内容を出力し、それを out.txt に出力してフェッチすることができる場合。パスワード プロンプトを表示せずにファイルを転送することは、困難であることがわかっています。(最終的にはホストファイルに追加されますが、まだ調べていません)
SOersさん、ありがとうございます!