anoop-khandelwal
anoop-khandelwal

Reputation: 3860

How to change aws-ec2 instance type?

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?

Upvotes: 2

Views: 1852

Answers (1)

Mircea
Mircea

Reputation: 10566

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

Upvotes: 2

Related Questions