如何在运行时更改实例类型
我正在运行 t2.small 实例,我弯下腰并使用 t2.medium 实例运行它,但运行 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}}"
似乎 ansible 忽略了 instance_type
最佳答案
您不能只使用新的大小运行您的实例,您应该先修改您的实例大小,然后停止它,然后再运行它。
修改您的实例大小 > [ reference ]
ec2-modify-instance-attribute <instance id> --instance-type <new type>
您还应该注意 this , 具体>
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.
关于amazon-ec2 - 如何在运行时更改实例类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35823953/