- Newest
- Most votes
- Most comments
Hi,
The right way to go for such thing is to use IAM condition in the policies.
See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_aws_deny-ip.html
An example is
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"NotIpAddress": {
"aws:SourceIp": [
"192.0.2.0/24",
"203.0.113.0/24"
]
}
}
}
}
You have to adapt it for the S3 actions and the buckets that you want to allow for read for some ip addresses and for write for others
Best,
Didier
By allowing access to all, without IP restrictions for reading and with restrictions for writing, do you mean completely unauthenticated users or only users and roles in your or someone else's AWS account or organisation?
Public access even for reading is hazardous, because it allows anyone to hit your bucket with as many requests as they'd like, for which AWS will charge you per- API call and data transfer fees. We can write the bucket policy statements to allow that, if that's really your intent, but usually this isn't what most mean to do.
Relevant content
asked 3 years ago
- AWS OFFICIALUpdated 6 months ago
