I found another related script that would trigger this, and I thought I'd put it here if anyone else came across it. If you define a TaskDefinition with an image that does not actually exist in its ContainerDefinition , and then you try to run this TaskDefinition as a service, you will encounter the same freeze problem (or at least something that looks like the same problem).
NOTE An example of the following YAML fragments is provided in one CloudFormation template.
So, as an example, I created this Repository :
MyRepository: Type: AWS::ECR::Repository
And then I created this Cluster :
MyCluster: Type: AWS::ECS::Cluster
And this TaskDefinition (abbreviated):
MyECSTaskDefinition: Type: AWS::ECS::TaskDefinition Properties: # ... ContainerDefinitions: # ... Image: !Join ["", [!Ref "AWS::AccountId", ".dkr.ecr.", !Ref "AWS::Region", ".amazonaws.com/", !Ref MyRepository, ":1"]] # ...
Based on the above, I decided to create a Service as follows:
MyECSServiceDefinition: Type: AWS::ECS::Service Properties: Cluster: !Ref MyCluster DesiredCount: 2 PlacementStrategies: - Type: spread Field: attribute:ecs.availability-zone TaskDefinition: !Ref MyECSTaskDefinition
That everything seemed reasonable to me, but, it turns out, there are two problems with this, as it is written / expanded, which made it hang.
DesiredCount set to 2, which means that it will actually try to deploy the service and start it, rather than just defining it. If I set DesiredCount to 0, that would be fine.Image defined in MyECSTaskDefinition does not yet exist. I made a repository as part of this template, but I didn't actually click anything on it. Therefore, when MyECSServiceDefinition tried to deploy a DesiredCount of 2 instances, it depended because the image was not actually available in the repository (because the repository had just been created in the same template).
So, at the moment, the solution is to create a CloudFormation stack with DesiredCount 0 for Service , load the corresponding Image into the repository, and then update the CloudFormation stack to expand the service. Or, in turn, you have a separate template that sets up the underlying infrastructure, such as a repository, downloads the assemblies for this, and then has a separate template to run, which installs the Services themselves.
Hope this helps anyone who has this problem!