I am trying to setup CloudFront
to serve static files hosted in my S3
bucket. I have setup distribution but I get AccessDenied
when trying
In my case I was using multiple origins with "Path Pattern" Behaviors along with an Origin Path in my S3 bucket:
CloudFront Behavior:
/images/*
-> My-S3-origin
My-S3-origin:
Origin Path: /images
S3 files: /images/my-image.jpg
GET Request: /images/my-image.jpg -> 403
What was happening was the entire CloudFront GET request gets sent to the origin: /image/my-image.jpg
prefixed by Origin Path: /images
, so the request into S3 looks like /images/images/my-image.jpg
which doesn't exist.
remove Origin Path.