How to change instance type in AWS ECS cluster?
To do it without any downtime:
- Create a copy of the Launch Configuration used by your Auto Scaling Group, including any changes you want to make.
- Edit the Auto Scaling Group to:
- Use the new Launch Configuration
- Desired Capacity = Desired Capacity * 2
- Min = Desired Capacity
- Wait for all new instances to become 'ACTIVE' in the ECS Instances tab of the ECS Cluster
- Select the old instances and click Actions -> Drain Instances
- Wait until all the old instances are running 0 tasks
- Edit the Auto Scaling Group and change Min and Desired back to their original values
Yes, you can achieve this in CloudFormation.
- Click on the Stack corresponding to your ECS-Cluster.
- Click
Update Stack
- Use radio
current template
,Next
- change EcsInstanceType
Next
,Next
,Update
- Upscale your cluster to
2*n
instances - Wait for the
n
new instances of the new type being created - Downscale your cluster to
n
- Or you could just drain and terminate the instances 1 by 1
Yes, this is possible.
The instance types in your cluster are determined by the 'Instance Type' setting within your Launch Configuration. To update the instance type without having to recreate the cluster:
- Make a copy of the cluster Launch Configuration and update the 'Instance Type'.
- Adjust the cluster Auto Scaling Group to point to your new Launch Configuration.
- Wait for your new instances to register in your cluster and your services to start.
You can also add multiple instances types to a single cluster by creating multiple Auto Scaling Groups linked to different Launch Configurations. Note however that you can't copy Auto Scaling Groups easily within the console.