【问题标题】:error when using EC2 SNS with SSM (Systems Manager)将 EC2 SNS 与 SSM 一起使用时出错(系统管理器)
【发布时间】:2018-03-13 01:04:15
【问题描述】:

我正在尝试将 AWS 的 SNS 与 SSM 一起使用,但收到有关角色的错误。

这是错误:

botocore.errorfactory.InvalidRole: An error occurred (InvalidRole) when calling the SendCommand operation: ServiceRoleArn is not valid: arn:aws:iam::<account #>:role/FullSNS

以下是相关代码:

response = client.send_command(
InstanceIds=[
    '<instance id>',
],
DocumentName='AWS-RunShellScript',
Parameters={
    'commands': [
        '<command>',
    ],
    'workingDirectory': [
        '<directory>'
    ]
},
OutputS3BucketName='<s3 bucket>',
ServiceRoleArn='arn:aws:iam::<account #>:role/FullSNS',
NotificationConfig={
    'NotificationArn': 'arn:aws:sns:us-east-1:<account #>:MyTestTopic',
    'NotificationEvents': [
        'All',
        ],
    'NotificationType': 'Command'
    }
)

以下是关于该角色的政策:

{
  "Version": "2012-10-17",
  "Statement": [
{
  "Action": [
    "sns:*"
  ],
  "Effect": "Allow",
  "Resource": "*"
}
]
}

以上是boto3,但如果我在控制台中尝试,我会得到同样的错误。

【问题讨论】:

    标签: amazon-ec2 boto3 amazon-sns amazon-iam ssm


    【解决方案1】:

    我希望 AWS 文档在这一点上更清楚,但我还必须编辑该 IAM 角色的信任关系,使其看起来像这样:

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

    【讨论】:

    猜你喜欢
    • 2011-09-22
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 1970-01-01
    • 2017-06-24
    • 2016-08-01
    • 1970-01-01
    • 2020-12-15
    相关资源
    最近更新 更多