I use Serverless to deploy a website to an AWS Lambda. This works fine. I now want to use CloudFront to proxy access to this Lambda and cache requests for static files.
I have set up a CloudFront distribution, and created an origin with the origin domain name set to that of the Lambda API gateway, i.e. foobarbaz123.execute-api.eu-west-2.amazonaws.com
(note: I can access the static files if I visit this URL directly). I was hoping that this would now allow me to access the static site that the Lambda serves through the CloudFront domain, i.e. abcdefg123.cloudfront.net
. However, I recieve a 403 forbidden error when I attempt this.
The origin's settings are pretty much the defaults, save for 'HTTPS only'. I have not touched the Lambda or its S3 bucket since deploying it with sls deploy
.
What could I be doing wrong?