无法为服务目录承担 AWS SSM 文档代入角色

AWS SSM DOcument Assume Role is unable to be assumed for Service Catalog

我正在使用服务目录执行 SSM 自动化文档,因此我的服务目录有自己的角色“My_END_USER_Role”,我创建了另一个角色,有权停止 SSM 自动化的 EC2文件.

My_END_USER_Role 这个角色有 AWSServiceCatalogEndUserFullAccess,简单的解决办法是直接给这个角色我需要的权限但我不希望服务目录外的用户执行停止 EC2 之类的任何操作,因此我想假设 MY_SSM_ROLE 具有额外权限,但我收到此错误

An error occurred (InvalidAutomationExecutionParametersException) when calling the StartAutomationExecution operation: The defined assume role is unable to be assumed.

基于 AWS Troubleshooting - section Assume Role Can't Be Assumed 要么是角色不存在,这对我来说是不正确的,要么承担的角色与 Systems Manager 服务没有信任关系,现在我被困在这里我应该如何给信任关系!!?

SSM 自动化文档

description: Stop EC2 Instance
schemaVersion: '0.3'
assumeRole: '{{ AutomationAssumeRole }}'
parameters:
  AutomationAssumeRole:
    type: String
    default: 'arn:aws:iam::ACCOUNTID:role/MY_SSM_ROLE'
    description: The ARN of the role that allows Automation to perform the actions on your behalf.
  InstanceId:
    type: 'AWS::EC2::Instance::Id'
mainSteps:
  - name: StopInstance
    action: 'aws:changeInstanceState'
    inputs:
      InstanceIds:
        - '{{ InstanceId }}'
      DesiredState: stopped

只是为了测试,我给了 MY_SSM_ROLE 管理员权限,还包括此政策:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "sts:AssumeRole",
                "iam:PassRole",
                "ssm:StartAutomationExecution"
            ],
            "Resource": "*"
        }
    ]
}

找到了解决方案,我不得不为 MY_SSM_ROLE 角色添加适当的服务到 信任关系

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