CloudFront returns `403 AccessDenied` (S3 XML) for every object after you switched the S3 origin to Origin Access Control.
IntermediateTroubleshootingRoute 53, CloudFront, API Gateway and Messaging
Answer
Likely causes → The bucket policy does not allow the cloudfront.amazonaws.com service principal with AWS:SourceArn set to this distribution. Other causes: objects are SSE-KMS and the key policy does not allow CloudFront, the request has no default root object, or the key is missing (S3 returns 403 instead of 404 without s3:ListBucket).
Diagnose →
aws cloudfront get-distribution-config --id E123ABC --query 'DistributionConfig.[DefaultRootObject,Origins.Items[].[DomainName,OriginAccessControlId]]'
aws s3api get-bucket-policy --bucket site-assets --output text
aws s3api head-object --bucket site-assets --key index.html
Fix →
{"Effect":"Allow","Principal":{"Service":"cloudfront.amazonaws.com"},
"Action":"s3:GetObject","Resource":"arn:aws:s3:::site-assets/*",
"Condition":{"StringEquals":{"AWS:SourceArn":"arn:aws:cloudfront::111111111111:distribution/E123ABC"}}}
Add a kms:Decrypt statement for CloudFront to the key policy if the objects use SSE-KMS, and set DefaultRootObject to index.html.
Prevent → Create the OAC, the bucket policy and the distribution together in one IaC module.
More on Route 53, CloudFront, API Gateway and Messaging
You created a public hosted zone and records for `example.com`, but `dig example.com` returns `NXDOMAIN` or old records.Beginner`InvalidChangeBatch: RRSet of type CNAME with DNS name example.com. is not permitted at apex in zone example.com.`BeginnerThe primary Region is down, but Route 53 failover records still send traffic to it.IntermediateA Route 53 health check reports `Failure: Connection timed out` for an endpoint that works fine from your laptop.IntermediateYou changed an A record an hour ago, but some users still reach the old server, and a newly created name returned `NXDOMAIN` for a while.AdvancedCloudFront shows `502 ERROR. The request could not be satisfied. CloudFront wasn't able to connect to the origin.`Intermediate