AWS IAM策略中的错误字符串

时间:2020-05-05 11:00:36

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

我正在努力为我们的IAM策略获取正确的JSON代码。 s3fs将使用此策略来安装OUR_AWS_BUCKET,并且仅限于一个IP地址-XXX.XXX.XXX.XXX

{
 "Version": "2012–10–17",
 "Statement": {
    {
        "Effect": "Deny",
        "Action": "*",
        "Resource": "*",
        "Condition": {
            "NotIpAddress": {"aws:SourceIp": [
                "XXX.XXX.XXX.XXX/32"
            ]}
        }
    },
    {
        "Effect": "Allow",
        "Action": [
            "s3:GetBucketLocation",
            "s3:ListAllMyBuckets"
        ],
        "Resource": "arn:aws:s3:::*"
    },
        {
        "Effect": "Allow",
        "Action": ["s3:ListBucket"],
        "Resource": [
            "arn:aws:s3:::OUR_AWS_BUCKET"
        ]
        },
        {
        "Effect": "Allow",
        "Action": [
            "s3:PutObject",
            "s3:GetObject",
            "s3:DeleteObject"
        ],
        "Resource": [
            "arn:aws:s3:::OUR_AWS_BUCKET/*"
        ]
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您的IAM政策应该是

{
    "Version": "2012-10-17",
    "Statement": [{
            "Effect": "Deny",
            "Action": "*",
            "Resource": "*",
            "Condition": {
                "NotIpAddress": {
                    "aws:SourceIp": [
                        "XXX.XXX.XXX.XXX/32"
                    ]
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListAllMyBuckets"
            ],
            "Resource": "arn:aws:s3:::*"
        },
        {
            "Effect": "Allow",
            "Action": ["s3:ListBucket"],
            "Resource": [
                "arn:aws:s3:::OUR_AWS_BUCKET"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::OUR_AWS_BUCKET/*"
            ]
        }
    ]
}