Amazon S3 Policy Example - Restricting public access by IP address

Amazon S3 Policy Example - Restricting public access by IP address

Sometimes you may want to restrict a public bucket to requests from specific IPs.  This example shows you the bucket policy to accomplish this:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "AllowPublicRead",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::llthemes/*",
            "Condition": {
                "IpAddress": {
                    "aws:SourceIp": [
                        "x.x.x.x/32",
                        "x.x.x.x/32"
                    ]
                }
            }
        }
    ]
}

Share this Post