-
Create an empty aws S3 bucket.
-
Create the lambda function in us-east-1 since it will be used for cloudfront using redirecturl.js.
-
Publish the new version of this lambda function.
-
Create a Cloudfront distribution on this bucket using cname containing www
-
In Cloudfront distribution, while creating Behavior, In Lambda function associations choose below values
Event Type - Viewer Request Lambda Function ARN - arn:aws:lambda:us-east-1:ACC_ID:function:FUNCTION_NAME:PUBLISHED_VERSION