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
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"
}