【问题标题】:How to solve the error ""Message":"User: anonymous is not authorized to perform: iam:PassRole on resource"如何解决错误““消息”:“用户:匿名无权执行:iam:PassRole on resource”
【发布时间】:2019-09-16 02:02:23
【问题描述】:

我正在尝试在 AWS 上为我的 elasticsearch 注册一个快照。我的目标是在 s3 存储桶上创建弹性搜索域的快照。以下是我正在使用的命令:

curl -XPUT https://vpc-xxxxxxx.ap-southeast-2.es.amazonaws.com/_snapshot/es-snapshot -d '
{
"type": "s3",
"settings": {
  "bucket": "$MY_BUCKET",
  "region": "ap-southeast-2",
  "role_arn": "arn:aws:iam::xxxx:role/es-snapshot-role"
}
}'

但是我收到了这个错误:

{"Message":"User: anonymous is not authorized to perform: iam:PassRole on resource: arn:aws:iam::xxxx:role/es-snapshot-role"}

这似乎是一个角色权限问题​​。我已将角色策略配置为:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": [
                "es:*",
                "s3:*",
                "iam:PassRole",
                "es:ESHttpPut"
            ],
            "Resource": [
                "*"
            ]
        }
    ]
}

而它的信任关系是:

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

我想知道我还错过了什么。

这篇帖子AccessDenied for EC2 Instance with attached IAM Role 似乎与我的问题无关。

【问题讨论】:

标签: amazon-web-services amazon-iam aws-elasticsearch


【解决方案1】:

注册手动快照存储库

您必须先向 Amazon Elasticsearch Service 注册快照存储库,然后才能拍摄手动索引快照。这一一次性操作要求您使用允许访问 TheSnapshotRole 的凭证签署您的 AWS 请求,如Manual Snapshot Prerequisites 中所述。

您不能使用 curl 执行此操作,因为它不支持 AWS 请求签名。相反,使用sample Python clientPostman 或其他方法发送signed request 来注册快照存储库。请求采用以下形式:

PUT elasticsearch-domain-endpoint/_snapshot/my-snapshot-repo
{
  "type": "s3",
  "settings": {
    "bucket": "s3-bucket-name",
    "region": "region",
    "role_arn": "arn:aws:iam::123456789012:role/TheSnapshotRole"
  }
}

来自 AWS 文档的参考:Working with Amazon Elasticsearch Service Index Snapshots

【讨论】:

    【解决方案2】:

    为您的 IAM 用户添加 iam:PassRole 权限并尝试该命令,

    【讨论】:

      猜你喜欢
      • 2019-01-25
      • 2021-05-16
      • 2020-06-08
      • 2016-04-19
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2019-01-22
      • 2019-06-21
      相关资源
      最近更新 更多