Amazon S3策略仅用于PUT,Read和List



我试图创建一个只读取/放置/列出我的桶和一个目录到它的策略。我写了这个策略:

{
    "Version": "2014-05-19",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [ "s3:Put*", "s3:Get*" ],
            "Resource": "arn:aws:s3:::<mybucket>/<mydirectoryinbucket>/*"
        }
    ]
}
{
    "Version": "2014-05-19",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Condition": { "StringLike": { "s3:prefix": "<mydirectoryinbucket>/*"} },
            "Resource": "arn:aws:s3:::<mybucket>"
        }
    ]
}

但是我在第一个策略的最后一行得到错误…这个错误只是语法错误,没有附加信息。

哪里做错了?

您至少错过了主体,它定义了允许或拒绝访问资源的实体。

我取了你的策略,添加了通配符*来表示'any'主体,并使用IAM policy Generator重新生成它。试试这个:

{
  "Id": "Policy1432045314996",
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicGetAndPutPolicy",
      "Action": [
        "s3:Get*",
        "s3:Put*"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::<mybucket>/<mydirectoryinbucket>/*",
      "Principal": "*"
    },
    {
      "Sid": "PublicListPolicy",
      "Action": [
        "s3:ListBucket"
      ],
      "Effect": "Allow",
      "Resource": "arn:aws:s3:::<mybucket>",
      "Condition": {
        "StringLike": {
          "s3:prefix": "<mydirectoryinbucket>/*"
        }
      },
      "Principal": "*"
    }
  ]
}

文档:

  • 在策略中指定主体

相关内容

  • 没有找到相关文章