【问题标题】:Unable to assume service linked role when using ecs-cli使用 ecs-cli 时无法承担服务相关角色
【发布时间】:2019-07-19 12:32:10
【问题描述】:

我正在尝试关注ecs-cli Fargate deployment tutorial,但在尝试部署我的服务时遇到了问题。

我正在尝试使用 ecs-cli compose --project-name tutorial-maltz service up 部署我的测试容器,但我收到一条错误消息,上面写着 "InvalidParameterException: Unable to assume the service linked role. Please verify that the ECS service linked role exists.\n\tstatus code: 400, request id

到目前为止,我已经使用提供的步骤创建了我的 IAM 权限,并验证了我有一个 IAM 角色 ecsTaskExecutionRole,其中包含一个 AmazonECSTaskExecutionRolePolicy。此策略还具有如下所示的信任关系:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "ecs-tasks.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

所有这些都是从ecs-params.yml 文件中部署的,如下所示:

version: 1
task_definition:
    task_execution_role: ecsTaskExecutionRole
    ecs_network_mode: awsvpc
    task_size:
        mem_limit: 0.5GB
        cpu_limit: 256
run_params:
    network_configuration:
        awsvpc_configuration:
            subnets:
                - "subnet-from-ecs-cli-up"
            security_groups:
                - "subnet-created-by-ecs-cli-up"
        assign_public_ip: ENABLED

我不确定下一步该往哪里看。我是否缺少 IAM 角色?我是否需要向我现有的 IAM 角色添加一些额外的参数?

【问题讨论】:

    标签: amazon-web-services amazon-ecs


    【解决方案1】:

    对于以后遇到此问题的人,解决方案是为整个 ECS 创建一个service linked role。这必须由 AWS 账户的管理员完成。

    请注意,这与您在本教程前面创建的TaskExecutionRole不同。服务相关角色允许 ECS 执行启动新 EC2 实例和创建 ELB 堆栈等操作。 TaskExecutionRole 用于启动任务的事物。

    【讨论】:

      【解决方案2】:

      使用我的管理员角色创建 ECS 集群时,我也被阻止...“ECS 集群无法承担服务链接角色。请验证 ECS 服务链接角色是否存在。” 我验证了这个角色确实存在,AWSServiceRoleForECS

      解决办法?通过执行“开始”向导,它在幕后(重新)配置了一些东西,现在我的管理员角色被允许承担 AWSServiceRoleForECSSUCCESS完全创建集群。

      【讨论】:

      • 这解决了我的问题,因为我第一次访问 ECS 时跳过了单击“开始”
      • 来自文档:Under most circumstances, you don't need to manually create the service-linked role. For example, when you create a new cluster (for example, with the Amazon ECS first-run experience, the cluster creation wizard, or the AWS CLI or SDKs), or create or update a service in the AWS Management Console, Amazon ECS creates the service-linked role for you, if it does not already exist.
      猜你喜欢
      • 2018-08-06
      • 2017-11-20
      • 2019-09-15
      • 2018-11-05
      • 2018-09-19
      • 2019-02-25
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      相关资源
      最近更新 更多