From b7a7ab65390088fdfb464ae010b2d8fcac498e21 Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Sun, 19 Jul 2020 03:28:31 +0100 Subject: [PATCH] Updating latest --- blog/config.toml | 3 +- .../lambda/prod-panaetius-blog-lambda/main.js | 22 ++ .../prod-panaetius-blog-lambda/main.zip | Bin 0 -> 546 bytes infrastructure/main.tf | 128 ++++++++-- .../prod-eu-west-1/terraform.tfstate | 222 ++++++++++++++-- .../prod-eu-west-1/terraform.tfstate.backup | 236 ++++++++++++++++-- infrastructure/variables.tf | 23 +- .../variables/prod-eu-west-1.tfvars | 21 +- 8 files changed, 581 insertions(+), 74 deletions(-) create mode 100644 infrastructure/lambda/prod-panaetius-blog-lambda/main.js create mode 100644 infrastructure/lambda/prod-panaetius-blog-lambda/main.zip diff --git a/blog/config.toml b/blog/config.toml index 80398c6..44dcf57 100644 --- a/blog/config.toml +++ b/blog/config.toml @@ -1,4 +1,5 @@ -baseURL = "panaetius.io" +baseURL = "https://panaetius.io/" +# relativeURLs = true title = "panaetius.io" # theme = "panaetius-chunky-theme" theme = ["hugo-notice-admonition", "panaetius-theme"] diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js new file mode 100644 index 0000000..8ddc9f2 --- /dev/null +++ b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js @@ -0,0 +1,22 @@ +"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.url; + + // Match any '/' that occurs at the end of a URI. Replace it with a default index + var newURI = oldURI.replace(/\/$, '\/index.html'/); + + // 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) +}; diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip b/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip new file mode 100644 index 0000000000000000000000000000000000000000..8913aa049804cde1ce8bb7b5067aeb1ca23237d4 GIT binary patch literal 546 zcmWIWW@Zs#U|`^2NSggI;A-KwraDFjhO0~r4D1Xt47rJ!d3ssJp&^_M%oT41<12x< zw1S&~k>x8;6m^)nh^B0R-nBHqMkI&Z$$x8t+05DtGj7n_$)f6ArHZx>?LqC;bkncy!6AT$qh%nzj)0S~gidp=&AeMxS;hnOf~o z4m9scopZw6V`X0`($uYeQjcz% zaZd5B*h0(vGxL@o&6%)i+Sjw37yWdOe(T^l_4&QR-72T)k2&V*9ThtGcGAz})_do4 z*;n4$CCYd2ZGd;5<@C~R)sN5g-#h$8h&8U<@5uaR*E`n1qz9`9~(tY4|yWN*%Nw5T54|l!~nT}iE28}KQm@bixEG`AK=Z% uB*%;^0wsVE%fJAPDTXDDAQn72Ss~Gh7L@_stZX1