Compare commits

...

8 Commits

Author SHA1 Message Date
Amaury
a36790c6a5
wip runtime 2024-12-30 12:13:26 +01:00
Amaury
f6cafb849e
works 2024-12-30 12:13:26 +01:00
Amaury
98669f0179
typechange 2024-12-30 12:13:26 +01:00
Amaury
cafadcfe6e
add docs 2024-12-30 12:13:26 +01:00
Amaury
f562830717
move 2024-12-30 12:13:26 +01:00
Amaury
47f1666af6
first version of terraform 2024-12-30 12:13:26 +01:00
Amaury
43e4aa8006
only vuild sqs 2024-12-30 12:13:26 +01:00
Amaury
202becb847
add sqs 2024-12-30 12:13:26 +01:00
9 changed files with 865 additions and 8 deletions

604
Cargo.lock generated
View File

@ -335,6 +335,28 @@ dependencies = [
"tokio",
]
[[package]]
name = "async-stream"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476"
dependencies = [
"async-stream-impl",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-stream-impl"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.90",
]
[[package]]
name = "async-task"
version = "4.7.1"
@ -384,6 +406,48 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "aws-config"
version = "1.5.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "649316840239f4e58df0b7f620c428f5fababbbca2d504488c641534050bd141"
dependencies = [
"aws-credential-types",
"aws-runtime",
"aws-sdk-sso",
"aws-sdk-ssooidc",
"aws-sdk-sts",
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-types",
"bytes",
"fastrand 2.3.0",
"hex",
"http 0.2.12",
"ring",
"time",
"tokio",
"tracing",
"url",
"zeroize",
]
[[package]]
name = "aws-credential-types"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60e8f6b615cb5fc60a98132268508ad104310f0cfb25a1c22eee76efdf9154da"
dependencies = [
"aws-smithy-async",
"aws-smithy-runtime-api",
"aws-smithy-types",
"zeroize",
]
[[package]]
name = "aws-lc-rs"
version = "1.12.0"
@ -410,6 +474,286 @@ dependencies = [
"paste",
]
[[package]]
name = "aws-runtime"
version = "1.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44f6f1124d6e19ab6daf7f2e615644305dc6cb2d706892a8a8c0b98db35de020"
dependencies = [
"aws-credential-types",
"aws-sigv4",
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-types",
"bytes",
"fastrand 2.3.0",
"http 0.2.12",
"http-body 0.4.6",
"once_cell",
"percent-encoding",
"pin-project-lite",
"tracing",
"uuid",
]
[[package]]
name = "aws-sdk-sqs"
version = "1.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9466fd797274f6c55454ea5aac51fc55a9bac6ca2116ed32cfb3134bb3fbcf0"
dependencies = [
"aws-credential-types",
"aws-runtime",
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-types",
"bytes",
"http 0.2.12",
"once_cell",
"regex-lite",
"tracing",
]
[[package]]
name = "aws-sdk-sso"
version = "1.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb25f7129c74d36afe33405af4517524df8f74b635af8c2c8e91c1552b8397b2"
dependencies = [
"aws-credential-types",
"aws-runtime",
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-types",
"bytes",
"http 0.2.12",
"once_cell",
"regex-lite",
"tracing",
]
[[package]]
name = "aws-sdk-ssooidc"
version = "1.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d03a3d5ef14851625eafd89660a751776f938bf32f309308b20dcca41c44b568"
dependencies = [
"aws-credential-types",
"aws-runtime",
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-json",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-types",
"bytes",
"http 0.2.12",
"once_cell",
"regex-lite",
"tracing",
]
[[package]]
name = "aws-sdk-sts"
version = "1.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3a9f073ae3a53b54421503063dfb87ff1ea83b876f567d92e8b8d9942ba91b"
dependencies = [
"aws-credential-types",
"aws-runtime",
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-json",
"aws-smithy-query",
"aws-smithy-runtime",
"aws-smithy-runtime-api",
"aws-smithy-types",
"aws-smithy-xml",
"aws-types",
"http 0.2.12",
"once_cell",
"regex-lite",
"tracing",
]
[[package]]
name = "aws-sigv4"
version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d3820e0c08d0737872ff3c7c1f21ebbb6693d832312d6152bf18ef50a5471c2"
dependencies = [
"aws-credential-types",
"aws-smithy-http",
"aws-smithy-runtime-api",
"aws-smithy-types",
"bytes",
"form_urlencoded",
"hex",
"hmac",
"http 0.2.12",
"http 1.2.0",
"once_cell",
"percent-encoding",
"sha2",
"time",
"tracing",
]
[[package]]
name = "aws-smithy-async"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427cb637d15d63d6f9aae26358e1c9a9c09d5aa490d64b09354c8217cfef0f28"
dependencies = [
"futures-util",
"pin-project-lite",
"tokio",
]
[[package]]
name = "aws-smithy-http"
version = "0.60.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8bc3e8fdc6b8d07d976e301c02fe553f72a39b7a9fea820e023268467d7ab6"
dependencies = [
"aws-smithy-runtime-api",
"aws-smithy-types",
"bytes",
"bytes-utils",
"futures-core",
"http 0.2.12",
"http-body 0.4.6",
"once_cell",
"percent-encoding",
"pin-project-lite",
"pin-utils",
"tracing",
]
[[package]]
name = "aws-smithy-json"
version = "0.61.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee4e69cc50921eb913c6b662f8d909131bb3e6ad6cb6090d3a39b66fc5c52095"
dependencies = [
"aws-smithy-types",
]
[[package]]
name = "aws-smithy-query"
version = "0.60.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2fbd61ceb3fe8a1cb7352e42689cec5335833cd9f94103a61e98f9bb61c64bb"
dependencies = [
"aws-smithy-types",
"urlencoding",
]
[[package]]
name = "aws-smithy-runtime"
version = "1.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a05dd41a70fc74051758ee75b5c4db2c0ca070ed9229c3df50e9475cda1cb985"
dependencies = [
"aws-smithy-async",
"aws-smithy-http",
"aws-smithy-runtime-api",
"aws-smithy-types",
"bytes",
"fastrand 2.3.0",
"h2",
"http 0.2.12",
"http-body 0.4.6",
"http-body 1.0.1",
"httparse",
"hyper 0.14.32",
"hyper-rustls 0.24.2",
"once_cell",
"pin-project-lite",
"pin-utils",
"rustls 0.21.12",
"tokio",
"tracing",
]
[[package]]
name = "aws-smithy-runtime-api"
version = "1.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92165296a47a812b267b4f41032ff8069ab7ff783696d217f0994a0d7ab585cd"
dependencies = [
"aws-smithy-async",
"aws-smithy-types",
"bytes",
"http 0.2.12",
"http 1.2.0",
"pin-project-lite",
"tokio",
"tracing",
"zeroize",
]
[[package]]
name = "aws-smithy-types"
version = "1.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38ddc9bd6c28aeb303477170ddd183760a956a03e083b3902a990238a7e3792d"
dependencies = [
"base64-simd",
"bytes",
"bytes-utils",
"futures-core",
"http 0.2.12",
"http 1.2.0",
"http-body 0.4.6",
"http-body 1.0.1",
"http-body-util",
"itoa",
"num-integer",
"pin-project-lite",
"pin-utils",
"ryu",
"serde",
"time",
"tokio",
"tokio-util",
]
[[package]]
name = "aws-smithy-xml"
version = "0.60.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab0b0166827aa700d3dc519f72f8b3a91c35d0b8d042dc5d643a91e6f80648fc"
dependencies = [
"xmlparser",
]
[[package]]
name = "aws-types"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5221b91b3e441e6675310829fd8984801b772cb1546ef6c0e54dec9f1ac13fef"
dependencies = [
"aws-credential-types",
"aws-smithy-async",
"aws-smithy-runtime-api",
"aws-smithy-types",
"rustc_version",
"tracing",
]
[[package]]
name = "backtrace"
version = "0.3.74"
@ -443,6 +787,16 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64-simd"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195"
dependencies = [
"outref",
"vsimd",
]
[[package]]
name = "base64ct"
version = "1.6.0"
@ -536,6 +890,16 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
[[package]]
name = "bytes-utils"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35"
dependencies = [
"bytes",
"either",
]
[[package]]
name = "cbc"
version = "0.1.2"
@ -1212,7 +1576,7 @@ dependencies = [
"http 1.2.0",
"http-body-util",
"hyper 1.5.2",
"hyper-rustls",
"hyper-rustls 0.27.4",
"hyper-util",
"mime",
"serde",
@ -1732,6 +2096,16 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "http-serde"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f056c8559e3757392c8d091e796416e4649d8e49e88b8d76df6c002f05027fd"
dependencies = [
"http 1.2.0",
"serde",
]
[[package]]
name = "httparse"
version = "1.9.5"
@ -1787,6 +2161,22 @@ dependencies = [
"want",
]
[[package]]
name = "hyper-rustls"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
dependencies = [
"futures-util",
"http 0.2.12",
"hyper 0.14.32",
"log",
"rustls 0.21.12",
"rustls-native-certs 0.6.3",
"tokio",
"tokio-rustls 0.24.1",
]
[[package]]
name = "hyper-rustls"
version = "0.27.4"
@ -1802,7 +2192,7 @@ dependencies = [
"rustls-native-certs 0.8.1",
"rustls-pki-types",
"tokio",
"tokio-rustls",
"tokio-rustls 0.26.1",
"tower-service",
"webpki-roots 0.26.7",
]
@ -2107,6 +2497,55 @@ dependencies = [
"serde",
]
[[package]]
name = "lambda_runtime"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed49669d6430292aead991e19bf13153135a884f916e68f32997c951af637ebe"
dependencies = [
"async-stream",
"base64 0.22.1",
"bytes",
"futures",
"http 1.2.0",
"http-body 1.0.1",
"http-body-util",
"http-serde",
"hyper 1.5.2",
"hyper-util",
"lambda_runtime_api_client",
"pin-project",
"serde",
"serde_json",
"serde_path_to_error",
"tokio",
"tokio-stream",
"tower",
"tower-layer",
"tracing",
]
[[package]]
name = "lambda_runtime_api_client"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c90a10f094475a34a04da2be11686c4dcfe214d93413162db9ffdff3d3af293a"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http 1.2.0",
"http-body 1.0.1",
"http-body-util",
"hyper 1.5.2",
"hyper-util",
"tokio",
"tower",
"tower-service",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "lapin"
version = "2.5.0"
@ -2248,6 +2687,15 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4"
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata 0.1.10",
]
[[package]]
name = "md-5"
version = "0.10.6"
@ -2524,6 +2972,12 @@ version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
[[package]]
name = "outref"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a"
[[package]]
name = "overload"
version = "0.1.1"
@ -3001,6 +3455,24 @@ dependencies = [
"warp",
]
[[package]]
name = "reacher_sqs"
version = "0.10.0"
dependencies = [
"anyhow",
"aws-config",
"aws-sdk-sqs",
"check-if-email-exists",
"dotenv",
"lambda_runtime",
"reacher_backend",
"serde",
"serde_json",
"tokio",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "reactor-trait"
version = "1.1.0"
@ -3029,8 +3501,17 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
"regex-automata 0.4.9",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax 0.6.29",
]
[[package]]
@ -3041,9 +3522,21 @@ checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
"regex-syntax 0.8.5",
]
[[package]]
name = "regex-lite"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a"
[[package]]
name = "regex-syntax"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "regex-syntax"
version = "0.8.5"
@ -3065,7 +3558,7 @@ dependencies = [
"http-body 1.0.1",
"http-body-util",
"hyper 1.5.2",
"hyper-rustls",
"hyper-rustls 0.27.4",
"hyper-util",
"ipnet",
"js-sys",
@ -3083,7 +3576,7 @@ dependencies = [
"serde_urlencoded",
"sync_wrapper",
"tokio",
"tokio-rustls",
"tokio-rustls 0.26.1",
"tower-service",
"url",
"wasm-bindgen",
@ -3178,6 +3671,15 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497"
[[package]]
name = "rustc_version"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
dependencies = [
"semver",
]
[[package]]
name = "rusticata-macros"
version = "4.1.0"
@ -3255,6 +3757,18 @@ dependencies = [
"rustls-webpki 0.102.8",
]
[[package]]
name = "rustls-native-certs"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
dependencies = [
"openssl-probe",
"rustls-pemfile 1.0.4",
"schannel",
"security-framework 2.11.1",
]
[[package]]
name = "rustls-native-certs"
version = "0.7.3"
@ -3422,6 +3936,12 @@ dependencies = [
"libc",
]
[[package]]
name = "semver"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba"
[[package]]
name = "sentry"
version = "0.32.3"
@ -3522,6 +4042,16 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_path_to_error"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af99884400da37c88f5e9146b7f1fd0fbcae8f6eec4e9da38b67d05486f814a6"
dependencies = [
"itoa",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.8"
@ -4184,6 +4714,16 @@ dependencies = [
"tokio-stream",
]
[[package]]
name = "tokio-rustls"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081"
dependencies = [
"rustls 0.21.12",
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.26.1"
@ -4264,6 +4804,27 @@ dependencies = [
"winnow",
]
[[package]]
name = "tower"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
"pin-project",
"pin-project-lite",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower-layer"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
[[package]]
name = "tower-service"
version = "0.3.3"
@ -4314,18 +4875,35 @@ dependencies = [
"tracing-core",
]
[[package]]
name = "tracing-serde"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1"
dependencies = [
"serde",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"serde",
"serde_json",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
"tracing-serde",
]
[[package]]
@ -4495,6 +5073,12 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "vsimd"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64"
[[package]]
name = "waker-fn"
version = "1.2.0"
@ -4978,6 +5562,12 @@ dependencies = [
"time",
]
[[package]]
name = "xmlparser"
version = "0.13.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"
[[package]]
name = "yaml-rust2"
version = "0.8.1"

View File

@ -1,2 +1,2 @@
[workspace]
members = ["backend", "cli", "core"]
members = ["backend", "cli", "core", "sqs"]

2
sqs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
terraform*
.terraform*

20
sqs/Cargo.toml Normal file
View File

@ -0,0 +1,20 @@
[package]
name = "reacher_sqs"
version = "0.10.0"
edition = "2018"
license = "AGPL-3.0"
publish = false
[dependencies]
anyhow = "1.0"
aws-sdk-sqs = "1.52.0"
aws-config = { version = "1.1.7", features = ["behavior-version-latest"] }
check-if-email-exists = { path = "../core", features = ["sentry"] }
dotenv = "0.15.0"
lambda_runtime = "0.13"
reacher_backend = { path = "../backend" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1.40", features = ["macros"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"

24
sqs/Dockerfile Normal file
View File

@ -0,0 +1,24 @@
FROM rust:1.82 as builder
# Install required dependencies
RUN apt-get update && apt-get install -y \
pkg-config libssl-dev musl-tools
# Set the working directory
WORKDIR /usr/src/app
# Copy the Rust project files
COPY . .
# Compile the application for the Lambda runtime (x86_64-unknown-linux-musl)
RUN rustup target add x86_64-unknown-linux-musl && \
cargo build --bin reacher_sqs --release --target x86_64-unknown-linux-musl
# Create the runtime container
FROM public.ecr.aws/lambda/provided:al2
# Copy the compiled binary from the builder stage
COPY --from=builder /usr/src/app/target/x86_64-unknown-linux-musl/release/reacher_sqs /var/task/bootstrap
# Set the Lambda handler (entry point)
CMD ["bootstrap"]

1
sqs/backend_config.toml Symbolic link
View File

@ -0,0 +1 @@
../backend/backend_config.toml

BIN
sqs/lambda-code.zip Normal file

Binary file not shown.

143
sqs/main.tf Normal file
View File

@ -0,0 +1,143 @@
provider "aws" {
region = var.aws_region
}
# Define variables for reuse
variable "aws_region" {
default = "eu-west-3"
}
variable "queue_name" {
default = "check-email-queue"
}
variable "lambda_name" {
default = "lambda-task-check-email"
}
variable "repository_name" {
default = "reacherhq/sqs"
}
# Create an SQS Queue
resource "aws_sqs_queue" "check_email_queue" {
name = var.queue_name
tags = {
Environment = "Production"
ManagedBy = "Terraform"
}
}
# IAM Role for Lambda execution
resource "aws_iam_role" "lambda_execution_role" {
name = "lambda_execution_role"
assume_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Action = "sts:AssumeRole",
Principal = {
Service = "lambda.amazonaws.com"
},
Effect = "Allow"
}
]
})
tags = {
Environment = "Production"
ManagedBy = "Terraform"
}
}
# IAM Policy for Lambda
resource "aws_iam_policy" "lambda_policy" {
name = "lambda_sqs_cloudwatch_policy"
description = "IAM policy for Lambda SQS and CloudWatch"
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes"
],
Resource = aws_sqs_queue.check_email_queue.arn
},
{
Effect = "Allow",
Action = [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
Resource = "arn:aws:logs:*:*:*"
}
]
})
tags = {
Environment = "Production"
ManagedBy = "Terraform"
}
}
# Attach IAM policy to Lambda role
resource "aws_iam_role_policy_attachment" "attach_lambda_policy" {
role = aws_iam_role.lambda_execution_role.name
policy_arn = aws_iam_policy.lambda_policy.arn
}
# Lambda Function
resource "aws_lambda_function" "lambda_task_check_email" {
function_name = var.lambda_name
role = aws_iam_role.lambda_execution_role.arn
handler = "function.handler"
runtime = "provided.al2"
# ECR repository image
package_type = "Image"
image_uri = "${aws_ecr_repository.lambda_ecr_repo.repository_url}:latest"
environment {
variables = {
QUEUE_URL = aws_sqs_queue.check_email_queue.url
}
}
timeout = 120 # Timeout set to 2 minutes, which corresponds to the max time one email verification should run, plus buffer.
tags = {
Environment = "Production"
ManagedBy = "Terraform"
}
}
# Connect SQS Queue to Lambda as event source
resource "aws_lambda_event_source_mapping" "sqs_trigger" {
event_source_arn = aws_sqs_queue.check_email_queue.arn
function_name = aws_lambda_function.lambda_task_check_email.arn
batch_size = 1
}
# ECR Repository for Lambda image
resource "aws_ecr_repository" "lambda_ecr_repo" {
name = var.repository_name
tags = {
Environment = "Production"
ManagedBy = "Terraform"
}
}
# Output SQS Queue URL
output "queue_url" {
value = aws_sqs_queue.check_email_queue.url
description = "The URL of the SQS queue."
}

77
sqs/src/main.rs Normal file
View File

@ -0,0 +1,77 @@
use std::sync::Arc;
use aws_sdk_sqs::types::Message;
use aws_sdk_sqs::Client;
use check_if_email_exists::check_email;
use lambda_runtime::Error;
use reacher_backend::config::load_config;
use reacher_backend::http::CheckEmailRequest;
use serde::Deserialize;
use tracing::info;
const QUEUE_URL: &str = "https://sqs.eu-west-3.amazonaws.com/430118836964/check-email-queue";
#[derive(Debug, Deserialize)]
struct CheckEmailTask {
input: CheckEmailRequest,
}
async fn function_handler(event: LambdaEvent<Value>) -> Result<Value, Error> {
let (event, _context) = event.into_parts();
Ok(json!({ "message": "Hello, world!", "input": event }))
}
#[tokio::main]
async fn main() -> Result<(), Error> {
tracing_subscriber::fmt::init();
dotenv::dotenv().ok();
run(service_fn(function_handler)).await
let shared_config = aws_config::load_from_env().await;
let client = Client::new(&shared_config);
let backend_config = load_config().await?;
if let Some(message) = fetch_message(&client).await? {
if let Some(body) = &message.body {
let task: CheckEmailTask = serde_json::from_str(body)?;
info!(email = ?task.input.to_email, "Processing task");
let output =
check_email(&task.input.to_check_email_input(Arc::new(backend_config))).await;
info!(email = ?output.input, is_reachable = ?output.is_reachable, "Task completed");
// Delete the message after successful processing
delete_message(&client, &message).await?;
}
} else {
info!("No messages to process");
}
Ok(())
}
async fn fetch_message(client: &Client) -> Result<Option<Message>, aws_sdk_sqs::Error> {
let response = client
.receive_message()
.queue_url(QUEUE_URL)
.max_number_of_messages(1) // Fetch a single message
.visibility_timeout(120) // Visibility timeout in seconds
.send()
.await?;
// Return the first message or None
Ok(response.messages.and_then(|mut msgs| msgs.pop()))
}
async fn delete_message(client: &Client, message: &Message) -> Result<(), aws_sdk_sqs::Error> {
if let Some(receipt_handle) = &message.receipt_handle {
client
.delete_message()
.queue_url(QUEUE_URL)
.receipt_handle(receipt_handle)
.send()
.await?;
}
Ok(())
}