Bypassing the S3 origin via Origin Access Control
Mar 21, 2024
- Created one bucket and uploaded the HTML file.
Press enter or click to view image in full size![]()
2. Created the CloudFront distribution
Give the origin domain from s3. Set up the OAC setting to access the content from CloudFront not from your source.
Press enter or click to view image in full size![]()
After creating the distribution, change the bucket policy like below.
{
"Version": "2008-10-17",
"Id": "PolicyForCloudFrontPrivateContent",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipal",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::2024-2/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::885078309492:distribution/EPGR2WE4GVY2V"
}
}
}
]
}After Activating the distribution, your S3 bucket URL not working. Your Cloudfront URL only working.
Press enter or click to view image in full size![]()
Press enter or click to view image in full size![]()