DEV Community

Discussion on: Migrating from Lambda@Edge to CloudFront Functions

Collapse
wparad profile image
Warren Parad

This is a great write-up. For what it's worth, I will mention, that this isn't a good use of a lambda, you can just deploy the index.html file twice, once to the /path/index.html and once to the /path/ location, you can also decide to upload it additionally to /path as well. This is a free solution.

Collapse
jimmydqv profile image
Jimmy Dahlqvist Author

There is actually a index.html file present under /path/ . Since links in my blog, consisting of static generated files, points to /path/ and not to /path/index.html CloudFront will request the /path/ from S3, CloudFront doesn't "speak" web server. Since there is no file in S3 called /path/ it will end up with an 404 error. Therefore the Lambda rewrites the path and append index.html so the correct file is requested from S3.
So either I have change all links to point to the actual index.html file or use a Lambda@Edge to do it for me.

Collapse
wparad profile image
Warren Parad

that's exactly my point, create a file called /path/ problem solved.