adding terraform config

This commit is contained in:
2021-03-18 01:00:12 +00:00
parent 848551e00a
commit 7df0ed18f7
11 changed files with 1106 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
"use strict";
exports.handler = (event, context, callback) => {
// Extract the request from the Cloudfront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
// Extract the URI from the request
var oldURI = request.uri;
// Match any '/' that occurs at the end of a URI. Replace it with a default index
function replace_uri(uri) {
uri = uri.replace(/\/$/, "/index.html");
// uri = uri.replace(/\.io\/search\?q\=(.*)/, ".io/search/index.html?q=$1");
// console.log(uri)
return uri;
}
// var newURI = oldURI.replace(/\/$/, "/index.html");
var newURI = replace_uri(oldURI);
// Log the URI as received by Cloudfront and the new URI to be used to fetch from the origin
console.log(`Old URI: ${oldURI}`);
console.log(`New URI: ${newURI}`);
// Replace the received URI with the URI that includes the index page
request.uri = newURI;
// Return to Cloudfront
return callback(null, request);
};