I am using S3 to store some business critical documents. I want the bucket to return a 404 status code when trying to access an object that does not exist in the bucket.
The exact requirement seems to be that your user has ListBucket permission for your particular bucket AND the ARN is exactly of the form arn:aws:s3:::your_bucket_name.
I also needed to add a completely new statement to my policy because other permissions like GetObject still require that the ARN ends with /* or some other suitable wildcard.
{
"Action": [
"s3:ListBucket"
],
"Sid": "StmtNNNNNNNNNNNNNNNwholebucket",
"Resource": [
"arn:aws:s3:::your_bucket_name"
],
"Effect": "Allow"
},
To summarize, the important bit for me was that if the ARN is NOT of the form arn:aws:s3:::your_bucket_name/* for ListBucket or you will still get 403 instead of 404.