diff --git a/Cargo.lock b/Cargo.lock index 7e2b372d5..56969658f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + [[package]] name = "autocfg" version = "1.1.0" @@ -29,12 +35,27 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "bumpalo" version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + [[package]] name = "bytes" version = "1.3.0" @@ -63,7 +84,7 @@ dependencies = [ "js-sys", "num-integer", "num-traits", - "time", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -115,6 +136,14 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "compute-static" +version = "0.1.0" +dependencies = [ + "fastly", + "log", +] + [[package]] name = "core-foundation" version = "0.9.3" @@ -131,6 +160,15 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + [[package]] name = "curl" version = "0.4.44" @@ -205,6 +243,15 @@ dependencies = [ "syn", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + [[package]] name = "encoding_rs" version = "0.8.31" @@ -235,6 +282,62 @@ dependencies = [ "libc", ] +[[package]] +name = "fastly" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d14ee2f12a3191582449a2e080287eff8898fc52da61c437869d91c41b3ae2a" +dependencies = [ + "anyhow", + "bytes 0.5.6", + "cfg-if", + "fastly-macros", + "fastly-shared", + "fastly-sys", + "http", + "lazy_static", + "mime", + "serde", + "serde_json", + "serde_urlencoded", + "sha2", + "thiserror", + "time 0.3.17", + "url", +] + +[[package]] +name = "fastly-macros" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1b2980c09148cb84bfd18591943ee449a350dc1ff1ead69edbf012f7e2eef" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fastly-shared" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f79939bdbbab8b1de759d584f386319454f8623681400675a07f9ad35f2b158" +dependencies = [ + "bitflags", + "http", + "thiserror", +] + +[[package]] +name = "fastly-sys" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d01e98274a6b12c85c0eef22924871cc12c54b5322268947322463e59d09336" +dependencies = [ + "bitflags", + "fastly-shared", +] + [[package]] name = "fastrand" version = "1.8.0" @@ -322,13 +425,23 @@ dependencies = [ "slab", ] +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "h2" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f9f29bc9dda355256b2916cf526ab02ce0aeaaaf2bad60d65ef3f12f11dd0f4" dependencies = [ - "bytes", + "bytes 1.3.0", "fnv", "futures-core", "futures-sink", @@ -377,7 +490,7 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ - "bytes", + "bytes 1.3.0", "fnv", "itoa", ] @@ -388,7 +501,7 @@ version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ - "bytes", + "bytes 1.3.0", "http", "pin-project-lite", ] @@ -411,7 +524,7 @@ version = "0.14.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "034711faac9d2166cb1baf1a2fb0b60b1f277f8492fd72176c17f3515e1abd3c" dependencies = [ - "bytes", + "bytes 1.3.0", "futures-channel", "futures-core", "futures-util", @@ -435,7 +548,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ - "bytes", + "bytes 1.3.0", "hyper", "native-tls", "tokio", @@ -685,6 +798,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "openssl" version = "0.10.44" @@ -827,7 +946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" dependencies = [ "base64", - "bytes", + "bytes 1.3.0", "encoding_rs", "futures-core", "futures-util", @@ -971,6 +1090,19 @@ dependencies = [ "serde_json", ] +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + [[package]] name = "slab" version = "0.4.7" @@ -1038,6 +1170,26 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "time" version = "0.1.45" @@ -1049,6 +1201,32 @@ dependencies = [ "winapi", ] +[[package]] +name = "time" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +dependencies = [ + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -1071,7 +1249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eab6d665857cc6ca78d6e80303a02cea7a7851e85dfbd77cbdc09bd129f1ef46" dependencies = [ "autocfg", - "bytes", + "bytes 1.3.0", "libc", "memchr", "mio", @@ -1097,7 +1275,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740" dependencies = [ - "bytes", + "bytes 1.3.0", "futures-core", "futures-sink", "pin-project-lite", @@ -1137,6 +1315,12 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + [[package]] name = "unicode-bidi" version = "0.3.8" diff --git a/terragrunt/accounts/legacy/crates-io-staging/crates-io/.terraform.lock.hcl b/terragrunt/accounts/legacy/crates-io-staging/crates-io/.terraform.lock.hcl index 722648ea7..d8b278a94 100644 --- a/terragrunt/accounts/legacy/crates-io-staging/crates-io/.terraform.lock.hcl +++ b/terragrunt/accounts/legacy/crates-io-staging/crates-io/.terraform.lock.hcl @@ -1,6 +1,28 @@ # This file is maintained automatically by "terraform init". # Manual edits may be lost in future updates. +provider "registry.terraform.io/fastly/fastly" { + version = "3.0.0" + constraints = "3.0.0" + hashes = [ + "h1:4+Tn2eY5zXc/h5laTgq6L32dSXibdhtIuOuon77WPJg=", + "zh:2413350985511d4c9b712ae69b21db2aed33d8d29a13ade8a5c0beb086895909", + "zh:25862534a8e89df4824789b81d7436fd512b7d0a94f962183fa1cef9abcb0d65", + "zh:31d49d8482436f4abe3e0085a7afba69fb6793afef33b32aa6f2002a046875c7", + "zh:47d6754dfa1ba71bba64e043c0d2f3606c3dffdec7928be55f5dd0b4f2de9e52", + "zh:4c49581dc4bc47bd5e31333f7d211d914ec7581b9dba6c20b5d255906611e40a", + "zh:5ee7dfedee80513e39124f5138e7d26d9bed3cb95ba487698c0eacc9d15834b6", + "zh:62ab9067b04bd7363031e41013cf112628042f49e501ce0bcd81cedd35884069", + "zh:6844386e6670cf3792089bc38099e8d3de6281a1d78154263bb4de0792bf9548", + "zh:74f4bb78a90107261b16e67b768cfe53fd43cb5d99e063d070139198c7a3032c", + "zh:8008409d5d42c641aa10e57688fa7915d6bee28fa3623af37d3c9b63fe090c0b", + "zh:850ace0895c3bb168b0a58f595f68fdd5b334c53384a20a844befefa46c2aa64", + "zh:a162f28658721c97e57a1ed07b863929001f23b65ebc35d5aeb22da910f59d71", + "zh:bece5c0816230c31d99c78e775fa00298ac6272af996d685730a7b72d12e0658", + "zh:de82eb1422aea19bcefc40b3408c12b9d9679bd29275eab7c775070786300d72", + ] +} + provider "registry.terraform.io/hashicorp/aws" { version = "4.45.0" constraints = "~> 4.32" @@ -23,3 +45,22 @@ provider "registry.terraform.io/hashicorp/aws" { "zh:f6d355a2fb3bcebb597f68bbca4fa2aaa364efd29240236c582375e219d77656", ] } + +provider "registry.terraform.io/hashicorp/external" { + version = "2.2.3" + hashes = [ + "h1:648ZjJR81c2W1OLtYmUQa9/1rGr3vvZSuX9dR1ucGWY=", + "zh:184ecd339d764de845db0e5b8a9c87893dcd0c9d822167f73658f89d80ec31c9", + "zh:2661eaca31d17d6bbb18a8f673bbfe3fe1b9b7326e60d0ceb302017003274e3c", + "zh:2c0a180f6d1fc2ba6e03f7dfc5f73b617e45408681f75bca75aa82f3796df0e4", + "zh:4b92ae44c6baef4c4952c47be00541055cb5280dd3bc8031dba5a1b2ee982387", + "zh:5641694d5daf3893d7ea90be03b6fa575211a08814ffe70998d5adb8b59cdc0a", + "zh:5bd55a2be8a1c20d732ac9c604b839e1cadc8c49006315dffa4d709b6874df32", + "zh:6e0ef5d11e1597202424b7d69b9da7b881494c9b13a3d4026fc47012dc651c79", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:9e19f89fa25004d3b926a8d15ea630b4bde62f1fa4ed5e11a3d27aabddb77353", + "zh:b763efdd69fd097616b4a4c89cf333b4cee9699ac6432d73d2756f8335d1213f", + "zh:e3b561efdee510b2b445f76a52a902c52bee8e13095e7f4bed7c80f10f8d294a", + "zh:fe660bb8781ee043a093b9a20e53069974475dcaa5791a1f45fd03c61a26478a", + ] +} diff --git a/terragrunt/modules/crates-io/_terraform.tf b/terragrunt/modules/crates-io/_terraform.tf index 57e7e1740..2ff2c3d29 100644 --- a/terragrunt/modules/crates-io/_terraform.tf +++ b/terragrunt/modules/crates-io/_terraform.tf @@ -5,6 +5,10 @@ terraform { version = "~> 4.20" configuration_aliases = [aws.us-east-1, aws.eu-west-1] } + fastly = { + source = "fastly/fastly" + version = "3.0.0" + } } } @@ -18,6 +22,8 @@ provider "aws" { region = "eu-west-1" } +provider "fastly" {} + data "aws_caller_identity" "current" {} data "terraform_remote_state" "shared" { diff --git a/terragrunt/modules/crates-io/compute-static/.cargo/config b/terragrunt/modules/crates-io/compute-static/.cargo/config new file mode 100644 index 000000000..6b77899cb --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/.cargo/config @@ -0,0 +1,2 @@ +[build] +target = "wasm32-wasi" diff --git a/terragrunt/modules/crates-io/compute-static/.gitignore b/terragrunt/modules/crates-io/compute-static/.gitignore new file mode 100644 index 000000000..9f6a0890d --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/.gitignore @@ -0,0 +1,4 @@ +/target +**/*.rs.bk +/bin +/pkg diff --git a/terragrunt/modules/crates-io/compute-static/Cargo.lock b/terragrunt/modules/crates-io/compute-static/Cargo.lock new file mode 100644 index 000000000..cabef6508 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/Cargo.lock @@ -0,0 +1,411 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "compute-static" +version = "0.1.0" +dependencies = [ + "fastly", + "log", +] + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "fastly" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d14ee2f12a3191582449a2e080287eff8898fc52da61c437869d91c41b3ae2a" +dependencies = [ + "anyhow", + "bytes 0.5.6", + "cfg-if", + "fastly-macros", + "fastly-shared", + "fastly-sys", + "http", + "lazy_static", + "mime", + "serde", + "serde_json", + "serde_urlencoded", + "sha2", + "thiserror", + "time", + "url", +] + +[[package]] +name = "fastly-macros" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1b2980c09148cb84bfd18591943ee449a350dc1ff1ead69edbf012f7e2eef" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fastly-shared" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f79939bdbbab8b1de759d584f386319454f8623681400675a07f9ad35f2b158" +dependencies = [ + "bitflags", + "http", + "thiserror", +] + +[[package]] +name = "fastly-sys" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d01e98274a6b12c85c0eef22924871cc12c54b5322268947322463e59d09336" +dependencies = [ + "bitflags", + "fastly-shared", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "http" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" +dependencies = [ + "bytes 1.3.0", + "fnv", + "itoa", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "itoa" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.138" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "proc-macro2" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" + +[[package]] +name = "serde" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fed41fc1a24994d044e6db6935e69511a1153b52c15eb42493b26fa87feba0" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.151" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "255abe9a125a985c05190d687b320c12f9b1f0b99445e608c21ba0782c719ad8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877c235533714907a8c2464236f5c4b2a17262ef1bd71f38f35ea592c8da6883" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + +[[package]] +name = "syn" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thiserror" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +dependencies = [ + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" diff --git a/terragrunt/modules/crates-io/compute-static/Cargo.toml b/terragrunt/modules/crates-io/compute-static/Cargo.toml new file mode 100644 index 000000000..24a9e4b36 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/Cargo.toml @@ -0,0 +1,19 @@ +# The Fastly function is built inside a virtual Terragrunt environment. Only the +# crates-io module is copied into this environment, which means it cannot be a +# part of the workspace at the root of this repository. +[workspace] + +[package] +name = "compute-static" +description = "Compute@Edge function for static.crates.io" +version = "0.1.0" +edition = "2021" + +publish = false + +[profile.release] +debug = 1 + +[dependencies] +fastly = "0.8.9" +log = "0.4.17" diff --git a/terragrunt/modules/crates-io/compute-static/README.md b/terragrunt/modules/crates-io/compute-static/README.md new file mode 100644 index 000000000..da25b0287 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/README.md @@ -0,0 +1,31 @@ +# Compute@Edge Function for `static.crates.io` + +We are using a [Compute@Edge](https://docs.fastly.com/en/guides/compute-at-edge) +function on [Fastly](https://fastly.com) to route incoming traffic for +`static.crates.io` to S3. The function tries to get crates from the primary +bucket, and will fail over to a fallback if it receives any HTTP `5xx` +responses. + +## Development + +Build the function: + +```shell +cd compute-static +fastly compute build +``` + +## Deployment + +Terraform uses an [external data source] to build the function as part of its +plan. This ensures that the function is always up-to-date, and prevents users +from accidentally uploading a stale version of the WASM module. + +Export an API token for Fastly and then run Terraform: + +```shell +export FASTLY_API_KEY="" +terraform plan +``` + +[external data source]: https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source diff --git a/terragrunt/modules/crates-io/compute-static/bin/terraform-external-build.sh b/terragrunt/modules/crates-io/compute-static/bin/terraform-external-build.sh new file mode 100755 index 000000000..1c5e2fd18 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/bin/terraform-external-build.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Build script used by Terraform to build the function when planning. +# +# This script is called by Terraform to build the function when a user runs +# `terraform plan`. This ensures that the function is always up-to-date, and +# prevents users from accidentally uploading a stale version of the WASM module. +# +# Terraform expects the script to output a valid JSON object. +# +# https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source + +# Enable strict mode for Bash +# http://redsymbol.net/articles/unofficial-bash-strict-mode/ +set -euo pipefail +IFS=$'\n\t' + +script_path=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd) +project_path=$(cd "${script_path}" && cd ".." && pwd) +project_name="${project_path##*/}" + +cd "${project_path}" && fastly compute build &>/dev/null + +# Return a valid JSON object that Terraform can consume +echo "{\"path\": \"./${project_name}/pkg/compute-static.tar.gz\"}" diff --git a/terragrunt/modules/crates-io/compute-static/fastly.toml b/terragrunt/modules/crates-io/compute-static/fastly.toml new file mode 100644 index 000000000..d67ae4d58 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/fastly.toml @@ -0,0 +1,12 @@ +# This file describes a Fastly Compute@Edge package. To learn more visit: +# https://developer.fastly.com/reference/fastly-toml/ + +authors = ["infra@rust-lang.org"] +description = "Compute@Edge function for static.crates.io" +language = "rust" +manifest_version = 2 +name = "compute-static" +service_id = "" + +[scripts] + build = "cargo build --bin compute-static --release --target wasm32-wasi --color always" diff --git a/terragrunt/modules/crates-io/compute-static/rust-toolchain.toml b/terragrunt/modules/crates-io/compute-static/rust-toolchain.toml new file mode 100644 index 000000000..5914a5625 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +targets = [ "wasm32-wasi" ] diff --git a/terragrunt/modules/crates-io/compute-static/src/config.rs b/terragrunt/modules/crates-io/compute-static/src/config.rs new file mode 100644 index 000000000..2f981f171 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/src/config.rs @@ -0,0 +1,35 @@ +use fastly::ConfigStore; + +// Name of the dictionary. Must match the dictionary in `fastly-static.tf`. +const DICTIONARY_NAME: &str = "compute_static"; + +// Name of the dictionary item with the name of the primary host. +const PRIMARY_HOST: &str = "s3-primary-host"; + +// Name of the dictionary item with the name of the fallback host. +const FALLBACK_HOST: &str = "s3-fallback-host"; + +#[derive(Debug)] +pub struct Config { + pub primary_host: String, + pub fallback_host: String, +} + +impl Config { + pub fn from_dictionary() -> Self { + let dictionary = ConfigStore::open(DICTIONARY_NAME); + + // Lookup S3 hosts for current environment + let primary_host = dictionary + .get(PRIMARY_HOST) + .expect("failed to get S3 primary host from dictionary"); + let fallback_host = dictionary + .get(FALLBACK_HOST) + .expect("failed to get S3 fallback host from dictionary"); + + Self { + primary_host, + fallback_host, + } + } +} diff --git a/terragrunt/modules/crates-io/compute-static/src/main.rs b/terragrunt/modules/crates-io/compute-static/src/main.rs new file mode 100644 index 000000000..8b8c39cf8 --- /dev/null +++ b/terragrunt/modules/crates-io/compute-static/src/main.rs @@ -0,0 +1,60 @@ +use fastly::http::{Method, StatusCode}; +use fastly::{Error, Request, Response}; +use log::warn; + +use crate::config::Config; + +mod config; + +#[fastly::main] +fn main(request: Request) -> Result { + let config = Config::from_dictionary(); + + if let Some(response) = limit_http_methods(&request) { + return Ok(response); + } + + send_request_to_s3(&config, &request) +} + +/// Limit HTTP methods +/// +/// Clients are only allowed to request resources using GET and HEAD requests. If any other HTTP +/// method is received, HTTP 403 Unauthorized is returned. +/// +/// We don't return HTTP 405 Method Not Allowed to maintain parity with CloudFront. +fn limit_http_methods(request: &Request) -> Option { + let method = request.get_method(); + + if method != Method::GET && method != Method::HEAD { + return Some( + Response::from_body("Method not allowed").with_status(StatusCode::UNAUTHORIZED), + ); + } + + None +} + +/// Forward client request to S3 +/// +/// The request that was received by the client is forwarded to S3. First, the primary bucket is +/// queried. If the response indicates a server issue (status code >= 500), the request is sent to +/// a fallback bucket in a different geographical region. +fn send_request_to_s3(config: &Config, request: &Request) -> Result { + let primary_request = request.clone_without_body(); + + let mut response = primary_request.send(&config.primary_host)?; + let status_code = response.get_status().as_u16(); + + if status_code >= 500 { + warn!( + "Request to host {} returned status code {}", + config.primary_host, status_code + ); + + let fallback_request = request.clone_without_body(); + response = fallback_request.send(&config.fallback_host)?; + } + + Ok(response) +} diff --git a/terragrunt/modules/crates-io/fastly-static.tf b/terragrunt/modules/crates-io/fastly-static.tf new file mode 100644 index 000000000..0e68fb80a --- /dev/null +++ b/terragrunt/modules/crates-io/fastly-static.tf @@ -0,0 +1,126 @@ +# The Fastly service must be deployed in two steps, since some resources depend +# on attributes that are only known after an `apply`. To deploy the service, +# comment out everything in Stage 2 and then run `terragrunt apply`. After the +# run has finished, uncomment Stage 2 and run `terragrunt apply` again. + +locals { + fastly_domain_name = "fastly-${var.static_domain_name}" + + primary_host_name = aws_s3_bucket.static.region + fallback_host_name = aws_s3_bucket.fallback.region + + dictionary_name = "compute_static" +} + +data "external" "package" { + program = ["bash", "terraform-external-build.sh"] + working_dir = "./compute-static/bin" +} + +### Stage 1 + +resource "fastly_service_compute" "static" { + name = var.static_domain_name + + domain { + name = local.fastly_domain_name + } + + backend { + # Must be identical to s3-primary-host item in dictionary + name = local.primary_host_name + + address = aws_s3_bucket.static.bucket_regional_domain_name + override_host = aws_s3_bucket.static.bucket_regional_domain_name + + use_ssl = true + port = 443 + ssl_cert_hostname = aws_s3_bucket.static.bucket_regional_domain_name + } + + backend { + # Must be identical to s3-fallback-host item in dictionary + name = local.fallback_host_name + + address = aws_s3_bucket.fallback.bucket_regional_domain_name + override_host = aws_s3_bucket.fallback.bucket_regional_domain_name + + use_ssl = true + port = 443 + ssl_cert_hostname = aws_s3_bucket.fallback.bucket_regional_domain_name + } + + dictionary { + name = local.dictionary_name + } + + package { + filename = data.external.package.result.path + source_code_hash = filesha512(data.external.package.result.path) + } +} + +resource "fastly_service_dictionary_items" "compute_static" { + for_each = { + for d in fastly_service_compute.static.dictionary : d.name => d if d.name == local.dictionary_name + } + + service_id = fastly_service_compute.static.id + dictionary_id = each.value.dictionary_id + manage_items = true + + items = { + "s3-primary-host" : local.primary_host_name + "s3-fallback-host" : local.fallback_host_name + } +} + +resource "fastly_tls_subscription" "static" { + certificate_authority = "lets-encrypt" + domains = [local.fastly_domain_name] +} + +### Stage 2 + +resource "aws_route53_record" "static_tls_validation" { + depends_on = [fastly_tls_subscription.static] + + for_each = { + for challenge in fastly_tls_subscription.static.managed_dns_challenges : + trimprefix(challenge.record_name, "_acme-challenge.") => challenge + } + + name = each.value.record_name + type = each.value.record_type + zone_id = data.aws_route53_zone.static.id + allow_overwrite = true + records = [each.value.record_value] + ttl = 60 +} + +resource "fastly_tls_subscription_validation" "static" { + depends_on = [aws_route53_record.static_tls_validation] + subscription_id = fastly_tls_subscription.static.id +} + +locals { + # It is currently not possible to get the CNAME for TLS-enabled hostnames as a + # Terraform resource. But the ACME HTTP challenge redirects production traffic + # to Fastly, for which it uses the CNAME that we are looking for. + # + # The below snippet is a hack to get the CNAME for the static domain from the + # HTTP challenge, until Fastly exposes it in the Terraform provider. + fastly_static_destinations = flatten([ + for record in fastly_tls_subscription.static.managed_http_challenges : + record.record_values if record.record_type == "CNAME" + ]) +} + +resource "aws_route53_record" "fastly_static_domain" { + name = local.fastly_domain_name + type = "CNAME" + zone_id = data.aws_route53_zone.static.id + allow_overwrite = true + records = local.fastly_static_destinations + ttl = 60 +}