Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon S3 files access policy based on IP Address

Is there any way to limit the access of a file stored in Amazon S3 based on the client IP address?

I have a file stored there, which should be access only by specific IP address. How to do this?

like image 791
Daniel Cukier Avatar asked Jul 12 '12 17:07

Daniel Cukier


People also ask

How do you limit access to an S3 bucket by IP address?

To allow users to perform S3 actions on the bucket from the VPC endpoints or IP addresses, you must explicitly allow the user-level permissions. You can explicitly allow user-level permissions on either an AWS Identity and Access Management (IAM) policy or another statement in the bucket policy.

How do I restrict access to a bucket to a specific IP address?

You can restrict access to objects in your bucket to specific IP address by attaching policy which contains allowed IP address range in the "Condition" statement.

Do AWS S3 buckets have IP addresses?

S3 IP addresses are consumed from a AWS-owned network range that differs based on the geographical location. Your our subnet IP's won't be affected by your S3 endpoints.


1 Answers

Yes there is, although I have not used this myself.

S3 supports granular control over buckets and objects in them using "Access Policy Language". There is specific whitelist and blacklist IP statements available. You will have to write the APL statements and upload them, however.

http://docs.amazonwebservices.com/AmazonS3/latest/dev/AccessPolicyLanguage.html

Here are 2 condition section examples:

Whitelist

"Condition" :  {        "IpAddress" : {           "aws:SourceIp" : ["192.168.176.0/24","192.168.143.0/24"]       } } 

Blacklist

"Condition" :  {        "NotIpAddress" : {           "aws:SourceIp" : ["192.168.176.0/24","192.168.143.0/24"]       } } 
like image 145
gview Avatar answered Oct 17 '22 01:10

gview