I'm trying to restrict access for my S3 bucket objects to be accessible using the public URL only from instances inside a VPC. Trying to achieve it using Bucket Policy by specifying VPC id. Check the bucket policy below.
"Version": "2012-10-17",
"Id": "Policy1596618884802",
"Statement": [
{
"Sid": "Stmt1596618880986",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": [
"arn:aws:s3:::<--bucket-name-->",
"arn:aws:s3:::<--bucket-name-->/*"
],
"Condition": {
"StringEquals": {
"aws:SourceVpc": "<--vpd-id-->"
}
}
}
]
}
But even after this policy the objects are not accessible from the URL but are accessible using s3 api inside the VPC.