问题
I wanted to change the aws-ec2 instance type(e.g from micro to large or vice-versa etc) using Boto3. What are the factors that needs to be care while changing the instance type of ec2-instances. Here is my code:
def get_ec2_boto3_connection(region, arn):
sess = Boto3Connecton.get_boto3_session(arn)
ec2_conn = sess.client(service_name='ec2', region_name=region)
return ec2_conn
def change_instance_type(arn,region):
ec2_conn=get_ec2_boto3_connection(region,arn)
ec2_conn.modify_instance_attribute(InstanceId=id,Attribute='instanceType'InstanceType={
'Value': 'm4.large'
})
What are the accountable factors,to be taken care of before changing the instance type of an ec2 instance?
回答1:
see: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-resize.html
basically it depends if it's ebs backed or instance store. you can only resize ebs backed instances (for instance store - you need to spin up a new instance, migrate, tear down old isntace). there are also compatibility issues that you need to make are satisfied before attempting a resize
来源:https://stackoverflow.com/questions/31907783/how-to-change-aws-ec2-instance-type