如何在启动 Amazon ECS 资源时解决 AWS CloudFormation 错误“无法代入角色并验证负载均衡器上配置的侦听器”?

1 分钟阅读
0

使用 AWS CloudFormation 启动 Amazon Elastic Container Service (Amazon ECS) 资源 (AWS::ECS::Service) 时收到一条错误消息。

简短描述

如果使用的是 Classic Load Balancer,将收到以下类似错误消息:

"12:21:48 UTC+0100 CREATE_FAILED AWS::ECS::Service ECSService Unable to assume role and validate the listeners configured on your load balancer.Please verify the role being passed has the proper permissions."

如果使用的是 Application Load Balancer,将收到以下类似错误消息:

"12:21:48 UTC+0100 CREATE_FAILED AWS::ECS::Service ECSService Unable to assume role and validate the specified targetGroupArn.请验证所传递的 ECS 服务角色是否具有正确的权限。”

如果使用指定实例配置文件的独立 AWS Identity and Access Management (IAM) 策略资源创建 Amazon ECS 服务,Amazon ECS 服务可能会失败并返回一条错误消息。

解决方法

要解决 Classic Load Balancer 和Application Load Balancer 的这一错误,请尝试以下一个或多个解决办法:

  • 确认 Amazon ECS 服务的 IAM 角色具有在负载均衡器中注册和取消注册容器实例的适当权限
    **提示:**可以使用此 AWS CloudFormation 模板作为参考,构建具有适当依赖关系的 Amazon ECS 架构组件。架构组件包括 Amazon ECS 集群、服务、负载均衡器、容器实例和 IAM 资源。
  • 确认 AWS Auto Scaling 组或 Amazon ECS 容器实例具有作为属性关联的实例配置文件
  • 使用 DependsOn 属性指定 AWS::IAM::PolicAWS::ECS::Service 资源的依赖关系。或者,使用自定义资源延迟堆栈创建过程,并为服务角色权限的传播提供时间。
</ul
AWS 官方
AWS 官方已更新 2 年前