S3 Bucket Policy to Allow access to specific users and restrict all

后端 未结 1 504
一整个雨季
一整个雨季 2021-01-05 14:04

I searched through existing questions and couldnt find an answer. Hence posting here.

I want to restrict access to a S3 bucket to all users except select few users u

相关标签:
1条回答
  • 2021-01-05 14:56

    To achieve what you want, use an explicit deny with a "NotPrincipal" policy element. The policy below will ensure no other user can access the buckets other than the users listed in the "NotPrincipal" element.

        {
                "Id": "bucketPolicy",
                "Statement": [
                        {
                                "Action": "s3:*",
                                "Effect": "Deny",
                                "NotPrincipal": {
                                        "AWS": [
                                                "arn:aws:iam::1234567890:user/alloweduser"
                                        ]
                                },
                                "Resource": [
                                        "arn:aws:s3:::examplebucket",
                                        "arn:aws:s3:::examplebucket/*"
                                ]
                        }
                ],
                "Version": "2012-10-17"
        }
    
    0 讨论(0)
提交回复
热议问题