PRECONDITION

Today we will see how we can use the Lambda Edge to insert “/index.html” at the end of the URLs of a static site distributed by Cloudfront

PROCEDURE

Go to Nord Virginia region (us-east-1) e create a Function. You can choose Broswe serverless app repository, you search cloudfront.

You choose cloudfront-s3-origin-website-redirects, in the next screen, write you application name, bucket name and click to deploy.

When Serverless have created you lambda, you go in the lambda role. You can replace Trust Relationship with this policy:

Copy to Clipboard

You could use this code for insert the “/index.html” at the end of you URL:

Copy to Clipboard

Now go to Cloudfront and in Behaviors select it and Edit. In the Bottom use Origin Request e put you lambda arn.

For the logs, you need to search in a region near at the client request, it’s so important!

That’s it!

CONCLUSIONS

Let us know if you have solved the problem!

AWS Certified Solutions Architect Official Study Guide: https://amzn.to/2HQ0UM4

AWS Certified Solutions Architect Associate Practice Tests: https://amzn.to/2T9APwz

Image credit AWS

Recent Tweets

For privacy reasons Twitter needs your permission to be loaded.
I Accept