- Newest
- Most votes
- Most comments
Hello.
Will I get an error even if I enter the path exactly as shown below?
https://yyyyyy.cloudfront.net/index.html
The bucket policy appears to be correct.
The bucket policy you are using seems to be an old version, but it should be a policy to allow GetObject from S3, so I think it will work.
By the way, when you copy the policy when creating OAC, the version will be "2012-10-17" as shown below.
I recommend that you check whether "AWS:SourceArn" listed in the bucket policy is correct just to be sure.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html#delete-oac-distribution-s3
{
"Version": "2012-10-17",
"Statement": {
"Sid": "AllowCloudFrontServicePrincipalReadOnly",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::<S3 bucket name>/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::111122223333:distribution/<CloudFront distribution ID>"
}
}
}
}
Hi,
You probably want to follow step by step this very detailled troubleshooting guide to. find the root cause of your problem: https://repost.aws/knowledge-center/s3-website-cloudfront-error-403
Best,
Didier
Based on the information provided, there are a few potential reasons for the Access Denied error you're experiencing when trying to access your static website through CloudFront:
-
S3 Bucket Configuration: Since you have static website hosting disabled, make sure your CloudFront origin domain is set to the S3 REST API endpoint (e.g., bucket-name.s3.amazonaws.com) rather than the website endpoint.
-
Origin Access Control (OAC): Ensure that the OAC is properly configured in CloudFront and that the S3 bucket policy correctly references your CloudFront distribution's ARN.
-
Default Root Object: With static website hosting disabled, CloudFront may not serve the default root object (typically index.html) for subdirectories. You might need to implement a CloudFront function to append "index.html" to requests for directories.
-
Bucket Policy: Double-check that the AWS account ID and distribution ID in the SourceArn condition of your bucket policy are accurate.
-
CloudFront Cache Behavior: Verify that your cache behavior is set up to forward all necessary headers to the origin for OAC to work properly.
-
Object Permissions: Ensure that the objects in your S3 bucket have the correct permissions for CloudFront to access them.
To troubleshoot further:
- Verify that the CloudFront distribution status is "Deployed".
- Try accessing your content directly through the CloudFront URL (d1234abcd.cloudfront.net) to isolate any DNS issues.
- Check CloudFront logs and S3 server access logs for more detailed error information.
- Ensure all IDs and ARNs in your configurations are correct.
If the issue persists after checking these points, you may need to implement a CloudFront function to handle directory indexes, or consider re-enabling static website hosting on your S3 bucket if that aligns with your use case.
Sources
Request for Help: Access Denied Error with CloudFront and S3 Bucket Policy | AWS re:Post
Access Denied for CloudFront to S3 static site | AWS re:Post
