【问题标题】:I am getting s3 error: An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied我收到 s3 错误:调用 ListBuckets 操作时发生错误 (AccessDenied):访问被拒绝
【发布时间】:2021-09-17 09:21:38
【问题描述】:

enter code heregetting:调用 ListBuckets 操作时发生错误(AccessDenied):访问被拒绝

但我有一个 IAM 策略集并使用带有该策略的 --profile 的 aws CLI。 IAM 政策:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::my-repository"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "s3:GetObjectAcl",
                "s3:GetObject",
                "s3:GetObjectTagging",
                "s3:DeleteObject"
            ],
            "Resource": "arn:aws:s3:::my-repository/data/*"
        }
    ]
}

aws --profile my-repository s3 ls

An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied

【问题讨论】:

    标签: amazon-s3 amazon-iam policy


    【解决方案1】:
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "VisualEditor0",
                "Effect": "Allow",
                "Action": "s3:ListBucket",
                "Resource": "arn:aws:s3:::my-repository"
            },
            {
                "Sid": "VisualEditor1",
                "Effect": "Allow",
                "Action": "s3:ListAllMyBuckets",
                "Resource": "*"
            },
            {
                "Sid": "VisualEditor2",
                "Effect": "Allow",
                "Action": [
                    "s3:GetObjectAcl",
                    "s3:GetObject",
                    "s3:GetObjectTagging",
                    "s3:DeleteObject"
                ],
                "Resource": "arn:aws:s3:::my-repository/data/*"
            }
        ]
    }
    

    【讨论】:

      【解决方案2】:

      您需要以下 IAM 权限才能执行aws s3 ls

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

      【讨论】:

      • 那么,我不能将 ListBucket 限制为一个资源(桶)吗?
      • 我明白你的意思....我进行了更改并保留了 listBucket 限制....有效!谢谢。
      • 我现在的政策是:
      • { “版本”:“2012-10-17”,“声明”:[ { “Sid”:“VisualEditor0”,“效果”:“允许”,“动作”:“s3: ListBucket", "Resource": "arn:aws:s3:::my-repository" }, { "Sid": "VisualEditor1", "Effect": "Allow", "Action": ["s3:GetObjectAcl", “s3:GetObject”、“s3:GetObjectTagging”、“s3:DeleteObject”]、“资源”:“arn:aws:s3:::my-repository/data/*”}]}
      • 对不起......我没有输入整个政策......现在发布答案
      猜你喜欢
      • 1970-01-01
      • 2021-04-13
      • 2018-07-12
      • 1970-01-01
      • 2018-12-09
      • 1970-01-01
      • 1970-01-01
      • 2021-09-23
      • 2020-04-02
      相关资源
      最近更新 更多