- I have created an S3 bucket and an EC2 instance.
- I have attached a role to the EC2 instance that contains
AmazonS3ReadOnlyAccesspolicy. - Used AWS CLI from EC2 instance to list all the content of my S3 bucket
- I created a bucket policy that prevents any operation from any principal on that bucket:
"Action": "s3:*",
"Effect": "Deny",
"Resource": "arn:aws:s3:::ananda-demo-bucket-1/",
"Principal": "*"
However, from my EC2 instance I can still list the content of my bucket. Does this mean that I can not override AWS IAM policy with custom bucket policy or the bucket policy which I have created is wrong?

Principalis empty. Can you show actually policy, and the instance role? - Marcin