2016-07-29 9 views
1

私は、EC2インスタンスを停止し、インスタンスのサイズを変更し、インスタンスのバックアップを開始するPython 2.7スクリプトを作成しています。 boto3を使用してインスタンスのサイズを変更する方法はありますか?そうでない場合は、プログラムでインスタンスのサイズ変更を処理する別の方法がありますか?boto3を使用してEC2インスタンスのサイズを変更する

+0

ゴーSO行い、リサイズすることによりhttp://stackoverflow.com/questions/31907783/how-to-change-aws-ec2-instance-type – error2007s

+1

を疑問視インスタンスの種類を変更するか、EBSのボリュームサイズを変更することを意味しますか? –

+0

@ KarenB私は、私はインスタンスの種類を変更することを意味していたはずです。 – danielhklein

答えて

4

これが動作しているようです。この貫通

import boto3 

client = boto3.client('ec2') 

# Insert your Instance ID here 
my_instance = 'i-xxxxxxxx' 

# Stop the instance 
client.stop_instances(InstanceIds=[my_instance]) 
waiter=client.get_waiter('instance_stopped') 
waiter.wait(InstanceIds=[my_instance]) 

# Change the instance type 
client.modify_instance_attribute(InstanceId=my_instance, Attribute='instanceType', Value='m3.xlarge') 

# Start the instance 
client.start_instances(InstanceIds=[my_instance]) 
関連する問題