0

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

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 故障排除 - 无法假定角色部分是角色不存在,这对我来说不是真的,或者假定角色与 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": "*"
        }
    ]
}
4

1 回答 1

0

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

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "ssm.amazonaws.com",
          "iam.amazonaws.com"
        ]
      },
      "Action": "sts:AssumeRole"
    }
  ]
}
于 2021-11-10T13:53:34.390 回答