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?
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.
Update the AWS CloudFormation template
- Open the AWS CloudFormation console.
- In the Stack Name column, select the stack that includes the cluster that you previously created.
- Choose the Template tab.
- Copy the template, and then paste it into a code editor.
- In the AWS::AutoScaling::LaunchConfiguration section of the template, change the AssociatePublicIpAddress property to false.
- Save your changes to the template file.
- 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
- Open the Amazon ECS console.
- Choose the cluster that you previously created.
- Choose the ECS Instances tab, and then select your instances.
- Choose Scale ECS Instances.
- For Desired number of instances, enter 0, and then choose Scale.
Note: This terminates instances created with public IP addresses.
- After the instance has been terminated, choose Scale ECS Instances again.
- For Desired number of instances, enter a number that meets your requirements, and then choose Scale.