Search code examples
amazon-web-servicesterraformaws-cliamazon-ecsautoscaling

How to get AWS ECS First Run Experience's "Scale ECS Instances" button?


I am able to launch a ECS cluster and auto-scaling group that attaches EC2's to the cluster.

I can launch new EC2's that can connect to the cluster using the launch template's and auto scaling group's web interfaces.

I cannot launch new EC2's to connect to the cluster using the ECS web interface via the Scale ECS Instances button mentioned here: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scale_cluster.html

The Scale ECS Instances button shows up when I create the ECS cluster through the web console. However, I cannot get the Scale ECS Instances button to show up when I create the ECS cluster through Terraform.

I'm hypothesizing that the web console goes through a first run experience that I cannot mimic using Terraform: https://aws.amazon.com/blogs/compute/amazon-ecs-console-first-run-troubleshoot-docker-errors/

But I cannot find any documentation to prove or disprove my hypothesis.

Is it possible to use Terraform (or CloudFormation or AWS CLI) to get the Scale ESC Instances button to show up on the ECS web console?

Thank you for your time :)


Solution

  • That console experience is using CloudFormation under the covers so when you click that button it's modifying the CloudFormation stack to add more desired instances to your ASG:

    If your cluster was created with the console first-run experience after November 24, 2015, then the Auto Scaling group associated with the AWS CloudFormation stack created for your cluster can be scaled up or down to add or remove container instances. You can perform this scaling operation from within the Amazon ECS console.

    To make the same change in Terraform you should modify your min_size or desired_capacity (depending on if you are actually using scaling policies or not) of your autoscaling group and allow it to scale appropriately.

    This is also a better approach anyway (and I'd recommend this approach even if you were using CloudFormation to create your ECS cluster) as it means that all of your changes are defined in code directly rather than a combination of code and people clicking around in the AWS console.