Mario Briseño
Mario Briseño

Reputation: 21

Why is my ECS cluster with AutoScaling group as capacity provider not working?

No Container Instances were found in your capacity provider

I want to use an autoscaling group as capacity provider for a ECS Cluster. Even tho I just want one container per container instance I chose the awsvpc as the network mode of my task definition. In other templates I create the autoscaling group with a launch template (in private subnets with NAT), a load balancer and a target group.

Still, when I try to create my service in the cluster an error shows: 'No Container Instances were found in your capacity provider'

What could it be? I'm not sure if it. was to do with policies, roles and stuff

I've read that some people may add userdata to the launch template but I'm not sure that's a solution for me. I want an autoscaling group as a capacity provider, not a single server.

Upvotes: 2

Views: 1739

Answers (1)

Michael Lueck
Michael Lueck

Reputation: 11

OK...so I spent A LOT of time tracking this down. I was creating my resources with terraform (as one should) and thought I could use the same launch template for multiple ASG or ECS clusters. Unfortunately someone made a decisions to have the launch template specify which ECS cluster the instance is attached to.

So here's how you fix it. In the launch template...all the way at the bottom under "Advanced Details" there is a little field called "User data". In here you have to setup an environment variable on the instance to specify which ECS cluster this is for.

I entered:

#!/bin/bash 
echo ECS_CLUSTER=test >> /etc/ecs/ecs.config;

and bingo...all the instances created with this launch template are now associated with the "test" ECS Cluster.

Hope this helps

Upvotes: 1

Related Questions