How can I get my Amazon ECS container instance to register with my cluster in a private subnet?

Last updated: 2019-07-26

I created an Amazon Elastic Container Service (Amazon ECS) cluster in a private subnet through the Amazon ECS console using the cluster creation wizard. However, my container instances aren't registered to the ECS cluster. How can I resolve this issue?

Short Description

If you created a cluster with the Amazon ECS console using the cluster creation wizard in a private subnet, your container instances are launched with a public IP address. As result, the container instances can't register to the ECS cluster, because they can't communicate with the ECS endpoint.

To reconfigure the environment to launch container instances without a public IP address, complete the following steps.

Resolution

Update the AWS CloudFormation template

  1. Open the AWS CloudFormation console.
  2. In the Stack Name column, select the stack that includes the cluster that you previously created.
  3. Choose the Template tab.
  4. Copy the template, and then paste it into a code editor.
  5. In the AWS::AutoScaling::LaunchConfiguration section of the template, change the AssociatePublicIpAddress property to false.
  6. Save your changes to the template file.
  7. Update the stack with your modified template.

You can now view your new cluster in the Amazon ECS console, and you can launch your container instances without a public IP address.

Scale your instances

  1. Open the Amazon ECS console.
  2. Choose the cluster that you previously created.
  3. Choose the ECS Instances tab, and then select your instances.
  4. Choose Scale ECS Instances.
  5. For Desired number of instances, enter 0, and then choose Scale.
    Note: This terminates instances created with public IP addresses.
  6. After the instance has been terminated, choose Scale ECS Instances again.
  7. For Desired number of instances, enter a number that meets your requirements, and then choose Scale.

Did this article help you?

Anything we could improve?


Need more help?