_This issue was originally opened by @gowtham6032 as hashicorp/terraform#18250. It was migrated here as a result of the provider split. The original body of the issue is below._
You can't. As the docs say -> https://www.terraform.io/docs/providers/aws/r/instance.html#instance_type
You could look at running an two ECS clusters side by side. One with a desired count of zero. When you want to change the instance type, do it to the side with the zero desired count and then increase the count and reduce the count to zero on the old instance. The containers will migrate over to the new cluster with the new instance type.
@MooreDerek explained the potential solution which involves ECS, but I believe the issue was created regarding aws_instance resource where it is not possible to change instance type once it was created without destroying it.
Proposing to close this issue.
Terraform has supported changing the instance type of an EC2 instance since https://github.com/hashicorp/terraform/pull/11998 which was released in 0.8.8 before the Terraform provider split in 0.10.0.
If you just update the instance_type field and run a plan you should see Terraform showing an in place modification (should be in yellow with a ~ and saying it wants to change something rather than destroy and create).
Note that it will stop the instance, change the instance type and then start it so this will cause some downtime if you are relying on the instance being up all the time.
@tomelliff is right, instance size can be updated in place. It still does incur downtime, which admittedly plan output doesn't reflect very well today (i.e. it's not clear whether an in-place change will incur downtime or not) as we don't really have good mechanism to implement this on the provider side yet.
Feel free to subscribe to https://github.com/hashicorp/terraform/issues/16624 if you want to get notified when we have some news to share in that area.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
Terraform has supported changing the instance type of an EC2 instance since https://github.com/hashicorp/terraform/pull/11998 which was released in 0.8.8 before the Terraform provider split in 0.10.0.
If you just update the
instance_typefield and run a plan you should see Terraform showing an in place modification (should be in yellow with a~and saying it wants to change something rather than destroy and create).Note that it will stop the instance, change the instance type and then start it so this will cause some downtime if you are relying on the instance being up all the time.