I have a static website hosted on S3 with cloudfront configured to it. My Main aim is to configure my site in a way that it is only accessible through a specific IP address. I have tried WAF and the website is getting cached in my browser and im able to access it from other ip address even though WAF is enabled. I have tried below policy and i do not see any change. I do not have a problem to get rid of cloudfront for this but tried disabling cloudfront and tried accessing from s3 endpoint all i got is 403 forbidden from any ip address. I don't know what iam missing here.
{
"Version": "2012-10-17",
"Id": "S3PolicyId1",
"Statement": [
{
"Sid": "IPAllow",
"Effect": "Allow",
"Principal": "AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity xxxxxxxxxxxx"
},,
"Action": "s3:*",
"Resource": "arn:aws:s3:::examplebucket/*",
"Condition": {
"IpAddress": {"aws:SourceIp": "54.240.143.0/24"},
"NotIpAddress": {"aws:SourceIp": "54.240.143.188/32"}
}
}
]
}