Here is the bucket policy that I implemented in my bucket.
{
"Id": "Policy1535460101139",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1535460099601",
"Action": "s3:*",
"Effect": "Deny",
"Resource": "arn:aws:s3:::bucketname",
"Condition": {
"StringNotEquals": {
"aws:SourceVpc": "vpc-id"
}
},
"Principal": "*"
}
]
}
Just after saving this bucket policy I'm unable to list or do anything with my bucket from console(I have s3 full access) with everything displaying access denied. Hence when I tried to copy a file from one of the ec2 instances in the VPC the copy was successfull but I was unable to list the objects in the bucket. I get an access denied error msg.(The ec2 instance has a role with full permission to the bucket). Here is the Role attached to the EC2 instance.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:::bucketname/*"
}
]
}
What I want to know is whether this weird behaviour is a cause of my bucket policy or it may be something else. If yes any tips on how can I change my bucket policy now? Moreover here is screenshot from my console.