用于创建ECS服务的Cloudformation模板卡在CREATE_IN_PROGRESS中 [英] Cloudformation template for creating ECS service stuck in CREATE_IN_PROGRESS
问题描述
我正在使用Cloudformation创建AWS ECS服务.
I am creating an AWS ECS service using Cloudformation.
一切似乎都成功完成,我可以看到该实例已连接到负载均衡器,负载均衡器将实例声明为运行状况良好,并且如果我击中了负载均衡器,则可以成功地将其带到正在运行的容器中.
Everything seems to complete successfully, I can see the instance being attached to the load-balancer, the load-balancer is declaring the instance as being healthy, and if I hit the load-balancer I am successfully taken to my running container.
看一下ECS控制面板,我可以看到该服务已稳定下来,并且一切正常.我还可以看到该容器是稳定的,并且没有终止/重新创建.
Looking at the ECS control panel, I can see that the service has stabilised, and that everything is looking OK. I can also see that the container is stable, and is not being terminated/re-created.
但是,Cloudformation模板永远不会完成,它被卡在 CREATE_IN_PROGRESS
中,直到大约30-60分钟后才回滚,声称服务没有稳定.查看CloudTrail,我可以看到由 ecs-service-scheduler
实例化的许多 RegisterInstancesWithLoadBalancer
,它们都具有相同的参数,即相同的实例ID和负载均衡器.我正在为ECS使用标准的IAM角色和权限,因此这应该不是权限问题.
However, the Cloudformation template never completes, it is stuck in CREATE_IN_PROGRESS
until about 30-60 minutes later, when it rolls back claiming that the service did not stabilise. Looking at CloudTrail, I can see a number of RegisterInstancesWithLoadBalancer
instantiated by ecs-service-scheduler
, all with the same parameters i.e. same instance id and load-balancer. I am using standard IAM roles and permissions for ECS, so it should not be a permissions issue.
有人遇到过类似的问题吗?
Anyone had a similar issue?
推荐答案
您的 AWS :: ECS :: Service
需要为 TaskDefinition
注册完整的ARN(源:在AWS论坛上查看ChrisB @ AWS的回答).关键是要为您的 TaskDefinition
设置完整的ARN,包括修订版.如果您跳过修订版本(在下面的示例中为:123
),则使用最新的修订版本,但是CloudFormation仍然会与"CREATE_IN_PROGRESS"共进午餐大约一个小时,然后才会失败.这是一种方法:
Your AWS::ECS::Service
needs to register the full ARN for the TaskDefinition
(Source: See the answer from ChrisB@AWS on the AWS forums). The key thing is to set your TaskDefinition
with the full ARN, including revision. If you skip the revision (:123
in the example below), the latest revision is used, but CloudFormation still goes out to lunch with "CREATE_IN_PROGRESS" for about an hour before failing. Here's one way to do that:
"MyService": {
"Type": "AWS::ECS::Service",
"Properties": {
"Cluster": { "Ref": "ECSClusterArn" },
"DesiredCount": 1,
"LoadBalancers": [
{
"ContainerName": "myContainer",
"ContainerPort": "80",
"LoadBalancerName": "MyELBName"
}
],
"Role": { "Ref": "EcsElbServiceRoleArn" },
"TaskDefinition": {
"Fn::Join": ["", ["arn:aws:ecs:", { "Ref": "AWS::Region" },
":", { "Ref": "AWS::AccountId" },
":task-definition/my-task-definition-name:123"]]}
}
}
}
这是一种通过aws cli和 jq 来获取 MyTaskDefinition
的最新版本的好方法.:
Here's a nifty way to grab the latest revision of MyTaskDefinition
via the aws cli and jq:
aws ecs list-task-definitions --family-prefix MyTaskDefinition | jq --raw-output .taskDefinitionArns[0][-1:]
这篇关于用于创建ECS服务的Cloudformation模板卡在CREATE_IN_PROGRESS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!