Question: How do I change my container instance type in Amazon ECS?

I want to change the container instance type in my Amazon Elastic Container Service (Amazon ECS) cluster. But, I don't know how.

Short descriptionTo change your container instance type, complete the steps in one of the following sections:Update container instances that are launched in an ECS cluster through the AWS CloudFormation stackUpdate container instances that are launched manually in an ECS clusterUpdate container instances in a cluster that's associate with a capacity provider

ResolutionUpdate container instances that are launched in an ECS cluster through the CloudFormation stackImportant: The following steps apply only to ECS clusters that are created with resources that internally create an underlying CloudFormation stack. The stack has a name in the following format: EC2ContainerService-yourClusterName. These steps don't apply to empty ECS clusters or to customized approaches for provisioning container instances.Update the value of the EcsInstanceType parameter in the CloudFormation stackOpen the AWS CloudFormation console.Select the stack that contains your ECS cluster.Note: The cluster name is appended to the end of your stack name (for example, EC2ContainerService-yourClusterName).Choose Actions, and then choose Update Stack.Choose Use current template, and then choose Next.For EcsInstanceType, set a value that's appropriate for the instance type in your container instance, and then choose Next.Skip the Options section, choose Next, and then choose Update.Replace the old container instances in the clusterTo update the CloudFormation stack, complete steps 1 through 4 in the preceding section.For AsgMaxSize, enter a parameter value that's double the current size.Note: For example, if the current value is 2, set the new value to 4. This helps prevent downtime when you change the instance type.Open the Amazon ECS console.In the navigation pane, choose Clusters, and then choose your cluster.Choose the ECS Instances tab, and then select the container instance IDs for the old container instances that you want to replace.Note: If DeploymentConfiguration allows for replacement tasks to be placed on container instances, then Amazon ECS automatically places the replacement tasks.Choose the Actions menu, and then choose Drain instances to drain the instances.On the ECS Instances tab, verify that Running tasks count is 0 for your old container instances.In the navigation pane, choose Clusters, and then select your cluster.Choose the ECS Instances tab, select the container instance IDs of your old container instances, and then choose Deregister.Note: Deregistering an instance removes it from Amazon ECS.In your CloudFormation template, set the value of AsgMaxSize to the original value to terminate the older container instances.Important: This step assumes that your Auto Scaling group has the Default Termination Policy.Update container instances that are manually launched in an ECS clusterCopy the launch configuration of your Auto Scaling group, and then name your new launch configuration.Change your instance type.In the Amazon EC2 console, in the Auto Scaling section of the navigation pane, choose Auto Scaling Groups. Then, select the Auto Scaling group for your container instance.Choose Actions, and then choose Edit.In the pop-up window, for Launch Configuration, choose the launch configuration that you created in step 1 of this section.For Desired Capacity, enter a value that's double the size of the current value, and then update the value of Max as needed.Note: Desired capacity must be between minimum and maximum group size, inclusive.In the navigation pane of the Amazon ECS console, choose Clusters, and then choose your cluster.Choose the ECS Instances tab, select the container instance IDs for the old container instances that you want to replace.Choose the Actions menu, and then choose Drain instances to drain the instances.On the ECS Instances tab, for your old container instances, verify that Running tasks count is 0.Choose the ECS Instances tab, select the container instance IDs for your old container instances, and then choose Deregister.Note: Deregistering an instance removes it from Amazon ECS.In the Amazon EC2 console, in the Auto Scaling section of the navigation pane, choose Auto Scaling Groups.Choose Actions, and then choose Edit.In your Auto Scaling group configuration, set Desired Capacity and Max to their original values, and then save your changes.Note: This terminates the old container instances in the ECS cluster.Update container instances in a cluster that's associated with a capacity providerNote: This section assumes that you have capacity providers associated with your cluster and services associated with capacity provider strategy.If the cluster was created using CloudFormation, then complete the following steps:Follow steps 1 through 6 in the preceding subsection:Update the value of the EcsInstanceType parameter in the CloudFormation stackIn the navigation pane of the Amazon ECS console, choose Clusters, and then choose your cluster.Choose the ECS Instances tab, then select the container instance ID for the old container instance that you want to replace.Choose the Actions menu, and then choose Drain instances to drain the instances.Note: When you drain the instances, the capacity provider launches new container instances based on the DeploymentConfiguration of the services.On the ECS Instances tab of your old container instance, verify that the Running tasks count is 0.If the cluster was created manually, then complete the following steps:Follow steps 1 through 5 in the preceding section:Update container instances that are manually launched in an ECS clusterIn the navigation pane of the Amazon ECS console, choose Clusters, and then choose your cluster.Choose the ECS Instances tab, then select the container instance ID for the old container instance that you want to replace.Choose the Actions menu, and then choose Drain instances to drain the instances.Note: When you drain the instances, the capacity provider launches new container instances based on the DeploymentConfiguration of the services.On the ECS Instances tab of your old container instance, verify that the Running tasks count is 0.Note: The capacity provider automatically terminates drained instances after a defined period of time.