创建AWS角色时json语法错误

时间:2018-12-29 00:32:28

标签: json amazon-web-services syntax roles amazon-iam

我只是复制关于使用JSON创建AWS角色但遇到语法错误的粘贴供应商文档。

JSON:

{

“版本”:“ 2012-10-17”,

“声明”:[

  {

     "Effect":"Allow",

     "Action":[

        "s3:ListBucket",

        "s3:GetBucketLocation"

     ],

     "Resource":[

        "arn:aws:s3:::<bucket-name>"

] }

  {

     "Effect":"Allow",

     "Action":[

        "s3:GetObject"

     ],

     "Resource":[

        "arn:aws:s3:::<bucket-name>/*"

] }

收到的错误:“调用PutRolePolicy操作时发生错误(MalformedPolicyDocument):策略中的语法错误。”

1 个答案:

答案 0 :(得分:0)

您缺少一些结束标记。清理后的版本如下。

此外,<bucket-name>需要用您授予访问权限的存储桶名称进行替换

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::<bucket-name>"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": [
                "arn:aws:s3:::<bucket-name>/*"
            ]
        }
    ]
}