I have a bucket my_super_bucket
with the following statement:
"Statement": [
{
"Sid": "Stmt4214214",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::my_super_bucket/*",
"Condition": {
"IpAddress": {
"aws:SourceIp": [
"my_super_ip_1",
"my_super_ip_2"
]
}
}
}
]
Previously, the bucket had public permission for List Objects, so as I want to only allow those two IPs, I removed that privilege. However, I still can access any file in this bucket from a different IP. Further troubleshooting, I took the following three steps:
- I thought it might be because of CloudFront cache, so tried to access the file directly with the S3 URL, still could download it.
- Added a
"NotIpAddress": { "aws:SourceIp": "*"}
to the conditions as well, still could access the files. - Removed the Read object permission of each file. Now I can't access the file, no matter the SourceIP.
So, how can I achieve my goal to just allow certain IPs to access any file of a specific bucket? On IRC, a guy told me that these policies only apply to AWS CLI, but there must be a way to restrict access via URL as well, right?