1 Answer
- Newest
- Most votes
- Most comments
2
Hello.
Have you configured custom error responses in CloudFront?
By setting a custom error response, you can display a custom error page when the corresponding error occurs.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/GeneratingCustomErrorResponses.html
"AccessDenied" will probably become "404 NotFound" if you allow the "s3:ListBucket" action in the S3 bucket policy.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowCloudFrontServicePrincipalReadOnly",
"Effect": "Allow",
"Principal": {
"Service": "cloudfront.amazonaws.com"
},
"Action": ["s3:GetObject", "s3:ListBucket"],
"Resource": ["arn:aws:s3:::cik-front-end/*", "arn:aws:s3:::cik-front-end"],
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::339712767340:distribution/EQDQLH88I63IN"
}
}
}
]
}
Relevant content
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated a year ago
You need
ListBucket
access in addition to the documentation you provided on CloudFront custom errors?Looks like that doesn't quite work. The error becomes:
Have you set a custom error response? Because if you didn't you will continue getting that default error.
@osvaldo yes. I have:
/error.html
file and the custom responseNone of these actually show that
html
document. It simply changed the error to theNoSuchKey
(posted above).EDIT: I tried again a few moments later and it works. I guess it was cached.
can you confirm that the
error.html
file is located at the root of your S3 bucket? You need to specify the correct path to theerror.html
file relative to the root of the S3 bucket.