From cac939e31fed621d38ec108cfd4037b78e99b79a Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Tue, 21 Jul 2020 23:26:23 +0100 Subject: [PATCH] Updating terraform --- .../lambda/prod-panaetius-blog-lambda/main.js | 13 +- .../prod-panaetius-blog-lambda/main.js.zip | Bin 0 -> 601 bytes .../prod-panaetius-blog-lambda/main.zip | Bin 546 -> 0 bytes infrastructure/main.tf | 63 ++++---- .../prod-eu-west-1/terraform.tfstate | 151 ++++++----------- .../prod-eu-west-1/terraform.tfstate.backup | 153 ++++++------------ .../variables/prod-eu-west-1.tfvars | 2 +- 7 files changed, 135 insertions(+), 247 deletions(-) create mode 100644 infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip delete mode 100644 infrastructure/lambda/prod-panaetius-blog-lambda/main.zip diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js index 8ddc9f2..6c9f2bf 100644 --- a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js +++ b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js @@ -5,10 +5,17 @@ exports.handler = (event, context, callback) => { var request = event.Records[0].cf.request; // Extract the URI from the request - var oldURI = request.url; + var oldURI = request.uri; // Match any '/' that occurs at the end of a URI. Replace it with a default index - var newURI = oldURI.replace(/\/$, '\/index.html'/); + 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}`); @@ -18,5 +25,5 @@ exports.handler = (event, context, callback) => { request.uri = newURI; // Return to Cloudfront - return callback(null, request) + return callback(null, request); }; diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip b/infrastructure/lambda/prod-panaetius-blog-lambda/main.js.zip new file mode 100644 index 0000000000000000000000000000000000000000..bfff512512451196e00197d92602eee1e58489f2 GIT binary patch literal 601 zcmWIWW@Zs#-~d7f2E{HQ0SD|rR&HWuo?cdQOR#UYw4unJ_v3CVN`P$~36vq2rea&m^~>&Api3+HtN~JkCgH8?!&J#I!A!V+2AD z1h&e_OtO+IZ7`bTCwjqExoH#II){4K<xc=Su)n(`IUFmGpw4S0K^Zoa?XLnlyA|9_*TlQA%^{G;K zMXTl-%H-<;fh&tY_Lmjkl>T0z;vwsi^w*}B*W73^kF2p# z#2U_vlYNf&UHYUKz1=T&%E|)MN0-fYFJJz?qf%4ooPXpC(HGed{TC?NHFsSqe6AYN zd`3l0Jz>s5m)jh&sy}1So=Z4hyiNV0v$e#RTMDz~-=utcwQ2Il)w5@>_NfGh_}4=}K#5yXO~jsR~~HV~H) M2u*=B9}|cN05+xs(f|Me literal 0 HcmV?d00001 diff --git a/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip b/infrastructure/lambda/prod-panaetius-blog-lambda/main.zip deleted file mode 100644 index 8913aa049804cde1ce8bb7b5067aeb1ca23237d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 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