Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change instance type in runtime

how to change instance type in run time

I have running t2.small instance, I stooped the instance and run it with t2.medium instance but the instance running t2.small

ec2:
 key_name: "{{key_name}}"
 region: "{{aws_region}}"
 state: running
 instance_type: t2.medium
 instance_ids: "{{ item.id }}"
 aws_access_key: "{{aws_access_key_id}}"
 aws_secret_key: "{{aws_secret_access_key}}"

it seems that ansible ignore from the instance_type

like image 273
yaniv refael Avatar asked Nov 09 '22 18:11

yaniv refael


1 Answers

You can't just run your instance using a new size, you should modify your instance size first, after stopping it, then run it afterwards.

Modify your instance size> [ reference ]

ec2-modify-instance-attribute <instance id> --instance-type <new type>

You should also take note of this, specifically>

You can resize an instance only if its current instance type and the new instance type that you want are compatible in the following ways:

  • Virtualization type. Linux AMIs use one of two types of virtualization: paravirtual (PV) or hardware virtual machine (HVM). You can't resize an instance that was launched from a PV AMI to an instance type that is HVM only. For more information, see Linux AMI Virtualization Types.
  • Network. Some instance types are not supported in EC2-Classic and must be launched in a VPC. Therefore, you can't resize an instance in EC2-Classic to a instance type that is available only in a VPC unless you have a nondefault VPC. For more information, see Instance Types Available Only in a VPC.
  • Platform. All Amazon EC2 instance types support 64-bit AMIs, but only the following instance types support 32-bit AMIs: t2.nano, t2.micro, t2.small, t2.medium, c3.large, t1.micro, m1.small, m1.medium, and c1.medium. If you are resizing a 32-bit instance, you are limited to these instance types.
like image 58
0xcurb Avatar answered Jan 04 '23 03:01

0xcurb