How to change aws-ec2 instance type?

余生颓废 提交于 2020-01-03 02:28:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!