How do I increase the available disk space on my Amazon ECS container instances if I launched my ECS cluster from the AWS Management Console?

Last updated: 2019-09-05

How do I increase the total disk space on my Amazon Elastic Container Service (Amazon ECS) container instances if I launch my ECS cluster from the AWS Management Console?

Short Description

To increase the storage space on your container instances, you must launch replacement instances, and then terminate your original instances.

To increase the storage space using this method, complete the steps in the Resolution section. If you launched your container instances using another method, then skip this article and complete the steps in one of the following articles:

Note: Your Amazon Elastic Block Store (Amazon EBS) volume configuration varies depending on which Amazon ECS-optimized Amazon Machine Image (AMI) that you're using. For more information and commands on how to check the available space on your instances, see AMI Storage Configuration.

Important: The following steps terminate the original container instances in your Amazon ECS cluster. Any data that's stored on the EBS volumes for those instances will be lost when you complete these steps.

Resolution

Update the storage size and launch replacement instances

  1. Open the Amazon ECS console, and then identify the name of the ECS cluster where you want to launch your new container instances.
  2. Identify the instances that are running in your Auto Scaling group.
  3. Open the AWS CloudFormation console, and then select the stack for your ECS cluster.
    Note: The stack name is in the following format: EC2ContainerService-yourEcsClusterName.
  4. Choose Actions, and then choose Update Stack.
  5. In the Select Template section, choose Use current template, and then choose Next.
  6. Set the EBsVolumeSize parameter to the new size required for your instances in GB.
  7. Set the AsgMaxSize parameter to increase the size of the Auto Scaling group, and then launch new replacement instances.
    Note: For Amazon ECS-optimized Amazon Linux 1 AMIs, use /dev/xvda for the operating system, and use /dev/xvdcz for Docker images and metadata with logical volume management (LVM) devices. For Amazon ECS-optimized Amazon Linux 2 AMIs, use /dev/xvda for the operating system and for Docker images and metadata.
  8. Set the DeviceName for your Amazon Linux version.
  9. Step through the rest of the setup wizard by choosing Next for each page, and then choose Update to launch your new replacement instances.

Now, the launch configuration for your Auto Scaling group is updated to the new storage configuration and your new container instances are launched.

Terminate your original instances

Important: To be sure that your services remain available, you must drain the container instances to reschedule your tasks, and then terminate your original instances in batches. You can also automate this draining workflow when an instance is terminated.

  1. Open the Amazon ECS console, identify the first batch of instances that are running in your Auto Scaling group, and then drain your instances in this batch.
    Note: You can drain the previous instances in batches to avoid downtime for your Amazon ECS services. When you drain service tasks for container instances, container instances that are in the RUNNING state are stopped and replaced according to the service's deployment configuration parameters, minimumHealthyPercent and maximumPercent. Any PENDING or RUNNING tasks that don't belong to the service are unaffected. You must either wait for these tasks to finish or stop them manually.
  2. After all the tasks on the container instance are stopped, terminate the container instance.
    Note: After several minutes, the underlying Auto Scaling group launches a replacement instance with increased storage to replace the terminated instance.
  3. Repeat steps 1-2 until you replace all the original instances with your new container instances.

Your tasks should now be running on the new instances with more storage available.


Did this article help you?

Anything we could improve?


Need more help?