@sst-community/sst 4.21.1 → 5.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (832) hide show
  1. package/README.md +86 -52
  2. package/package.json +35 -11
  3. package/platform/js/chunks/chunk-HIZZCEDS.js +328 -0
  4. package/platform/js/chunks/chunk-HIZZCEDS.js.map +6 -0
  5. package/platform/js/chunks/chunk-KOKHGKJ2.js +639 -0
  6. package/platform/js/chunks/chunk-KOKHGKJ2.js.map +6 -0
  7. package/platform/js/chunks/chunk-MR4XM5XA.js +473 -0
  8. package/platform/js/chunks/chunk-MR4XM5XA.js.map +6 -0
  9. package/platform/js/chunks/chunk-ONNI4XNK.js +367 -0
  10. package/platform/js/chunks/chunk-ONNI4XNK.js.map +6 -0
  11. package/platform/js/chunks/chunk-VIFHC73J.js +108 -0
  12. package/platform/js/chunks/chunk-VIFHC73J.js.map +6 -0
  13. package/platform/js/chunks/chunk-WJ6BVA46.js +10 -0
  14. package/platform/js/chunks/chunk-WJ6BVA46.js.map +6 -0
  15. package/platform/js/chunks/component-32FCLIRK.js +26 -0
  16. package/platform/js/chunks/component-32FCLIRK.js.map +6 -0
  17. package/platform/js/chunks/config-CRGKEDQW.js +10 -0
  18. package/platform/js/chunks/config-CRGKEDQW.js.map +6 -0
  19. package/platform/js/chunks/link-OJ3RNGQ3.js +9 -0
  20. package/platform/js/chunks/link-OJ3RNGQ3.js.map +6 -0
  21. package/platform/js/components/aws/index.js +35399 -0
  22. package/platform/js/components/aws/index.js.map +6 -0
  23. package/platform/js/components/cloudflare/index.js +3246 -0
  24. package/platform/js/components/cloudflare/index.js.map +6 -0
  25. package/platform/js/components/core.js +114 -0
  26. package/platform/js/components/core.js.map +6 -0
  27. package/platform/js/components/vercel/index.js +120 -0
  28. package/platform/js/components/vercel/index.js.map +6 -0
  29. package/platform/js/testing/index.js +569 -0
  30. package/platform/js/testing/index.js.map +6 -0
  31. package/platform/package.json +25 -0
  32. package/platform/src/ast/add.mjs +190 -0
  33. package/platform/src/auto/run.ts +109 -0
  34. package/platform/src/components/README.md +652 -0
  35. package/platform/src/components/args.ts +133 -0
  36. package/platform/src/components/aws/alb.ts +577 -0
  37. package/platform/src/components/aws/analog.ts +462 -0
  38. package/platform/src/components/aws/apigateway-websocket-route.ts +206 -0
  39. package/platform/src/components/aws/apigateway-websocket.ts +894 -0
  40. package/platform/src/components/aws/apigatewayv1-api-key.ts +90 -0
  41. package/platform/src/components/aws/apigatewayv1-authorizer.ts +178 -0
  42. package/platform/src/components/aws/apigatewayv1-base-route.ts +78 -0
  43. package/platform/src/components/aws/apigatewayv1-integration-route.ts +92 -0
  44. package/platform/src/components/aws/apigatewayv1-lambda-route.ts +152 -0
  45. package/platform/src/components/aws/apigatewayv1-usage-plan.ts +109 -0
  46. package/platform/src/components/aws/apigatewayv1.ts +1691 -0
  47. package/platform/src/components/aws/apigatewayv2-authorizer.ts +199 -0
  48. package/platform/src/components/aws/apigatewayv2-base-route.ts +69 -0
  49. package/platform/src/components/aws/apigatewayv2-lambda-route.ts +141 -0
  50. package/platform/src/components/aws/apigatewayv2-private-route.ts +101 -0
  51. package/platform/src/components/aws/apigatewayv2-url-route.ts +90 -0
  52. package/platform/src/components/aws/apigatewayv2.ts +1439 -0
  53. package/platform/src/components/aws/app-sync-data-source.ts +264 -0
  54. package/platform/src/components/aws/app-sync-function.ts +79 -0
  55. package/platform/src/components/aws/app-sync-resolver.ts +110 -0
  56. package/platform/src/components/aws/app-sync.ts +849 -0
  57. package/platform/src/components/aws/astro.ts +580 -0
  58. package/platform/src/components/aws/aurora.ts +1356 -0
  59. package/platform/src/components/aws/auth-v1.ts +69 -0
  60. package/platform/src/components/aws/auth.ts +417 -0
  61. package/platform/src/components/aws/bucket-lambda-subscriber.ts +162 -0
  62. package/platform/src/components/aws/bucket-notification.ts +254 -0
  63. package/platform/src/components/aws/bucket-queue-subscriber.ts +122 -0
  64. package/platform/src/components/aws/bucket-topic-subscriber.ts +144 -0
  65. package/platform/src/components/aws/bucket.ts +2046 -0
  66. package/platform/src/components/aws/bus-base-subscriber.ts +52 -0
  67. package/platform/src/components/aws/bus-lambda-subscriber.ts +125 -0
  68. package/platform/src/components/aws/bus-queue-subscriber.ts +88 -0
  69. package/platform/src/components/aws/bus.ts +630 -0
  70. package/platform/src/components/aws/cdn.ts +561 -0
  71. package/platform/src/components/aws/cluster-v1.ts +932 -0
  72. package/platform/src/components/aws/cluster.ts +584 -0
  73. package/platform/src/components/aws/cognito-identity-pool.ts +433 -0
  74. package/platform/src/components/aws/cognito-identity-provider.ts +96 -0
  75. package/platform/src/components/aws/cognito-user-pool-client.ts +114 -0
  76. package/platform/src/components/aws/cognito-user-pool.ts +1089 -0
  77. package/platform/src/components/aws/cron-v2.ts +555 -0
  78. package/platform/src/components/aws/cron.ts +435 -0
  79. package/platform/src/components/aws/dns-validated-certificate.ts +108 -0
  80. package/platform/src/components/aws/dns.ts +221 -0
  81. package/platform/src/components/aws/dsql.ts +741 -0
  82. package/platform/src/components/aws/dynamo-lambda-subscriber.ts +124 -0
  83. package/platform/src/components/aws/dynamo.ts +929 -0
  84. package/platform/src/components/aws/efs.ts +410 -0
  85. package/platform/src/components/aws/email.ts +673 -0
  86. package/platform/src/components/aws/fargate.ts +1279 -0
  87. package/platform/src/components/aws/function.ts +3280 -0
  88. package/platform/src/components/aws/helpers/apigateway-account.ts +78 -0
  89. package/platform/src/components/aws/helpers/apigatewayv2-domain.ts +144 -0
  90. package/platform/src/components/aws/helpers/arn.ts +182 -0
  91. package/platform/src/components/aws/helpers/bootstrap.ts +16 -0
  92. package/platform/src/components/aws/helpers/client.ts +76 -0
  93. package/platform/src/components/aws/helpers/container-builder.ts +33 -0
  94. package/platform/src/components/aws/helpers/custom-domain.ts +128 -0
  95. package/platform/src/components/aws/helpers/event-source.ts +41 -0
  96. package/platform/src/components/aws/helpers/fargate.ts +727 -0
  97. package/platform/src/components/aws/helpers/function-builder.ts +133 -0
  98. package/platform/src/components/aws/helpers/function-code.ts +224 -0
  99. package/platform/src/components/aws/helpers/function-part.ts +212 -0
  100. package/platform/src/components/aws/helpers/function-permission.ts +29 -0
  101. package/platform/src/components/aws/helpers/load-balancer-args.ts +88 -0
  102. package/platform/src/components/aws/helpers/load-balancer.ts +17 -0
  103. package/platform/src/components/aws/helpers/provider.ts +36 -0
  104. package/platform/src/components/aws/helpers/queue-policy.ts +33 -0
  105. package/platform/src/components/aws/helpers/rds.ts +212 -0
  106. package/platform/src/components/aws/helpers/site-builder.ts +41 -0
  107. package/platform/src/components/aws/helpers/subscriber.ts +23 -0
  108. package/platform/src/components/aws/helpers/vpc.ts +27 -0
  109. package/platform/src/components/aws/https-redirect.ts +216 -0
  110. package/platform/src/components/aws/iam-edit.ts +50 -0
  111. package/platform/src/components/aws/index.ts +61 -0
  112. package/platform/src/components/aws/kinesis-stream-lambda-subscriber.ts +122 -0
  113. package/platform/src/components/aws/kinesis-stream.ts +416 -0
  114. package/platform/src/components/aws/linkable.ts +32 -0
  115. package/platform/src/components/aws/logging.ts +25 -0
  116. package/platform/src/components/aws/microvm.ts +988 -0
  117. package/platform/src/components/aws/mysql.ts +1050 -0
  118. package/platform/src/components/aws/nextjs.ts +1052 -0
  119. package/platform/src/components/aws/nuxt.ts +527 -0
  120. package/platform/src/components/aws/open-search.ts +603 -0
  121. package/platform/src/components/aws/opencontrol.ts +235 -0
  122. package/platform/src/components/aws/permission.ts +80 -0
  123. package/platform/src/components/aws/postgres-v1.ts +537 -0
  124. package/platform/src/components/aws/postgres.ts +1074 -0
  125. package/platform/src/components/aws/providers/bucket-files.ts +32 -0
  126. package/platform/src/components/aws/providers/distribution-deployment-waiter.ts +27 -0
  127. package/platform/src/components/aws/providers/distribution-invalidation.ts +24 -0
  128. package/platform/src/components/aws/providers/function-environment-update.ts +46 -0
  129. package/platform/src/components/aws/providers/hosted-zone-lookup.ts +25 -0
  130. package/platform/src/components/aws/providers/kv-keys.ts +15 -0
  131. package/platform/src/components/aws/providers/kv-routes-update.ts +24 -0
  132. package/platform/src/components/aws/providers/microvm-image-prune.ts +48 -0
  133. package/platform/src/components/aws/providers/origin-access-control.ts +21 -0
  134. package/platform/src/components/aws/providers/rds-role-lookup.ts +21 -0
  135. package/platform/src/components/aws/providers/vector-table.ts +25 -0
  136. package/platform/src/components/aws/queue-lambda-subscriber.ts +135 -0
  137. package/platform/src/components/aws/queue.ts +712 -0
  138. package/platform/src/components/aws/react.ts +510 -0
  139. package/platform/src/components/aws/realtime-lambda-subscriber.ts +129 -0
  140. package/platform/src/components/aws/realtime.ts +345 -0
  141. package/platform/src/components/aws/redis-v1.ts +595 -0
  142. package/platform/src/components/aws/redis.ts +1078 -0
  143. package/platform/src/components/aws/remix.ts +576 -0
  144. package/platform/src/components/aws/router-base-route.ts +83 -0
  145. package/platform/src/components/aws/router-bucket-route.ts +63 -0
  146. package/platform/src/components/aws/router-url-route.ts +75 -0
  147. package/platform/src/components/aws/router.ts +3294 -0
  148. package/platform/src/components/aws/service-v1.ts +876 -0
  149. package/platform/src/components/aws/service.ts +2994 -0
  150. package/platform/src/components/aws/sns-topic-lambda-subscriber.ts +127 -0
  151. package/platform/src/components/aws/sns-topic-queue-subscriber.ts +105 -0
  152. package/platform/src/components/aws/sns-topic.ts +700 -0
  153. package/platform/src/components/aws/solid-start.ts +467 -0
  154. package/platform/src/components/aws/ssr-site.ts +2204 -0
  155. package/platform/src/components/aws/static-site.ts +1389 -0
  156. package/platform/src/components/aws/step-functions/choice.ts +123 -0
  157. package/platform/src/components/aws/step-functions/fail.ts +69 -0
  158. package/platform/src/components/aws/step-functions/map.ts +264 -0
  159. package/platform/src/components/aws/step-functions/parallel.ts +170 -0
  160. package/platform/src/components/aws/step-functions/pass.ts +48 -0
  161. package/platform/src/components/aws/step-functions/state.ts +376 -0
  162. package/platform/src/components/aws/step-functions/succeed.ts +31 -0
  163. package/platform/src/components/aws/step-functions/task.ts +538 -0
  164. package/platform/src/components/aws/step-functions/wait.ts +105 -0
  165. package/platform/src/components/aws/step-functions.ts +804 -0
  166. package/platform/src/components/aws/svelte-kit.ts +563 -0
  167. package/platform/src/components/aws/takeover/alb.ts +9 -0
  168. package/platform/src/components/aws/takeover/apigatewayv2.ts +43 -0
  169. package/platform/src/components/aws/takeover/app-sync.ts +45 -0
  170. package/platform/src/components/aws/takeover/aurora.ts +19 -0
  171. package/platform/src/components/aws/takeover/bucket.ts +94 -0
  172. package/platform/src/components/aws/takeover/bus.ts +43 -0
  173. package/platform/src/components/aws/takeover/cognito-user-pool.ts +21 -0
  174. package/platform/src/components/aws/takeover/cron-v2.ts +9 -0
  175. package/platform/src/components/aws/takeover/dsql.ts +12 -0
  176. package/platform/src/components/aws/takeover/dynamo.ts +31 -0
  177. package/platform/src/components/aws/takeover/efs.ts +9 -0
  178. package/platform/src/components/aws/takeover/function.ts +21 -0
  179. package/platform/src/components/aws/takeover/helpers.ts +26 -0
  180. package/platform/src/components/aws/takeover/index.ts +27 -0
  181. package/platform/src/components/aws/takeover/mysql.ts +17 -0
  182. package/platform/src/components/aws/takeover/postgres.ts +17 -0
  183. package/platform/src/components/aws/takeover/queue.ts +21 -0
  184. package/platform/src/components/aws/takeover/redis.ts +10 -0
  185. package/platform/src/components/aws/takeover/service.ts +22 -0
  186. package/platform/src/components/aws/takeover/sns-topic.ts +27 -0
  187. package/platform/src/components/aws/takeover/task.ts +13 -0
  188. package/platform/src/components/aws/tan-stack-start.ts +479 -0
  189. package/platform/src/components/aws/task.ts +571 -0
  190. package/platform/src/components/aws/v5/alb.ts +310 -0
  191. package/platform/src/components/aws/v5/apigatewayv2.ts +845 -0
  192. package/platform/src/components/aws/v5/app-sync.ts +673 -0
  193. package/platform/src/components/aws/v5/aurora.ts +855 -0
  194. package/platform/src/components/aws/v5/bucket.ts +1001 -0
  195. package/platform/src/components/aws/v5/bus.ts +321 -0
  196. package/platform/src/components/aws/v5/cluster.ts +230 -0
  197. package/platform/src/components/aws/v5/cognito-user-pool-client.ts +100 -0
  198. package/platform/src/components/aws/v5/cognito-user-pool.ts +693 -0
  199. package/platform/src/components/aws/v5/cron-v2.ts +316 -0
  200. package/platform/src/components/aws/v5/dsql.ts +665 -0
  201. package/platform/src/components/aws/v5/dynamo.ts +477 -0
  202. package/platform/src/components/aws/v5/efs.ts +311 -0
  203. package/platform/src/components/aws/v5/function.ts +1546 -0
  204. package/platform/src/components/aws/v5/index.ts +26 -0
  205. package/platform/src/components/aws/v5/mysql.ts +604 -0
  206. package/platform/src/components/aws/v5/postgres.ts +612 -0
  207. package/platform/src/components/aws/v5/queue.ts +271 -0
  208. package/platform/src/components/aws/v5/redis.ts +550 -0
  209. package/platform/src/components/aws/v5/service.ts +2209 -0
  210. package/platform/src/components/aws/v5/sns-topic.ts +284 -0
  211. package/platform/src/components/aws/v5/task.ts +549 -0
  212. package/platform/src/components/aws/vector.ts +316 -0
  213. package/platform/src/components/aws/vpc-v1.ts +580 -0
  214. package/platform/src/components/aws/vpc.ts +1641 -0
  215. package/platform/src/components/aws/workflow.ts +421 -0
  216. package/platform/src/components/base/base-site.ts +101 -0
  217. package/platform/src/components/base/base-ssr-site.ts +120 -0
  218. package/platform/src/components/base/base-static-site.ts +314 -0
  219. package/platform/src/components/cloudflare/account-id.ts +1 -0
  220. package/platform/src/components/cloudflare/ai.ts +77 -0
  221. package/platform/src/components/cloudflare/astro.ts +355 -0
  222. package/platform/src/components/cloudflare/auth.ts +69 -0
  223. package/platform/src/components/cloudflare/binding.ts +132 -0
  224. package/platform/src/components/cloudflare/bucket.ts +142 -0
  225. package/platform/src/components/cloudflare/cron.ts +207 -0
  226. package/platform/src/components/cloudflare/d1.ts +230 -0
  227. package/platform/src/components/cloudflare/dns.ts +253 -0
  228. package/platform/src/components/cloudflare/durable-object.ts +144 -0
  229. package/platform/src/components/cloudflare/experimental/index.ts +3 -0
  230. package/platform/src/components/cloudflare/experimental/solid-start.ts +288 -0
  231. package/platform/src/components/cloudflare/experimental/static-site.ts +4 -0
  232. package/platform/src/components/cloudflare/helpers/compatibility.ts +44 -0
  233. package/platform/src/components/cloudflare/helpers/fetch.ts +81 -0
  234. package/platform/src/components/cloudflare/helpers/validation.ts +74 -0
  235. package/platform/src/components/cloudflare/helpers/worker-builder.ts +57 -0
  236. package/platform/src/components/cloudflare/helpers/wrangler.ts +222 -0
  237. package/platform/src/components/cloudflare/hyperdrive.ts +402 -0
  238. package/platform/src/components/cloudflare/index.ts +25 -0
  239. package/platform/src/components/cloudflare/kv.ts +218 -0
  240. package/platform/src/components/cloudflare/providers/dns-record.ts +43 -0
  241. package/platform/src/components/cloudflare/providers/kv-data.ts +107 -0
  242. package/platform/src/components/cloudflare/providers/worker-assets.ts +41 -0
  243. package/platform/src/components/cloudflare/providers/worker-placement.ts +93 -0
  244. package/platform/src/components/cloudflare/providers/worker-script.ts +47 -0
  245. package/platform/src/components/cloudflare/providers/worker-url.ts +109 -0
  246. package/platform/src/components/cloudflare/providers/zone-lookup.ts +85 -0
  247. package/platform/src/components/cloudflare/queue-worker-subscriber.ts +192 -0
  248. package/platform/src/components/cloudflare/queue.ts +310 -0
  249. package/platform/src/components/cloudflare/rate-limit.ts +178 -0
  250. package/platform/src/components/cloudflare/react-router.ts +322 -0
  251. package/platform/src/components/cloudflare/ssr-site.ts +293 -0
  252. package/platform/src/components/cloudflare/static-site-v2.ts +428 -0
  253. package/platform/src/components/cloudflare/static-site.ts +470 -0
  254. package/platform/src/components/cloudflare/tan-stack-start.ts +408 -0
  255. package/platform/src/components/cloudflare/worker.ts +1080 -0
  256. package/platform/src/components/cloudflare/workflow.ts +319 -0
  257. package/platform/src/components/component.ts +242 -0
  258. package/platform/src/components/core.ts +43 -0
  259. package/platform/src/components/cpu.ts +10 -0
  260. package/platform/src/components/dns.ts +82 -0
  261. package/platform/src/components/duration.ts +67 -0
  262. package/platform/src/components/error.ts +5 -0
  263. package/platform/src/components/esbuild.ts +15 -0
  264. package/platform/src/components/experimental/dev-command.ts +127 -0
  265. package/platform/src/components/experimental/index.ts +1 -0
  266. package/platform/src/components/groups.ts +9 -0
  267. package/platform/src/components/index.ts +9 -0
  268. package/platform/src/components/input.ts +2 -0
  269. package/platform/src/components/link.ts +201 -0
  270. package/platform/src/components/linkable.ts +360 -0
  271. package/platform/src/components/naming-rules.ts +299 -0
  272. package/platform/src/components/naming.ts +189 -0
  273. package/platform/src/components/parts-component.ts +662 -0
  274. package/platform/src/components/parts.ts +299 -0
  275. package/platform/src/components/path.ts +5 -0
  276. package/platform/src/components/rpc/rpc.ts +110 -0
  277. package/platform/src/components/secret.ts +159 -0
  278. package/platform/src/components/size.ts +28 -0
  279. package/platform/src/components/takeover.ts +131 -0
  280. package/platform/src/components/transform.ts +107 -0
  281. package/platform/src/components/vercel/account-id.ts +1 -0
  282. package/platform/src/components/vercel/dns.ts +171 -0
  283. package/platform/src/components/vercel/index.ts +2 -0
  284. package/platform/src/components/vercel/providers/dns-record.ts +34 -0
  285. package/platform/src/config.ts +1463 -0
  286. package/platform/src/global-aliases.d.ts +37 -0
  287. package/platform/src/global.d.ts +374 -0
  288. package/platform/src/internal.d.ts +18 -0
  289. package/platform/src/runtime/worker/unenv.d.ts +14 -0
  290. package/platform/src/runtime/worker/unenv.mjs +26 -0
  291. package/platform/src/shim/run.js +25 -0
  292. package/platform/src/testing/global.ts +83 -0
  293. package/platform/src/testing/index.ts +103 -0
  294. package/platform/src/testing/mock.ts +646 -0
  295. package/platform/src/testing/vitest.ts +36 -0
  296. package/platform/src/util/compare-semver.ts +23 -0
  297. package/platform/src/util/fs.ts +49 -0
  298. package/platform/src/util/lazy.ts +12 -0
  299. package/platform/src/util/minify.ts +10 -0
  300. package/platform/src/util/package.ts +29 -0
  301. package/platform/src/util/semaphore.ts +29 -0
  302. package/platform/src/util/warn.ts +7 -0
  303. package/platform/types/auto/run.d.ts +9 -0
  304. package/platform/types/auto/run.d.ts.map +1 -0
  305. package/platform/types/components/args.d.ts +77 -0
  306. package/platform/types/components/args.d.ts.map +1 -0
  307. package/platform/types/components/aws/alb.d.ts +283 -0
  308. package/platform/types/components/aws/alb.d.ts.map +1 -0
  309. package/platform/types/components/aws/analog.d.ts +408 -0
  310. package/platform/types/components/aws/analog.d.ts.map +1 -0
  311. package/platform/types/components/aws/apigateway-websocket-route.d.ts +74 -0
  312. package/platform/types/components/aws/apigateway-websocket-route.d.ts.map +1 -0
  313. package/platform/types/components/aws/apigateway-websocket.d.ts +560 -0
  314. package/platform/types/components/aws/apigateway-websocket.d.ts.map +1 -0
  315. package/platform/types/components/aws/apigatewayv1-api-key.d.ts +48 -0
  316. package/platform/types/components/aws/apigatewayv1-api-key.d.ts.map +1 -0
  317. package/platform/types/components/aws/apigatewayv1-authorizer.d.ts +55 -0
  318. package/platform/types/components/aws/apigatewayv1-authorizer.d.ts.map +1 -0
  319. package/platform/types/components/aws/apigatewayv1-base-route.d.ts +36 -0
  320. package/platform/types/components/aws/apigatewayv1-base-route.d.ts.map +1 -0
  321. package/platform/types/components/aws/apigatewayv1-integration-route.d.ts +39 -0
  322. package/platform/types/components/aws/apigatewayv1-integration-route.d.ts.map +1 -0
  323. package/platform/types/components/aws/apigatewayv1-lambda-route.d.ts +53 -0
  324. package/platform/types/components/aws/apigatewayv1-lambda-route.d.ts.map +1 -0
  325. package/platform/types/components/aws/apigatewayv1-usage-plan.d.ts +53 -0
  326. package/platform/types/components/aws/apigatewayv1-usage-plan.d.ts.map +1 -0
  327. package/platform/types/components/aws/apigatewayv1.d.ts +1028 -0
  328. package/platform/types/components/aws/apigatewayv1.d.ts.map +1 -0
  329. package/platform/types/components/aws/apigatewayv2-authorizer.d.ts +54 -0
  330. package/platform/types/components/aws/apigatewayv2-authorizer.d.ts.map +1 -0
  331. package/platform/types/components/aws/apigatewayv2-base-route.d.ts +28 -0
  332. package/platform/types/components/aws/apigatewayv2-base-route.d.ts.map +1 -0
  333. package/platform/types/components/aws/apigatewayv2-lambda-route.d.ts +59 -0
  334. package/platform/types/components/aws/apigatewayv2-lambda-route.d.ts.map +1 -0
  335. package/platform/types/components/aws/apigatewayv2-private-route.d.ts +54 -0
  336. package/platform/types/components/aws/apigatewayv2-private-route.d.ts.map +1 -0
  337. package/platform/types/components/aws/apigatewayv2-url-route.d.ts +44 -0
  338. package/platform/types/components/aws/apigatewayv2-url-route.d.ts.map +1 -0
  339. package/platform/types/components/aws/apigatewayv2.d.ts +955 -0
  340. package/platform/types/components/aws/apigatewayv2.d.ts.map +1 -0
  341. package/platform/types/components/aws/app-sync-data-source.d.ts +52 -0
  342. package/platform/types/components/aws/app-sync-data-source.d.ts.map +1 -0
  343. package/platform/types/components/aws/app-sync-function.d.ts +33 -0
  344. package/platform/types/components/aws/app-sync-function.d.ts.map +1 -0
  345. package/platform/types/components/aws/app-sync-resolver.d.ts +41 -0
  346. package/platform/types/components/aws/app-sync-resolver.d.ts.map +1 -0
  347. package/platform/types/components/aws/app-sync.d.ts +638 -0
  348. package/platform/types/components/aws/app-sync.d.ts.map +1 -0
  349. package/platform/types/components/aws/astro.d.ts +409 -0
  350. package/platform/types/components/aws/astro.d.ts.map +1 -0
  351. package/platform/types/components/aws/aurora.d.ts +720 -0
  352. package/platform/types/components/aws/aurora.d.ts.map +1 -0
  353. package/platform/types/components/aws/auth-v1.d.ts +26 -0
  354. package/platform/types/components/aws/auth-v1.d.ts.map +1 -0
  355. package/platform/types/components/aws/auth.d.ts +295 -0
  356. package/platform/types/components/aws/auth.d.ts.map +1 -0
  357. package/platform/types/components/aws/bucket-lambda-subscriber.d.ts +61 -0
  358. package/platform/types/components/aws/bucket-lambda-subscriber.d.ts.map +1 -0
  359. package/platform/types/components/aws/bucket-notification.d.ts +47 -0
  360. package/platform/types/components/aws/bucket-notification.d.ts.map +1 -0
  361. package/platform/types/components/aws/bucket-queue-subscriber.d.ts +55 -0
  362. package/platform/types/components/aws/bucket-queue-subscriber.d.ts.map +1 -0
  363. package/platform/types/components/aws/bucket-topic-subscriber.d.ts +55 -0
  364. package/platform/types/components/aws/bucket-topic-subscriber.d.ts.map +1 -0
  365. package/platform/types/components/aws/bucket.d.ts +1356 -0
  366. package/platform/types/components/aws/bucket.d.ts.map +1 -0
  367. package/platform/types/components/aws/bus-base-subscriber.d.ts +20 -0
  368. package/platform/types/components/aws/bus-base-subscriber.d.ts.map +1 -0
  369. package/platform/types/components/aws/bus-lambda-subscriber.d.ts +50 -0
  370. package/platform/types/components/aws/bus-lambda-subscriber.d.ts.map +1 -0
  371. package/platform/types/components/aws/bus-queue-subscriber.d.ts +44 -0
  372. package/platform/types/components/aws/bus-queue-subscriber.d.ts.map +1 -0
  373. package/platform/types/components/aws/bus.d.ts +447 -0
  374. package/platform/types/components/aws/bus.d.ts.map +1 -0
  375. package/platform/types/components/aws/cdn.d.ts +310 -0
  376. package/platform/types/components/aws/cdn.d.ts.map +1 -0
  377. package/platform/types/components/aws/cluster-v1.d.ts +885 -0
  378. package/platform/types/components/aws/cluster-v1.d.ts.map +1 -0
  379. package/platform/types/components/aws/cluster.d.ts +364 -0
  380. package/platform/types/components/aws/cluster.d.ts.map +1 -0
  381. package/platform/types/components/aws/cognito-identity-pool.d.ts +199 -0
  382. package/platform/types/components/aws/cognito-identity-pool.d.ts.map +1 -0
  383. package/platform/types/components/aws/cognito-identity-provider.d.ts +38 -0
  384. package/platform/types/components/aws/cognito-identity-provider.d.ts.map +1 -0
  385. package/platform/types/components/aws/cognito-user-pool-client.d.ts +50 -0
  386. package/platform/types/components/aws/cognito-user-pool-client.d.ts.map +1 -0
  387. package/platform/types/components/aws/cognito-user-pool.d.ts +703 -0
  388. package/platform/types/components/aws/cognito-user-pool.d.ts.map +1 -0
  389. package/platform/types/components/aws/cron-v2.d.ts +325 -0
  390. package/platform/types/components/aws/cron-v2.d.ts.map +1 -0
  391. package/platform/types/components/aws/cron.d.ts +259 -0
  392. package/platform/types/components/aws/cron.d.ts.map +1 -0
  393. package/platform/types/components/aws/dns-validated-certificate.d.ts +27 -0
  394. package/platform/types/components/aws/dns-validated-certificate.d.ts.map +1 -0
  395. package/platform/types/components/aws/dns.d.ts +94 -0
  396. package/platform/types/components/aws/dns.d.ts.map +1 -0
  397. package/platform/types/components/aws/dsql.d.ts +369 -0
  398. package/platform/types/components/aws/dsql.d.ts.map +1 -0
  399. package/platform/types/components/aws/dynamo-lambda-subscriber.d.ts +55 -0
  400. package/platform/types/components/aws/dynamo-lambda-subscriber.d.ts.map +1 -0
  401. package/platform/types/components/aws/dynamo.d.ts +628 -0
  402. package/platform/types/components/aws/dynamo.d.ts.map +1 -0
  403. package/platform/types/components/aws/efs.d.ts +217 -0
  404. package/platform/types/components/aws/efs.d.ts.map +1 -0
  405. package/platform/types/components/aws/email.d.ts +370 -0
  406. package/platform/types/components/aws/email.d.ts.map +1 -0
  407. package/platform/types/components/aws/fargate.d.ts +894 -0
  408. package/platform/types/components/aws/fargate.d.ts.map +1 -0
  409. package/platform/types/components/aws/function.d.ts +1780 -0
  410. package/platform/types/components/aws/function.d.ts.map +1 -0
  411. package/platform/types/components/aws/helpers/apigateway-account.d.ts +3 -0
  412. package/platform/types/components/aws/helpers/apigateway-account.d.ts.map +1 -0
  413. package/platform/types/components/aws/helpers/apigatewayv2-domain.d.ts +144 -0
  414. package/platform/types/components/aws/helpers/apigatewayv2-domain.d.ts.map +1 -0
  415. package/platform/types/components/aws/helpers/arn.d.ts +51 -0
  416. package/platform/types/components/aws/helpers/arn.d.ts.map +1 -0
  417. package/platform/types/components/aws/helpers/bootstrap.d.ts +13 -0
  418. package/platform/types/components/aws/helpers/bootstrap.d.ts.map +1 -0
  419. package/platform/types/components/aws/helpers/client.d.ts +7 -0
  420. package/platform/types/components/aws/helpers/client.d.ts.map +1 -0
  421. package/platform/types/components/aws/helpers/container-builder.d.ts +4 -0
  422. package/platform/types/components/aws/helpers/container-builder.d.ts.map +1 -0
  423. package/platform/types/components/aws/helpers/custom-domain.d.ts +111 -0
  424. package/platform/types/components/aws/helpers/custom-domain.d.ts.map +1 -0
  425. package/platform/types/components/aws/helpers/event-source.d.ts +26 -0
  426. package/platform/types/components/aws/helpers/event-source.d.ts.map +1 -0
  427. package/platform/types/components/aws/helpers/fargate.d.ts +225 -0
  428. package/platform/types/components/aws/helpers/fargate.d.ts.map +1 -0
  429. package/platform/types/components/aws/helpers/function-builder.d.ts +14 -0
  430. package/platform/types/components/aws/helpers/function-builder.d.ts.map +1 -0
  431. package/platform/types/components/aws/helpers/function-code.d.ts +80 -0
  432. package/platform/types/components/aws/helpers/function-code.d.ts.map +1 -0
  433. package/platform/types/components/aws/helpers/function-part.d.ts +61 -0
  434. package/platform/types/components/aws/helpers/function-part.d.ts.map +1 -0
  435. package/platform/types/components/aws/helpers/function-permission.d.ts +17 -0
  436. package/platform/types/components/aws/helpers/function-permission.d.ts.map +1 -0
  437. package/platform/types/components/aws/helpers/load-balancer-args.d.ts +40 -0
  438. package/platform/types/components/aws/helpers/load-balancer-args.d.ts.map +1 -0
  439. package/platform/types/components/aws/helpers/load-balancer.d.ts +9 -0
  440. package/platform/types/components/aws/helpers/load-balancer.d.ts.map +1 -0
  441. package/platform/types/components/aws/helpers/provider.d.ts +3 -0
  442. package/platform/types/components/aws/helpers/provider.d.ts.map +1 -0
  443. package/platform/types/components/aws/helpers/queue-policy.d.ts +11 -0
  444. package/platform/types/components/aws/helpers/queue-policy.d.ts.map +1 -0
  445. package/platform/types/components/aws/helpers/rds.d.ts +98 -0
  446. package/platform/types/components/aws/helpers/rds.d.ts.map +1 -0
  447. package/platform/types/components/aws/helpers/site-builder.d.ts +4 -0
  448. package/platform/types/components/aws/helpers/site-builder.d.ts.map +1 -0
  449. package/platform/types/components/aws/helpers/subscriber.d.ts +6 -0
  450. package/platform/types/components/aws/helpers/subscriber.d.ts.map +1 -0
  451. package/platform/types/components/aws/helpers/vpc.d.ts +14 -0
  452. package/platform/types/components/aws/helpers/vpc.d.ts.map +1 -0
  453. package/platform/types/components/aws/https-redirect.d.ts +38 -0
  454. package/platform/types/components/aws/https-redirect.d.ts.map +1 -0
  455. package/platform/types/components/aws/iam-edit.d.ts +39 -0
  456. package/platform/types/components/aws/iam-edit.d.ts.map +1 -0
  457. package/platform/types/components/aws/index.d.ts +56 -0
  458. package/platform/types/components/aws/index.d.ts.map +1 -0
  459. package/platform/types/components/aws/kinesis-stream-lambda-subscriber.d.ts +49 -0
  460. package/platform/types/components/aws/kinesis-stream-lambda-subscriber.d.ts.map +1 -0
  461. package/platform/types/components/aws/kinesis-stream.d.ts +254 -0
  462. package/platform/types/components/aws/kinesis-stream.d.ts.map +1 -0
  463. package/platform/types/components/aws/linkable.d.ts +17 -0
  464. package/platform/types/components/aws/linkable.d.ts.map +1 -0
  465. package/platform/types/components/aws/logging.d.ts +26 -0
  466. package/platform/types/components/aws/logging.d.ts.map +1 -0
  467. package/platform/types/components/aws/microvm.d.ts +439 -0
  468. package/platform/types/components/aws/microvm.d.ts.map +1 -0
  469. package/platform/types/components/aws/mysql.d.ts +528 -0
  470. package/platform/types/components/aws/mysql.d.ts.map +1 -0
  471. package/platform/types/components/aws/nextjs.d.ts +534 -0
  472. package/platform/types/components/aws/nextjs.d.ts.map +1 -0
  473. package/platform/types/components/aws/nuxt.d.ts +480 -0
  474. package/platform/types/components/aws/nuxt.d.ts.map +1 -0
  475. package/platform/types/components/aws/open-search.d.ts +306 -0
  476. package/platform/types/components/aws/open-search.d.ts.map +1 -0
  477. package/platform/types/components/aws/opencontrol.d.ts +169 -0
  478. package/platform/types/components/aws/opencontrol.d.ts.map +1 -0
  479. package/platform/types/components/aws/permission.d.ts +80 -0
  480. package/platform/types/components/aws/permission.d.ts.map +1 -0
  481. package/platform/types/components/aws/postgres-v1.d.ts +328 -0
  482. package/platform/types/components/aws/postgres-v1.d.ts.map +1 -0
  483. package/platform/types/components/aws/postgres.d.ts +529 -0
  484. package/platform/types/components/aws/postgres.d.ts.map +1 -0
  485. package/platform/types/components/aws/providers/bucket-files.d.ts +18 -0
  486. package/platform/types/components/aws/providers/bucket-files.d.ts.map +1 -0
  487. package/platform/types/components/aws/providers/distribution-deployment-waiter.d.ts +13 -0
  488. package/platform/types/components/aws/providers/distribution-deployment-waiter.d.ts.map +1 -0
  489. package/platform/types/components/aws/providers/distribution-invalidation.d.ts +11 -0
  490. package/platform/types/components/aws/providers/distribution-invalidation.d.ts.map +1 -0
  491. package/platform/types/components/aws/providers/function-environment-update.d.ts +33 -0
  492. package/platform/types/components/aws/providers/function-environment-update.d.ts.map +1 -0
  493. package/platform/types/components/aws/providers/hosted-zone-lookup.d.ts +11 -0
  494. package/platform/types/components/aws/providers/hosted-zone-lookup.d.ts.map +1 -0
  495. package/platform/types/components/aws/providers/kv-keys.d.ts +11 -0
  496. package/platform/types/components/aws/providers/kv-keys.d.ts.map +1 -0
  497. package/platform/types/components/aws/providers/kv-routes-update.d.ts +11 -0
  498. package/platform/types/components/aws/providers/kv-routes-update.d.ts.map +1 -0
  499. package/platform/types/components/aws/providers/microvm-image-prune.d.ts +35 -0
  500. package/platform/types/components/aws/providers/microvm-image-prune.d.ts.map +1 -0
  501. package/platform/types/components/aws/providers/origin-access-control.d.ts +8 -0
  502. package/platform/types/components/aws/providers/origin-access-control.d.ts.map +1 -0
  503. package/platform/types/components/aws/providers/rds-role-lookup.d.ts +8 -0
  504. package/platform/types/components/aws/providers/rds-role-lookup.d.ts.map +1 -0
  505. package/platform/types/components/aws/providers/vector-table.d.ts +12 -0
  506. package/platform/types/components/aws/providers/vector-table.d.ts.map +1 -0
  507. package/platform/types/components/aws/queue-lambda-subscriber.d.ts +53 -0
  508. package/platform/types/components/aws/queue-lambda-subscriber.d.ts.map +1 -0
  509. package/platform/types/components/aws/queue.d.ts +494 -0
  510. package/platform/types/components/aws/queue.d.ts.map +1 -0
  511. package/platform/types/components/aws/react.d.ts +407 -0
  512. package/platform/types/components/aws/react.d.ts.map +1 -0
  513. package/platform/types/components/aws/realtime-lambda-subscriber.d.ts +53 -0
  514. package/platform/types/components/aws/realtime-lambda-subscriber.d.ts.map +1 -0
  515. package/platform/types/components/aws/realtime.d.ts +237 -0
  516. package/platform/types/components/aws/realtime.d.ts.map +1 -0
  517. package/platform/types/components/aws/redis-v1.d.ts +348 -0
  518. package/platform/types/components/aws/redis-v1.d.ts.map +1 -0
  519. package/platform/types/components/aws/redis.d.ts +545 -0
  520. package/platform/types/components/aws/redis.d.ts.map +1 -0
  521. package/platform/types/components/aws/remix.d.ts +408 -0
  522. package/platform/types/components/aws/remix.d.ts.map +1 -0
  523. package/platform/types/components/aws/router-base-route.d.ts +28 -0
  524. package/platform/types/components/aws/router-base-route.d.ts.map +1 -0
  525. package/platform/types/components/aws/router-bucket-route.d.ts +29 -0
  526. package/platform/types/components/aws/router-bucket-route.d.ts.map +1 -0
  527. package/platform/types/components/aws/router-url-route.d.ts +28 -0
  528. package/platform/types/components/aws/router-url-route.d.ts.map +1 -0
  529. package/platform/types/components/aws/router.d.ts +1767 -0
  530. package/platform/types/components/aws/router.d.ts.map +1 -0
  531. package/platform/types/components/aws/service-v1.d.ts +78 -0
  532. package/platform/types/components/aws/service-v1.d.ts.map +1 -0
  533. package/platform/types/components/aws/service.d.ts +1756 -0
  534. package/platform/types/components/aws/service.d.ts.map +1 -0
  535. package/platform/types/components/aws/sns-topic-lambda-subscriber.d.ts +53 -0
  536. package/platform/types/components/aws/sns-topic-lambda-subscriber.d.ts.map +1 -0
  537. package/platform/types/components/aws/sns-topic-queue-subscriber.d.ts +55 -0
  538. package/platform/types/components/aws/sns-topic-queue-subscriber.d.ts.map +1 -0
  539. package/platform/types/components/aws/sns-topic.d.ts +394 -0
  540. package/platform/types/components/aws/sns-topic.d.ts.map +1 -0
  541. package/platform/types/components/aws/solid-start.d.ts +399 -0
  542. package/platform/types/components/aws/solid-start.d.ts.map +1 -0
  543. package/platform/types/components/aws/ssr-site.d.ts +895 -0
  544. package/platform/types/components/aws/ssr-site.d.ts.map +1 -0
  545. package/platform/types/components/aws/static-site.d.ts +744 -0
  546. package/platform/types/components/aws/static-site.d.ts.map +1 -0
  547. package/platform/types/components/aws/step-functions/choice.d.ts +73 -0
  548. package/platform/types/components/aws/step-functions/choice.d.ts.map +1 -0
  549. package/platform/types/components/aws/step-functions/fail.d.ts +63 -0
  550. package/platform/types/components/aws/step-functions/fail.d.ts.map +1 -0
  551. package/platform/types/components/aws/step-functions/map.d.ts +236 -0
  552. package/platform/types/components/aws/step-functions/map.d.ts.map +1 -0
  553. package/platform/types/components/aws/step-functions/parallel.d.ts +127 -0
  554. package/platform/types/components/aws/step-functions/parallel.d.ts.map +1 -0
  555. package/platform/types/components/aws/step-functions/pass.d.ts +39 -0
  556. package/platform/types/components/aws/step-functions/pass.d.ts.map +1 -0
  557. package/platform/types/components/aws/step-functions/state.d.ts +231 -0
  558. package/platform/types/components/aws/step-functions/state.d.ts.map +1 -0
  559. package/platform/types/components/aws/step-functions/succeed.d.ts +26 -0
  560. package/platform/types/components/aws/step-functions/succeed.d.ts.map +1 -0
  561. package/platform/types/components/aws/step-functions/task.d.ts +485 -0
  562. package/platform/types/components/aws/step-functions/task.d.ts.map +1 -0
  563. package/platform/types/components/aws/step-functions/wait.d.ts +91 -0
  564. package/platform/types/components/aws/step-functions/wait.d.ts.map +1 -0
  565. package/platform/types/components/aws/step-functions.d.ts +478 -0
  566. package/platform/types/components/aws/step-functions.d.ts.map +1 -0
  567. package/platform/types/components/aws/svelte-kit.d.ts +456 -0
  568. package/platform/types/components/aws/svelte-kit.d.ts.map +1 -0
  569. package/platform/types/components/aws/takeover/alb.d.ts +2 -0
  570. package/platform/types/components/aws/takeover/alb.d.ts.map +1 -0
  571. package/platform/types/components/aws/takeover/apigatewayv2.d.ts +2 -0
  572. package/platform/types/components/aws/takeover/apigatewayv2.d.ts.map +1 -0
  573. package/platform/types/components/aws/takeover/app-sync.d.ts +2 -0
  574. package/platform/types/components/aws/takeover/app-sync.d.ts.map +1 -0
  575. package/platform/types/components/aws/takeover/aurora.d.ts +2 -0
  576. package/platform/types/components/aws/takeover/aurora.d.ts.map +1 -0
  577. package/platform/types/components/aws/takeover/bucket.d.ts +2 -0
  578. package/platform/types/components/aws/takeover/bucket.d.ts.map +1 -0
  579. package/platform/types/components/aws/takeover/bus.d.ts +2 -0
  580. package/platform/types/components/aws/takeover/bus.d.ts.map +1 -0
  581. package/platform/types/components/aws/takeover/cognito-user-pool.d.ts +2 -0
  582. package/platform/types/components/aws/takeover/cognito-user-pool.d.ts.map +1 -0
  583. package/platform/types/components/aws/takeover/cron-v2.d.ts +2 -0
  584. package/platform/types/components/aws/takeover/cron-v2.d.ts.map +1 -0
  585. package/platform/types/components/aws/takeover/dsql.d.ts +2 -0
  586. package/platform/types/components/aws/takeover/dsql.d.ts.map +1 -0
  587. package/platform/types/components/aws/takeover/dynamo.d.ts +2 -0
  588. package/platform/types/components/aws/takeover/dynamo.d.ts.map +1 -0
  589. package/platform/types/components/aws/takeover/efs.d.ts +2 -0
  590. package/platform/types/components/aws/takeover/efs.d.ts.map +1 -0
  591. package/platform/types/components/aws/takeover/function.d.ts +2 -0
  592. package/platform/types/components/aws/takeover/function.d.ts.map +1 -0
  593. package/platform/types/components/aws/takeover/helpers.d.ts +16 -0
  594. package/platform/types/components/aws/takeover/helpers.d.ts.map +1 -0
  595. package/platform/types/components/aws/takeover/index.d.ts +28 -0
  596. package/platform/types/components/aws/takeover/index.d.ts.map +1 -0
  597. package/platform/types/components/aws/takeover/mysql.d.ts +2 -0
  598. package/platform/types/components/aws/takeover/mysql.d.ts.map +1 -0
  599. package/platform/types/components/aws/takeover/postgres.d.ts +2 -0
  600. package/platform/types/components/aws/takeover/postgres.d.ts.map +1 -0
  601. package/platform/types/components/aws/takeover/queue.d.ts +2 -0
  602. package/platform/types/components/aws/takeover/queue.d.ts.map +1 -0
  603. package/platform/types/components/aws/takeover/redis.d.ts +2 -0
  604. package/platform/types/components/aws/takeover/redis.d.ts.map +1 -0
  605. package/platform/types/components/aws/takeover/service.d.ts +2 -0
  606. package/platform/types/components/aws/takeover/service.d.ts.map +1 -0
  607. package/platform/types/components/aws/takeover/sns-topic.d.ts +2 -0
  608. package/platform/types/components/aws/takeover/sns-topic.d.ts.map +1 -0
  609. package/platform/types/components/aws/takeover/task.d.ts +2 -0
  610. package/platform/types/components/aws/takeover/task.d.ts.map +1 -0
  611. package/platform/types/components/aws/tan-stack-start.d.ts +359 -0
  612. package/platform/types/components/aws/tan-stack-start.d.ts.map +1 -0
  613. package/platform/types/components/aws/task.d.ts +342 -0
  614. package/platform/types/components/aws/task.d.ts.map +1 -0
  615. package/platform/types/components/aws/v5/alb.d.ts +177 -0
  616. package/platform/types/components/aws/v5/alb.d.ts.map +1 -0
  617. package/platform/types/components/aws/v5/apigatewayv2.d.ts +482 -0
  618. package/platform/types/components/aws/v5/apigatewayv2.d.ts.map +1 -0
  619. package/platform/types/components/aws/v5/app-sync.d.ts +424 -0
  620. package/platform/types/components/aws/v5/app-sync.d.ts.map +1 -0
  621. package/platform/types/components/aws/v5/aurora.d.ts +459 -0
  622. package/platform/types/components/aws/v5/aurora.d.ts.map +1 -0
  623. package/platform/types/components/aws/v5/bucket.d.ts +578 -0
  624. package/platform/types/components/aws/v5/bucket.d.ts.map +1 -0
  625. package/platform/types/components/aws/v5/bus.d.ts +255 -0
  626. package/platform/types/components/aws/v5/bus.d.ts.map +1 -0
  627. package/platform/types/components/aws/v5/cluster.d.ts +167 -0
  628. package/platform/types/components/aws/v5/cluster.d.ts.map +1 -0
  629. package/platform/types/components/aws/v5/cognito-user-pool-client.d.ts +69 -0
  630. package/platform/types/components/aws/v5/cognito-user-pool-client.d.ts.map +1 -0
  631. package/platform/types/components/aws/v5/cognito-user-pool.d.ts +396 -0
  632. package/platform/types/components/aws/v5/cognito-user-pool.d.ts.map +1 -0
  633. package/platform/types/components/aws/v5/cron-v2.d.ts +206 -0
  634. package/platform/types/components/aws/v5/cron-v2.d.ts.map +1 -0
  635. package/platform/types/components/aws/v5/dsql.d.ts +453 -0
  636. package/platform/types/components/aws/v5/dsql.d.ts.map +1 -0
  637. package/platform/types/components/aws/v5/dynamo.d.ts +328 -0
  638. package/platform/types/components/aws/v5/dynamo.d.ts.map +1 -0
  639. package/platform/types/components/aws/v5/efs.d.ts +178 -0
  640. package/platform/types/components/aws/v5/efs.d.ts.map +1 -0
  641. package/platform/types/components/aws/v5/function.d.ts +586 -0
  642. package/platform/types/components/aws/v5/function.d.ts.map +1 -0
  643. package/platform/types/components/aws/v5/index.d.ts +27 -0
  644. package/platform/types/components/aws/v5/index.d.ts.map +1 -0
  645. package/platform/types/components/aws/v5/mysql.d.ts +347 -0
  646. package/platform/types/components/aws/v5/mysql.d.ts.map +1 -0
  647. package/platform/types/components/aws/v5/postgres.d.ts +348 -0
  648. package/platform/types/components/aws/v5/postgres.d.ts.map +1 -0
  649. package/platform/types/components/aws/v5/queue.d.ts +190 -0
  650. package/platform/types/components/aws/v5/queue.d.ts.map +1 -0
  651. package/platform/types/components/aws/v5/redis.d.ts +214 -0
  652. package/platform/types/components/aws/v5/redis.d.ts.map +1 -0
  653. package/platform/types/components/aws/v5/service.d.ts +1347 -0
  654. package/platform/types/components/aws/v5/service.d.ts.map +1 -0
  655. package/platform/types/components/aws/v5/sns-topic.d.ts +226 -0
  656. package/platform/types/components/aws/v5/sns-topic.d.ts.map +1 -0
  657. package/platform/types/components/aws/v5/task.d.ts +346 -0
  658. package/platform/types/components/aws/v5/task.d.ts.map +1 -0
  659. package/platform/types/components/aws/vector.d.ts +163 -0
  660. package/platform/types/components/aws/vector.d.ts.map +1 -0
  661. package/platform/types/components/aws/vpc-v1.d.ts +208 -0
  662. package/platform/types/components/aws/vpc-v1.d.ts.map +1 -0
  663. package/platform/types/components/aws/vpc.d.ts +491 -0
  664. package/platform/types/components/aws/vpc.d.ts.map +1 -0
  665. package/platform/types/components/aws/workflow.d.ts +331 -0
  666. package/platform/types/components/aws/workflow.d.ts.map +1 -0
  667. package/platform/types/components/base/base-site.d.ts +53 -0
  668. package/platform/types/components/base/base-site.d.ts.map +1 -0
  669. package/platform/types/components/base/base-ssr-site.d.ts +13 -0
  670. package/platform/types/components/base/base-ssr-site.d.ts.map +1 -0
  671. package/platform/types/components/base/base-static-site.d.ts +199 -0
  672. package/platform/types/components/base/base-static-site.d.ts.map +1 -0
  673. package/platform/types/components/cloudflare/account-id.d.ts +2 -0
  674. package/platform/types/components/cloudflare/account-id.d.ts.map +1 -0
  675. package/platform/types/components/cloudflare/ai.d.ts +68 -0
  676. package/platform/types/components/cloudflare/ai.d.ts.map +1 -0
  677. package/platform/types/components/cloudflare/astro.d.ts +249 -0
  678. package/platform/types/components/cloudflare/astro.d.ts.map +1 -0
  679. package/platform/types/components/cloudflare/auth.d.ts +22 -0
  680. package/platform/types/components/cloudflare/auth.d.ts.map +1 -0
  681. package/platform/types/components/cloudflare/binding.d.ts +109 -0
  682. package/platform/types/components/cloudflare/binding.d.ts.map +1 -0
  683. package/platform/types/components/cloudflare/bucket.d.ts +98 -0
  684. package/platform/types/components/cloudflare/bucket.d.ts.map +1 -0
  685. package/platform/types/components/cloudflare/cron.d.ts +151 -0
  686. package/platform/types/components/cloudflare/cron.d.ts.map +1 -0
  687. package/platform/types/components/cloudflare/d1.d.ts +142 -0
  688. package/platform/types/components/cloudflare/d1.d.ts.map +1 -0
  689. package/platform/types/components/cloudflare/dns.d.ts +100 -0
  690. package/platform/types/components/cloudflare/dns.d.ts.map +1 -0
  691. package/platform/types/components/cloudflare/durable-object.d.ts +125 -0
  692. package/platform/types/components/cloudflare/durable-object.d.ts.map +1 -0
  693. package/platform/types/components/cloudflare/experimental/index.d.ts +4 -0
  694. package/platform/types/components/cloudflare/experimental/index.d.ts.map +1 -0
  695. package/platform/types/components/cloudflare/experimental/solid-start.d.ts +219 -0
  696. package/platform/types/components/cloudflare/experimental/solid-start.d.ts.map +1 -0
  697. package/platform/types/components/cloudflare/experimental/static-site.d.ts +3 -0
  698. package/platform/types/components/cloudflare/experimental/static-site.d.ts.map +1 -0
  699. package/platform/types/components/cloudflare/helpers/compatibility.d.ts +21 -0
  700. package/platform/types/components/cloudflare/helpers/compatibility.d.ts.map +1 -0
  701. package/platform/types/components/cloudflare/helpers/fetch.d.ts +19 -0
  702. package/platform/types/components/cloudflare/helpers/fetch.d.ts.map +1 -0
  703. package/platform/types/components/cloudflare/helpers/validation.d.ts +15 -0
  704. package/platform/types/components/cloudflare/helpers/validation.d.ts.map +1 -0
  705. package/platform/types/components/cloudflare/helpers/worker-builder.d.ts +10 -0
  706. package/platform/types/components/cloudflare/helpers/worker-builder.d.ts.map +1 -0
  707. package/platform/types/components/cloudflare/helpers/wrangler.d.ts +31 -0
  708. package/platform/types/components/cloudflare/helpers/wrangler.d.ts.map +1 -0
  709. package/platform/types/components/cloudflare/hyperdrive.d.ts +302 -0
  710. package/platform/types/components/cloudflare/hyperdrive.d.ts.map +1 -0
  711. package/platform/types/components/cloudflare/index.d.ts +25 -0
  712. package/platform/types/components/cloudflare/index.d.ts.map +1 -0
  713. package/platform/types/components/cloudflare/kv.d.ts +140 -0
  714. package/platform/types/components/cloudflare/kv.d.ts.map +1 -0
  715. package/platform/types/components/cloudflare/providers/dns-record.d.ts +21 -0
  716. package/platform/types/components/cloudflare/providers/dns-record.d.ts.map +1 -0
  717. package/platform/types/components/cloudflare/providers/kv-data.d.ts +23 -0
  718. package/platform/types/components/cloudflare/providers/kv-data.d.ts.map +1 -0
  719. package/platform/types/components/cloudflare/providers/worker-assets.d.ts +19 -0
  720. package/platform/types/components/cloudflare/providers/worker-assets.d.ts.map +1 -0
  721. package/platform/types/components/cloudflare/providers/worker-placement.d.ts +27 -0
  722. package/platform/types/components/cloudflare/providers/worker-placement.d.ts.map +1 -0
  723. package/platform/types/components/cloudflare/providers/worker-script.d.ts +23 -0
  724. package/platform/types/components/cloudflare/providers/worker-script.d.ts.map +1 -0
  725. package/platform/types/components/cloudflare/providers/worker-url.d.ts +24 -0
  726. package/platform/types/components/cloudflare/providers/worker-url.d.ts.map +1 -0
  727. package/platform/types/components/cloudflare/providers/zone-lookup.d.ts +22 -0
  728. package/platform/types/components/cloudflare/providers/zone-lookup.d.ts.map +1 -0
  729. package/platform/types/components/cloudflare/queue-worker-subscriber.d.ts +122 -0
  730. package/platform/types/components/cloudflare/queue-worker-subscriber.d.ts.map +1 -0
  731. package/platform/types/components/cloudflare/queue.d.ts +235 -0
  732. package/platform/types/components/cloudflare/queue.d.ts.map +1 -0
  733. package/platform/types/components/cloudflare/rate-limit.d.ts +117 -0
  734. package/platform/types/components/cloudflare/rate-limit.d.ts.map +1 -0
  735. package/platform/types/components/cloudflare/react-router.d.ts +262 -0
  736. package/platform/types/components/cloudflare/react-router.d.ts.map +1 -0
  737. package/platform/types/components/cloudflare/ssr-site.d.ts +60 -0
  738. package/platform/types/components/cloudflare/ssr-site.d.ts.map +1 -0
  739. package/platform/types/components/cloudflare/static-site-v2.d.ts +302 -0
  740. package/platform/types/components/cloudflare/static-site-v2.d.ts.map +1 -0
  741. package/platform/types/components/cloudflare/static-site.d.ts +270 -0
  742. package/platform/types/components/cloudflare/static-site.d.ts.map +1 -0
  743. package/platform/types/components/cloudflare/tan-stack-start.d.ts +259 -0
  744. package/platform/types/components/cloudflare/tan-stack-start.d.ts.map +1 -0
  745. package/platform/types/components/cloudflare/worker.d.ts +483 -0
  746. package/platform/types/components/cloudflare/worker.d.ts.map +1 -0
  747. package/platform/types/components/cloudflare/workflow.d.ts +248 -0
  748. package/platform/types/components/cloudflare/workflow.d.ts.map +1 -0
  749. package/platform/types/components/component.d.ts +67 -0
  750. package/platform/types/components/component.d.ts.map +1 -0
  751. package/platform/types/components/core.d.ts +16 -0
  752. package/platform/types/components/core.d.ts.map +1 -0
  753. package/platform/types/components/cpu.d.ts +3 -0
  754. package/platform/types/components/cpu.d.ts.map +1 -0
  755. package/platform/types/components/dns.d.ts +63 -0
  756. package/platform/types/components/dns.d.ts.map +1 -0
  757. package/platform/types/components/duration.d.ts +9 -0
  758. package/platform/types/components/duration.d.ts.map +1 -0
  759. package/platform/types/components/error.d.ts +4 -0
  760. package/platform/types/components/error.d.ts.map +1 -0
  761. package/platform/types/components/esbuild.d.ts +3 -0
  762. package/platform/types/components/esbuild.d.ts.map +1 -0
  763. package/platform/types/components/experimental/dev-command.d.ts +99 -0
  764. package/platform/types/components/experimental/dev-command.d.ts.map +1 -0
  765. package/platform/types/components/experimental/index.d.ts +2 -0
  766. package/platform/types/components/experimental/index.d.ts.map +1 -0
  767. package/platform/types/components/groups.d.ts +6 -0
  768. package/platform/types/components/groups.d.ts.map +1 -0
  769. package/platform/types/components/index.d.ts +5 -0
  770. package/platform/types/components/index.d.ts.map +1 -0
  771. package/platform/types/components/input.d.ts +3 -0
  772. package/platform/types/components/input.d.ts.map +1 -0
  773. package/platform/types/components/link.d.ts +41 -0
  774. package/platform/types/components/link.d.ts.map +1 -0
  775. package/platform/types/components/linkable.d.ts +301 -0
  776. package/platform/types/components/linkable.d.ts.map +1 -0
  777. package/platform/types/components/naming-rules.d.ts +32 -0
  778. package/platform/types/components/naming-rules.d.ts.map +1 -0
  779. package/platform/types/components/naming.d.ts +21 -0
  780. package/platform/types/components/naming.d.ts.map +1 -0
  781. package/platform/types/components/parts-component.d.ts +242 -0
  782. package/platform/types/components/parts-component.d.ts.map +1 -0
  783. package/platform/types/components/parts.d.ts +194 -0
  784. package/platform/types/components/parts.d.ts.map +1 -0
  785. package/platform/types/components/path.d.ts +2 -0
  786. package/platform/types/components/path.d.ts.map +1 -0
  787. package/platform/types/components/rpc/rpc.d.ts +19 -0
  788. package/platform/types/components/rpc/rpc.d.ts.map +1 -0
  789. package/platform/types/components/secret.d.ts +123 -0
  790. package/platform/types/components/secret.d.ts.map +1 -0
  791. package/platform/types/components/size.d.ts +5 -0
  792. package/platform/types/components/size.d.ts.map +1 -0
  793. package/platform/types/components/takeover.d.ts +88 -0
  794. package/platform/types/components/takeover.d.ts.map +1 -0
  795. package/platform/types/components/transform.d.ts +34 -0
  796. package/platform/types/components/transform.d.ts.map +1 -0
  797. package/platform/types/components/vercel/account-id.d.ts +2 -0
  798. package/platform/types/components/vercel/account-id.d.ts.map +1 -0
  799. package/platform/types/components/vercel/dns.d.ts +73 -0
  800. package/platform/types/components/vercel/dns.d.ts.map +1 -0
  801. package/platform/types/components/vercel/index.d.ts +3 -0
  802. package/platform/types/components/vercel/index.d.ts.map +1 -0
  803. package/platform/types/components/vercel/providers/dns-record.d.ts +15 -0
  804. package/platform/types/components/vercel/providers/dns-record.d.ts.map +1 -0
  805. package/platform/types/config.d.ts +1440 -0
  806. package/platform/types/config.d.ts.map +1 -0
  807. package/platform/types/global-aliases.d.ts +37 -0
  808. package/platform/types/global.d.ts +374 -0
  809. package/platform/types/internal.d.ts +18 -0
  810. package/platform/types/runtime/worker/unenv.d.ts +14 -0
  811. package/platform/types/testing/global.d.ts +11 -0
  812. package/platform/types/testing/global.d.ts.map +1 -0
  813. package/platform/types/testing/index.d.ts +80 -0
  814. package/platform/types/testing/index.d.ts.map +1 -0
  815. package/platform/types/testing/mock.d.ts +136 -0
  816. package/platform/types/testing/mock.d.ts.map +1 -0
  817. package/platform/types/testing/vitest.d.ts +19 -0
  818. package/platform/types/testing/vitest.d.ts.map +1 -0
  819. package/platform/types/util/compare-semver.d.ts +4 -0
  820. package/platform/types/util/compare-semver.d.ts.map +1 -0
  821. package/platform/types/util/fs.d.ts +5 -0
  822. package/platform/types/util/fs.d.ts.map +1 -0
  823. package/platform/types/util/lazy.d.ts +2 -0
  824. package/platform/types/util/lazy.d.ts.map +1 -0
  825. package/platform/types/util/minify.d.ts +2 -0
  826. package/platform/types/util/minify.d.ts.map +1 -0
  827. package/platform/types/util/package.d.ts +10 -0
  828. package/platform/types/util/package.d.ts.map +1 -0
  829. package/platform/types/util/semaphore.d.ts +9 -0
  830. package/platform/types/util/semaphore.d.ts.map +1 -0
  831. package/platform/types/util/warn.d.ts +2 -0
  832. package/platform/types/util/warn.d.ts.map +1 -0
@@ -0,0 +1,3294 @@
1
+ import path from "path";
2
+ import {
3
+ ComponentResourceOptions,
4
+ Output,
5
+ all,
6
+ interpolate,
7
+ output,
8
+ } from "@pulumi/pulumi";
9
+ import { asset } from "@pulumi/pulumi";
10
+ import { iam, lambda } from "@pulumi/aws";
11
+ import crypto from "crypto";
12
+ import { Component, Transform, transform } from "../component";
13
+ import { Link } from "../link";
14
+ import type { Input } from "../input";
15
+ import { Cdn, CdnArgs } from "./cdn";
16
+ import { cloudfront, cloudwatch, wafv2 } from "@pulumi/aws";
17
+ import { useProvider } from "./helpers/provider";
18
+ import { hashStringToPrettyString, physicalName } from "../naming";
19
+ import { Bucket } from "./bucket";
20
+ import { OriginAccessControl } from "./providers/origin-access-control";
21
+ import { VisibleError } from "../error";
22
+ import { RouterUrlRoute } from "./router-url-route";
23
+ import { RouterBucketRoute } from "./router-bucket-route";
24
+ import { DurationSeconds, toSeconds } from "../duration";
25
+ import { FunctionArn } from "./function.js";
26
+ import { parseLambdaEdgeArn } from "./helpers/arn";
27
+ import { Size, toMBs } from "../size";
28
+ import { RETENTION } from "./logging";
29
+ import { minify } from "../../util/minify";
30
+
31
+ interface InlineUrlRouteArgs extends InlineBaseRouteArgs {
32
+ /**
33
+ * The destination URL.
34
+ *
35
+ * @example
36
+ *
37
+ * ```js
38
+ * {
39
+ * routes: {
40
+ * "/api/*": {
41
+ * url: "https://example.com"
42
+ * }
43
+ * }
44
+ * }
45
+ * ```
46
+ */
47
+ url: Input<string>;
48
+ /**
49
+ * Rewrite the request path.
50
+ *
51
+ * @example
52
+ *
53
+ * By default, if the route path is `/api/*` and a request comes in for `/api/users/profile`,
54
+ * the request path the destination sees is `/api/users/profile`.
55
+ *
56
+ * If you want to serve the route from the root, you can rewrite the request path to
57
+ * `/users/profile`.
58
+ *
59
+ * ```js
60
+ * {
61
+ * routes: {
62
+ * "/api/*": {
63
+ * url: "https://api.example.com",
64
+ * rewrite: {
65
+ * regex: "^/api/(.*)$",
66
+ * to: "/$1"
67
+ * }
68
+ * }
69
+ * }
70
+ * }
71
+ * ```
72
+ */
73
+ rewrite?: Input<{
74
+ /**
75
+ * The regex to match the request path.
76
+ */
77
+ regex: Input<string>;
78
+ /**
79
+ * The replacement for the matched path.
80
+ */
81
+ to: Input<string>;
82
+ }>;
83
+ }
84
+
85
+ interface InlineRouterBucketRouteArgs extends InlineBaseRouteArgs {
86
+ /**
87
+ * A bucket to route to.
88
+ *
89
+ * :::note
90
+ * You need to let CloudFront `access` the bucket.
91
+ * :::
92
+ *
93
+ * @example
94
+ *
95
+ * For example, let's say you have a bucket that gives CloudFront `access`.
96
+ *
97
+ * ```ts title="sst.config.ts" {2}
98
+ * const myBucket = new sst.aws.Bucket("MyBucket", {
99
+ * access: "cloudfront"
100
+ * });
101
+ * ```
102
+ *
103
+ * You can then this directly as the destination for the route.
104
+ *
105
+ * ```js
106
+ * {
107
+ * routes: {
108
+ * "/files/*": {
109
+ * bucket: myBucket
110
+ * }
111
+ * }
112
+ * }
113
+ * ```
114
+ *
115
+ * Or if you have an existing bucket, you can pass in its regional domain.
116
+ *
117
+ * ```js
118
+ * {
119
+ * routes: {
120
+ * "/files/*": {
121
+ * bucket: "my-bucket.s3.us-east-1.amazonaws.com"
122
+ * }
123
+ * }
124
+ * }
125
+ * ```
126
+ */
127
+ bucket?: Input<Bucket | string>;
128
+ /**
129
+ * Rewrite the request path.
130
+ *
131
+ * @example
132
+ *
133
+ * By default, if the route path is `/files/*` and a request comes in for `/files/logo.png`,
134
+ * the request path the destination sees is `/files/logo.png`. In the case of a bucket route,
135
+ * the file `logo.png` is served from the `files` directory in the bucket.
136
+ *
137
+ * If you want to serve the file from the root of the bucket, you can rewrite
138
+ * the request path to `/logo.png`.
139
+ *
140
+ * ```js
141
+ * {
142
+ * routes: {
143
+ * "/files/*": {
144
+ * bucket: myBucket,
145
+ * rewrite: {
146
+ * regex: "^/files/(.*)$",
147
+ * to: "/$1"
148
+ * }
149
+ * }
150
+ * }
151
+ * }
152
+ * ```
153
+ */
154
+ rewrite?: Input<{
155
+ /**
156
+ * The regex to match the request path.
157
+ */
158
+ regex: Input<string>;
159
+ /**
160
+ * The replacement for the matched path.
161
+ */
162
+ to: Input<string>;
163
+ }>;
164
+ }
165
+
166
+ interface InlineBaseRouteArgs {
167
+ /**
168
+ * The cache policy to use for the route.
169
+ *
170
+ * @default CloudFront's managed CachingOptimized policy
171
+ * @example
172
+ * ```js
173
+ * {
174
+ * routes: {
175
+ * "/files/*": {
176
+ * url: "https://example.com"
177
+ * cachePolicy: "658327ea-f89d-4fab-a63d-7e88639e58f6"
178
+ * }
179
+ * }
180
+ * }
181
+ * ```
182
+ */
183
+ cachePolicy?: Input<string>;
184
+ /**
185
+ * Configure CloudFront Functions to customize the behavior of HTTP requests and responses at the edge.
186
+ */
187
+ edge?: {
188
+ /**
189
+ * Configure the viewer request function.
190
+ *
191
+ * The viewer request function can be used to modify incoming requests before they
192
+ * reach your origin server. For example, you can redirect users, rewrite URLs,
193
+ * or add headers.
194
+ */
195
+ viewerRequest?: Input<{
196
+ /**
197
+ * The code to inject into the viewer request function.
198
+ *
199
+ * By default, a viewer request function is created to add the `x-forwarded-host`
200
+ * header. The given code will be injected at the end of this function.
201
+ *
202
+ * ```js
203
+ * async function handler(event) {
204
+ * // Default behavior code
205
+ *
206
+ * // User injected code
207
+ *
208
+ * return event.request;
209
+ * }
210
+ * ```
211
+ *
212
+ * @example
213
+ * To add a custom header to all requests.
214
+ *
215
+ * ```js
216
+ * {
217
+ * routes: {
218
+ * "/api/*": {
219
+ * url: "https://example.com"
220
+ * edge: {
221
+ * viewerRequest: {
222
+ * injection: `event.request.headers["x-foo"] = { value: "bar" };`
223
+ * }
224
+ * }
225
+ * }
226
+ * }
227
+ * }
228
+ * ```
229
+ */
230
+ injection: Input<string>;
231
+ /**
232
+ * The KeyValueStore to associate with the viewer request function.
233
+ *
234
+ * @example
235
+ * ```js
236
+ * {
237
+ * routes: {
238
+ * "/api/*": {
239
+ * url: "https://example.com"
240
+ * edge: {
241
+ * viewerRequest: {
242
+ * kvStore: "arn:aws:cloudfront::123456789012:key-value-store/my-store"
243
+ * }
244
+ * }
245
+ * }
246
+ * }
247
+ * }
248
+ * ```
249
+ */
250
+ kvStore?: Input<string>;
251
+ /**
252
+ * @deprecated Use `kvStore` instead because CloudFront Functions only support one KeyValueStore.
253
+ */
254
+ kvStores?: Input<Input<string>[]>;
255
+ }>;
256
+ /**
257
+ * Configure the viewer response function.
258
+ *
259
+ * The viewer response function can be used to modify outgoing responses before
260
+ * they are sent to the client. For example, you can add security headers or change
261
+ * the response status code.
262
+ *
263
+ * By default, no viewer response function is set. A new function will be created
264
+ * with the provided code.
265
+ *
266
+ * @example
267
+ * Add a custom header to all responses
268
+ * ```js
269
+ * {
270
+ * routes: {
271
+ * "/api/*": {
272
+ * url: "https://example.com"
273
+ * edge: {
274
+ * viewerResponse: {
275
+ * injection: `event.response.headers["x-foo"] = { value: "bar" };`
276
+ * }
277
+ * }
278
+ * }
279
+ * }
280
+ * }
281
+ * ```
282
+ */
283
+ viewerResponse?: Input<{
284
+ /**
285
+ * The code to inject into the viewer response function.
286
+ *
287
+ * By default, no viewer response function is set. A new function will be created with
288
+ * the provided code.
289
+ *
290
+ * ```js
291
+ * async function handler(event) {
292
+ * // User injected code
293
+ *
294
+ * return event.response;
295
+ * }
296
+ * ```
297
+ *
298
+ * @example
299
+ * To add a custom header to all responses.
300
+ *
301
+ * ```js
302
+ * {
303
+ * routes: {
304
+ * "/api/*": {
305
+ * url: "https://example.com"
306
+ * edge: {
307
+ * viewerResponse: {
308
+ * injection: `event.response.headers["x-foo"] = { value: "bar" };`
309
+ * }
310
+ * }
311
+ * }
312
+ * }
313
+ * }
314
+ * ```
315
+ */
316
+ injection: Input<string>;
317
+ /**
318
+ * The KeyValueStore to associate with the viewer response function.
319
+ *
320
+ * @example
321
+ * ```js
322
+ * {
323
+ * routes: {
324
+ * "/api/*": {
325
+ * url: "https://example.com"
326
+ * edge: {
327
+ * viewerResponse: {
328
+ * kvStore: "arn:aws:cloudfront::123456789012:key-value-store/my-store"
329
+ * }
330
+ * }
331
+ * }
332
+ * }
333
+ * }
334
+ * ```
335
+ */
336
+ kvStore?: Input<string>;
337
+ /**
338
+ * @deprecated Use `kvStore` instead because CloudFront Functions only support one KeyValueStore.
339
+ */
340
+ kvStores?: Input<Input<string>[]>;
341
+ }>;
342
+ };
343
+ }
344
+
345
+ interface RouteArgs {
346
+ /**
347
+ * The number of times that CloudFront attempts to connect to the origin. Must be
348
+ * between 1 and 3.
349
+ * @default 3
350
+ * @example
351
+ * ```js
352
+ * {
353
+ * connectionAttempts: 1
354
+ * }
355
+ * ```
356
+ */
357
+ connectionAttempts?: Input<number>;
358
+ /**
359
+ * The number of seconds that CloudFront waits before timing out and closing the
360
+ * connection to the origin. Must be between 1 and 10 seconds.
361
+ * @default `"10 seconds"`
362
+ * @example
363
+ * ```js
364
+ * {
365
+ * connectionTimeout: "3 seconds"
366
+ * }
367
+ * ```
368
+ */
369
+ connectionTimeout?: Input<DurationSeconds>;
370
+ }
371
+
372
+ export interface RouterUrlRouteArgs extends RouteArgs {
373
+ /**
374
+ * Rewrite the request path.
375
+ *
376
+ * @example
377
+ *
378
+ * If the route path is `/api/*` and a request comes in for `/api/users/profile`,
379
+ * the request path the destination sees is `/api/users/profile`.
380
+ *
381
+ * If you want to serve the route from the root, you can rewrite the request
382
+ * path to `/users/profile`.
383
+ *
384
+ * ```js
385
+ * {
386
+ * rewrite: {
387
+ * regex: "^/api/(.*)$",
388
+ * to: "/$1"
389
+ * }
390
+ * }
391
+ * ```
392
+ */
393
+ rewrite?: Input<{
394
+ /**
395
+ * The regex to match the request path.
396
+ */
397
+ regex: Input<string>;
398
+ /**
399
+ * The replacement for the matched path.
400
+ */
401
+ to: Input<string>;
402
+ }>;
403
+ /**
404
+ * The number of seconds that CloudFront waits for a response after routing a
405
+ * request to the destination. Must be between 1 and 60 seconds.
406
+ *
407
+ * When compared to the `connectionTimeout`, this is the time CloudFront waits
408
+ * for each connection attempt. If the destination doesn't respond, CloudFront
409
+ * tries again, up to `connectionAttempts` times (3 by default), so the request
410
+ * can take that many times this value to fail.
411
+ *
412
+ * The Router applies this timeout dynamically to matching requests through
413
+ * its CloudFront Function. It does not change the distribution's static
414
+ * origin configuration. When you don't set it, the requests use the 20 seconds
415
+ * that the Router sets on the distribution's origin by default.
416
+ *
417
+ * @default `"20 seconds"`
418
+ * @example
419
+ * ```js
420
+ * {
421
+ * readTimeout: "60 seconds"
422
+ * }
423
+ * ```
424
+ */
425
+ readTimeout?: Input<DurationSeconds>;
426
+ /**
427
+ * The number of seconds that CloudFront should try to maintain the connection
428
+ * to the destination after receiving the last packet of the response. Must be
429
+ * between 1 and 60 seconds
430
+ *
431
+ * The Router passes this value to CloudFront with each matching request, but
432
+ * CloudFront currently does not apply it. It keeps the connection for the
433
+ * keep-alive timeout of the distribution's origin, which is 5 seconds by
434
+ * default, whatever you set here.
435
+ *
436
+ * @default `"5 seconds"`
437
+ * @example
438
+ * ```js
439
+ * {
440
+ * keepAliveTimeout: "10 seconds"
441
+ * }
442
+ * ```
443
+ */
444
+ keepAliveTimeout?: Input<DurationSeconds>;
445
+ }
446
+
447
+ export interface RouterBucketRouteArgs extends RouteArgs {
448
+ /**
449
+ * Rewrite the request path.
450
+ *
451
+ * @example
452
+ *
453
+ * If the route path is `/files/*` and a request comes in for `/files/logo.png`,
454
+ * the request path the destination sees is `/files/logo.png`.
455
+ *
456
+ * If you want to serve the file from the root of the bucket, you can rewrite
457
+ * the request path to `/logo.png`.
458
+ *
459
+ * ```js
460
+ * {
461
+ * rewrite: {
462
+ * regex: "^/files/(.*)$",
463
+ * to: "/$1"
464
+ * }
465
+ * }
466
+ * ```
467
+ */
468
+ rewrite?: Input<{
469
+ /**
470
+ * The regex to match the request path.
471
+ */
472
+ regex: Input<string>;
473
+ /**
474
+ * The replacement for the matched path.
475
+ */
476
+ to: Input<string>;
477
+ }>;
478
+ }
479
+
480
+ export interface WafLoggingArgs {
481
+ /**
482
+ * Filter which requests are logged.
483
+ *
484
+ * - `"all"` logs every request evaluated by the WAF.
485
+ * - `"blocked"` only logs requests that were blocked.
486
+ *
487
+ * @default `"all"`
488
+ * @example
489
+ * ```js
490
+ * {
491
+ * waf: {
492
+ * logging: {
493
+ * include: "blocked"
494
+ * }
495
+ * }
496
+ * }
497
+ * ```
498
+ */
499
+ include?: Input<"all" | "blocked">;
500
+ /**
501
+ * The duration the WAF logs are kept in CloudWatch.
502
+ *
503
+ * @default `"1 month"`
504
+ * @example
505
+ * ```js
506
+ * {
507
+ * waf: {
508
+ * logging: {
509
+ * retention: "3 months"
510
+ * }
511
+ * }
512
+ * }
513
+ * ```
514
+ */
515
+ retention?: Input<keyof typeof RETENTION>;
516
+ /**
517
+ * Configure which parts of the request are redacted from the logs. Redacted
518
+ * fields are replaced with `REDACTED` in the log output.
519
+ *
520
+ * By default, the query string and the `cookie` and `authorization` headers
521
+ * are redacted since they commonly contain PII or credentials.
522
+ *
523
+ * Set to `false` to disable all redaction.
524
+ *
525
+ * @default `{ queryString: true, headers: ["cookie", "authorization"] }`
526
+ * @example
527
+ *
528
+ * Disable all redaction.
529
+ *
530
+ * ```js
531
+ * {
532
+ * waf: {
533
+ * logging: {
534
+ * redact: false
535
+ * }
536
+ * }
537
+ * }
538
+ * ```
539
+ *
540
+ * Redact everything.
541
+ *
542
+ * ```js
543
+ * {
544
+ * waf: {
545
+ * logging: {
546
+ * redact: {
547
+ * queryString: true,
548
+ * uriPath: true,
549
+ * method: true,
550
+ * headers: ["cookie", "authorization"]
551
+ * }
552
+ * }
553
+ * }
554
+ * }
555
+ * ```
556
+ */
557
+ redact?: Input<
558
+ | false
559
+ | {
560
+ /**
561
+ * Redact the query string from the logs. The query string is the
562
+ * part of a URL after the `?` and can contain tokens, user IDs,
563
+ * or other sensitive parameters.
564
+ * @default `true`
565
+ */
566
+ queryString?: Input<boolean>;
567
+ /**
568
+ * Redact the URI path from the logs. The URI path identifies the
569
+ * resource being accessed, like `/users/123/profile`.
570
+ * @default `false`
571
+ */
572
+ uriPath?: Input<boolean>;
573
+ /**
574
+ * Redact the HTTP method from the logs (GET, POST, etc.).
575
+ * @default `false`
576
+ */
577
+ method?: Input<boolean>;
578
+ /**
579
+ * A list of header names to redact from the logs. Must be lowercase.
580
+ * @default `["cookie", "authorization"]`
581
+ * @example
582
+ * ```js
583
+ * {
584
+ * headers: ["cookie", "authorization", "x-api-key"]
585
+ * }
586
+ * ```
587
+ */
588
+ headers?: Input<string[]>;
589
+ }
590
+ >;
591
+ }
592
+
593
+ export interface WafArgs {
594
+ /**
595
+ * The rate limit per IP address. Requests from an IP that exceed this limit
596
+ * within a 5-minute window will be blocked.
597
+ *
598
+ * @default `2000`
599
+ * @example
600
+ * ```js
601
+ * {
602
+ * waf: {
603
+ * rateLimitPerIp: 1000
604
+ * }
605
+ * }
606
+ * ```
607
+ */
608
+ rateLimitPerIp?: Input<number>;
609
+ /**
610
+ * Configure which AWS managed rule groups to enable.
611
+ *
612
+ * @default All managed rules enabled
613
+ * @example
614
+ * ```js
615
+ * {
616
+ * waf: {
617
+ * managedRules: {
618
+ * coreRuleSet: true,
619
+ * knownBadInputs: true,
620
+ * sqlInjection: false
621
+ * }
622
+ * }
623
+ * }
624
+ * ```
625
+ */
626
+ managedRules?: Input<{
627
+ /**
628
+ * Enable the AWS Core Rule Set (CRS) which provides protection against common
629
+ * web vulnerabilities.
630
+ * @default `true`
631
+ */
632
+ coreRuleSet?: Input<boolean>;
633
+ /**
634
+ * Enable protection against known bad inputs, including Log4j vulnerabilities.
635
+ * @default `true`
636
+ */
637
+ knownBadInputs?: Input<boolean>;
638
+ /**
639
+ * Enable SQL injection protection.
640
+ * @default `true`
641
+ */
642
+ sqlInjection?: Input<boolean>;
643
+ }>;
644
+ /**
645
+ * Configure WAF logging to CloudWatch. When set to `true`, all WAF-evaluated
646
+ * requests are logged with a 1-month retention. Or pass in an object to
647
+ * customize what is logged, how long logs are retained, and which fields
648
+ * are redacted.
649
+ *
650
+ * :::tip
651
+ * WAF logging is off by default. Enabling it will incur additional
652
+ * [CloudWatch costs](https://aws.amazon.com/cloudwatch/pricing/) depending
653
+ * on log volume.
654
+ * :::
655
+ *
656
+ * @default Logging is disabled
657
+ * @example
658
+ *
659
+ * Enable with defaults.
660
+ *
661
+ * ```js
662
+ * {
663
+ * waf: {
664
+ * logging: true
665
+ * }
666
+ * }
667
+ * ```
668
+ *
669
+ * Only log blocked requests.
670
+ *
671
+ * ```js
672
+ * {
673
+ * waf: {
674
+ * logging: {
675
+ * include: "blocked",
676
+ * retention: "3 months"
677
+ * }
678
+ * }
679
+ * }
680
+ * ```
681
+ *
682
+ * Redact sensitive fields.
683
+ *
684
+ * ```js
685
+ * {
686
+ * waf: {
687
+ * logging: {
688
+ * redact: {
689
+ * queryString: true,
690
+ * headers: ["cookie"]
691
+ * }
692
+ * }
693
+ * }
694
+ * }
695
+ * ```
696
+ */
697
+ logging?: Input<boolean | WafLoggingArgs>;
698
+ }
699
+
700
+ export interface RouterArgs {
701
+ /**
702
+ * Set a custom domain for your Router.
703
+ *
704
+ * Automatically manages domains hosted on AWS Route 53, Cloudflare, and Vercel. For other
705
+ * providers, you'll need to pass in a `cert` that validates domain ownership and add the
706
+ * DNS records.
707
+ *
708
+ * :::tip
709
+ * Built-in support for AWS Route 53, Cloudflare, and Vercel. And manual setup for other
710
+ * providers.
711
+ * :::
712
+ *
713
+ * @example
714
+ *
715
+ * By default this assumes the domain is hosted on Route 53.
716
+ *
717
+ * ```js
718
+ * {
719
+ * domain: "example.com"
720
+ * }
721
+ * ```
722
+ *
723
+ * For domains hosted on Cloudflare.
724
+ *
725
+ * ```js
726
+ * {
727
+ * domain: {
728
+ * name: "example.com",
729
+ * dns: sst.cloudflare.dns()
730
+ * }
731
+ * }
732
+ * ```
733
+ *
734
+ * Specify a `www.` version of the custom domain.
735
+ *
736
+ * ```js
737
+ * {
738
+ * domain: {
739
+ * name: "domain.com",
740
+ * redirects: ["www.domain.com"]
741
+ * }
742
+ * }
743
+ * ```
744
+ */
745
+ domain?: CdnArgs["domain"];
746
+ /**
747
+ * A map of routes to their destinations.
748
+ *
749
+ * @deprecated Use the `route` and `routeBucket` functions instead. These
750
+ * functions provide a more flexible API for routing to URLs and buckets. They
751
+ * also allow routing based on both domain and path patterns.
752
+ *
753
+ * The _key_ is the route path and the _value_ can be:
754
+ *
755
+ * - The destination URL as a string
756
+ * - Or, an object with
757
+ * - Args for a URL route
758
+ * - Args for a bucket route
759
+ *
760
+ * :::note
761
+ * All routes need to start with `/`.
762
+ * :::
763
+ *
764
+ * For example, you can set the destination as a URL.
765
+ *
766
+ * ```ts
767
+ * {
768
+ * routes: {
769
+ * "/*": "https://example.com"
770
+ * }
771
+ * }
772
+ * ```
773
+ *
774
+ * Or, you can route to a bucket.
775
+ *
776
+ * ```ts
777
+ * {
778
+ * routes: {
779
+ * "/files/*": {
780
+ * bucket: myBucket
781
+ * }
782
+ * }
783
+ * }
784
+ * ```
785
+ *
786
+ * When router receives a request, the requested path is compared with path patterns
787
+ * in the order they are listed. The first match determines which URL the
788
+ * request is routed to.
789
+ *
790
+ * :::tip[Default Route]
791
+ * The `/*` route is a default or catch-all route.
792
+ * :::
793
+ *
794
+ * The `/*` route is a _default_ route, meaning that if no routes match, the `/*` route will be used. It does not matter where the `/*` route is listed in the routes object.
795
+ *
796
+ * :::note
797
+ * If you don't have a `/*` route, you'll get a 404 error for any requests that don't match a route.
798
+ * :::
799
+ *
800
+ * Suppose you have the following three routes.
801
+ *
802
+ * ```js
803
+ * {
804
+ * routes: {
805
+ * "/api/*.json": "https://example1.com",
806
+ * "/api/*": "https://example2.com",
807
+ * "/*.xml": "https://example3.com",
808
+ * }
809
+ * }
810
+ * ```
811
+ *
812
+ * A request to `/api/sample.xml` will match `/api/*` first and route to it; even though it matches `/*.xml`.
813
+ *
814
+ * However for this case, a request to `/api/users` will route to `/api/*` even though it comes after `/*`. This is because the `/*` route is the default route.
815
+ *
816
+ * ```js
817
+ * {
818
+ * routes: {
819
+ * "/*": "myapp.com",
820
+ * "/api/*": myFunction.url
821
+ * }
822
+ * }
823
+ * ```
824
+ *
825
+ * You can also customize the route behavior with injecting some code into the CloudFront
826
+ * Functions. To do so, pass in an object, with the destination as the `url`.
827
+ *
828
+ * ```ts
829
+ * {
830
+ * routes: {
831
+ * "/*": {
832
+ * url: "https://example.com",
833
+ * edge: {
834
+ * viewerRequest: {
835
+ * injection: `event.request.headers["x-foo"] = { value: "bar" };`
836
+ * }
837
+ * }
838
+ * }
839
+ * }
840
+ * }
841
+ * ```
842
+ *
843
+ * You can also `rewrite` the request path.
844
+ *
845
+ * ```ts
846
+ * {
847
+ * routes: {
848
+ * "/files/*": {
849
+ * bucket: myBucket,
850
+ * rewrite: {
851
+ * regex: "^/files/(.*)$",
852
+ * to: "/$1"
853
+ * }
854
+ * }
855
+ * }
856
+ * }
857
+ * ```
858
+ */
859
+ routes?: Input<
860
+ Record<
861
+ string,
862
+ Input<string | InlineUrlRouteArgs | InlineRouterBucketRouteArgs>
863
+ >
864
+ >;
865
+ /**
866
+ * Configure CloudFront Functions to customize the behavior of HTTP requests and responses at the edge.
867
+ */
868
+ edge?: {
869
+ /**
870
+ * Configure the viewer request function.
871
+ *
872
+ * The viewer request function can be used to modify incoming requests before they
873
+ * reach your origin server. For example, you can redirect users, rewrite URLs,
874
+ * or add headers.
875
+ */
876
+ viewerRequest?: Input<{
877
+ /**
878
+ * The code to inject into the viewer request function.
879
+ *
880
+ * By default, a viewer request function is created to:
881
+ * - Disable CloudFront default URL if custom domain is set.
882
+ * - Add the `x-forwarded-host` header.
883
+ * - Route requests to the corresponding target based on the domain and request path.
884
+ *
885
+ * The given code will be injected at the beginning of this function.
886
+ *
887
+ * ```js
888
+ * async function handler(event) {
889
+ * // User injected code
890
+ *
891
+ * // Default behavior code
892
+ *
893
+ * return event.request;
894
+ * }
895
+ * ```
896
+ *
897
+ * @example
898
+ * To add a custom header to all requests.
899
+ *
900
+ * ```js
901
+ * {
902
+ * edge: {
903
+ * viewerRequest: {
904
+ * injection: `event.request.headers["x-foo"] = { value: "bar" };`
905
+ * }
906
+ * }
907
+ * }
908
+ * ```
909
+ */
910
+ injection: Input<string>;
911
+ /**
912
+ * The KeyValueStore to associate with the viewer request function.
913
+ *
914
+ * @example
915
+ * ```js
916
+ * {
917
+ * edge: {
918
+ * viewerRequest: {
919
+ * kvStore: "arn:aws:cloudfront::123456789012:key-value-store/my-store"
920
+ * }
921
+ * }
922
+ * }
923
+ * ```
924
+ */
925
+ kvStore?: Input<string>;
926
+ }>;
927
+ /**
928
+ * Configure the viewer response function.
929
+ *
930
+ * The viewer response function can be used to modify outgoing responses before
931
+ * they are sent to the client. For example, you can add security headers or change
932
+ * the response status code.
933
+ *
934
+ * By default, no viewer response function is set. A new function will be created
935
+ * with the provided code.
936
+ */
937
+ viewerResponse?: Input<{
938
+ /**
939
+ * The code to inject into the viewer response function.
940
+ *
941
+ * ```js
942
+ * async function handler(event) {
943
+ * // User injected code
944
+ *
945
+ * return event.response;
946
+ * }
947
+ * ```
948
+ *
949
+ * @example
950
+ * To add a custom header to all responses.
951
+ *
952
+ * ```js
953
+ * {
954
+ * edge: {
955
+ * viewerResponse: {
956
+ * injection: `event.response.headers["x-foo"] = { value: "bar" };`
957
+ * }
958
+ * }
959
+ * }
960
+ * ```
961
+ */
962
+ injection: Input<string>;
963
+ /**
964
+ * The KeyValueStore to associate with the viewer response function.
965
+ *
966
+ * @example
967
+ * ```js
968
+ * {
969
+ * edge: {
970
+ * viewerResponse: {
971
+ * kvStore: "arn:aws:cloudfront::123456789012:key-value-store/my-store"
972
+ * }
973
+ * }
974
+ * }
975
+ * ```
976
+ */
977
+ kvStore?: Input<string>;
978
+ }>;
979
+ };
980
+ /**
981
+ * Configure how the CloudFront cache invalidations are handled.
982
+ * :::tip
983
+ * You get 1000 free invalidations per month. After that you pay $0.005 per invalidation path. [Read more here](https://aws.amazon.com/cloudfront/pricing/).
984
+ * :::
985
+ * @default Invalidation is turned off
986
+ * @example
987
+ * Setting this to `true` will invalidate all paths. It's equivalent
988
+ * to passing in `{ paths: ["/*"] }`.
989
+ *
990
+ * ```js
991
+ * {
992
+ * invalidation: true
993
+ * }
994
+ * ```
995
+ */
996
+ invalidation?: Input<
997
+ | boolean
998
+ | {
999
+ /**
1000
+ * Configure if `sst deploy` should wait for the CloudFront cache invalidation to finish.
1001
+ *
1002
+ * :::tip
1003
+ * For non-prod environments it might make sense to pass in `false`.
1004
+ * :::
1005
+ *
1006
+ * Waiting for this process to finish ensures that new content will be available after the deploy finishes. However, this process can sometimes take more than 5 mins.
1007
+ * @default `false`
1008
+ * @example
1009
+ * ```js
1010
+ * {
1011
+ * invalidation: {
1012
+ * wait: true
1013
+ * }
1014
+ * }
1015
+ * ```
1016
+ */
1017
+ wait?: Input<boolean>;
1018
+ /**
1019
+ * A token used to determine if the cache should be invalidated. If the
1020
+ * token is the same as the previous deployment, the cache will not be invalidated.
1021
+ *
1022
+ * You can set this to a hash that's computed on every deploy. So if the hash
1023
+ * changes, the cache will be invalidated.
1024
+ *
1025
+ * @default A unique value is auto-generated on each deploy
1026
+ * @example
1027
+ * ```js
1028
+ * {
1029
+ * invalidation: {
1030
+ * token: "foo123"
1031
+ * }
1032
+ * }
1033
+ * ```
1034
+ */
1035
+ token?: Input<string>;
1036
+ /**
1037
+ * Specify an array of glob pattern of paths to invalidate.
1038
+ *
1039
+ * :::note
1040
+ * Each glob pattern counts as a single invalidation. Whereas, invalidating
1041
+ * `/*` counts as a single invalidation.
1042
+ * :::
1043
+ * @default `["/*"]`
1044
+ * @example
1045
+ * Invalidate the `index.html` and all files under the `products/` route.
1046
+ * ```js
1047
+ * {
1048
+ * invalidation: {
1049
+ * paths: ["/index.html", "/products/*"]
1050
+ * }
1051
+ * }
1052
+ * ```
1053
+ * This counts as two invalidations.
1054
+ */
1055
+ paths?: Input<Input<string>[]>;
1056
+ }
1057
+ >;
1058
+
1059
+ /**
1060
+ * Configure Lambda function URL protection through CloudFront Origin Access Control.
1061
+ *
1062
+ * When set, all Functions and SSR sites routing through this Router automatically
1063
+ * inherit the protection mode.
1064
+ *
1065
+ * @default `"none"`
1066
+ *
1067
+ * The available options are:
1068
+ * - `"none"`: Lambda URLs are publicly accessible.
1069
+ * - `"oac"`: Lambda URLs protected by CloudFront Origin Access Control. Requires
1070
+ * manual `x-amz-content-sha256` header for POST requests.
1071
+ * - `"oac-with-edge-signing"`: Full protection with automatic header signing via
1072
+ * Lambda@Edge. Works with external webhooks and callbacks. Higher cost and latency
1073
+ * but works out of the box.
1074
+ *
1075
+ * :::note
1076
+ * Switching from `"none"` to `"oac"` or `"oac-with-edge-signing"` may cause brief
1077
+ * 403 errors (~10-60s) during deployment while CloudFront edge nodes pick up the new
1078
+ * signing configuration. For zero-disruption upgrades, set `protection` when first
1079
+ * creating the Router.
1080
+ * :::
1081
+ *
1082
+ * :::note
1083
+ * When using `"oac-with-edge-signing"`, request bodies are limited to 1MB due to
1084
+ * Lambda@Edge payload limits. For file uploads larger than 1MB, consider using
1085
+ * presigned S3 URLs or the `"oac"` mode with manual header signing.
1086
+ * :::
1087
+ *
1088
+ * :::note
1089
+ * When removing a stage that uses `"oac-with-edge-signing"`, deletion may take
1090
+ * 5-10 minutes while AWS removes the Lambda@Edge replicated functions from all
1091
+ * edge locations.
1092
+ * :::
1093
+ *
1094
+ * @example
1095
+ * ```js
1096
+ * {
1097
+ * protection: "oac"
1098
+ * }
1099
+ * ```
1100
+ *
1101
+ * @example
1102
+ * ```js
1103
+ * {
1104
+ * protection: "oac-with-edge-signing"
1105
+ * }
1106
+ * ```
1107
+ *
1108
+ * @example
1109
+ * ```js
1110
+ * // Custom Lambda@Edge configuration
1111
+ * {
1112
+ * protection: {
1113
+ * mode: "oac-with-edge-signing",
1114
+ * edgeFunction: {
1115
+ * memory: "256 MB",
1116
+ * timeout: "10 seconds"
1117
+ * }
1118
+ * }
1119
+ * }
1120
+ * ```
1121
+ */
1122
+ protection?: Input<
1123
+ | "none"
1124
+ | "oac"
1125
+ | "oac-with-edge-signing"
1126
+ | {
1127
+ mode: "oac-with-edge-signing";
1128
+ edgeFunction?: {
1129
+ /**
1130
+ * Custom Lambda@Edge function ARN to use for request signing.
1131
+ * If provided, this function will be used instead of creating a new one.
1132
+ * Must be a qualified ARN (with version) and deployed in us-east-1.
1133
+ */
1134
+ arn?: Input<FunctionArn>;
1135
+ /**
1136
+ * Memory size for the auto-created Lambda@Edge function.
1137
+ * Only used when arn is not provided.
1138
+ * @default `"128 MB"`
1139
+ */
1140
+ memory?: Input<Size>;
1141
+ /**
1142
+ * Timeout for the auto-created Lambda@Edge function.
1143
+ * Only used when arn is not provided.
1144
+ * @default `"5 seconds"`
1145
+ */
1146
+ timeout?: Input<DurationSeconds>;
1147
+ };
1148
+ }
1149
+ >;
1150
+ /**
1151
+ * Enable AWS WAF (Web Application Firewall) to protect your Router from common
1152
+ * web exploits and bots.
1153
+ *
1154
+ * :::tip
1155
+ * WAF provides protection against SQL injection, cross-site scripting (XSS),
1156
+ * and other common attacks.
1157
+ * :::
1158
+ *
1159
+ * @default WAF is disabled
1160
+ * @example
1161
+ *
1162
+ * Enable with sensible defaults.
1163
+ *
1164
+ * ```js
1165
+ * {
1166
+ * waf: true
1167
+ * }
1168
+ * ```
1169
+ *
1170
+ * Or customize the configuration.
1171
+ *
1172
+ * ```js
1173
+ * {
1174
+ * waf: {
1175
+ * rateLimitPerIp: 1000,
1176
+ * managedRules: {
1177
+ * coreRuleSet: true,
1178
+ * knownBadInputs: true,
1179
+ * sqlInjection: true
1180
+ * }
1181
+ * }
1182
+ * }
1183
+ * ```
1184
+ */
1185
+ waf?: Input<boolean | WafArgs>;
1186
+ /**
1187
+ * [Transform](/docs/components#transform) how this component creates its underlying
1188
+ * resources.
1189
+ */
1190
+ transform?: {
1191
+ /**
1192
+ * Transform the Cache Policy that's attached to each CloudFront behavior.
1193
+ */
1194
+ cachePolicy?: Transform<cloudfront.CachePolicyArgs>;
1195
+ /**
1196
+ * Transform the CloudFront CDN resource.
1197
+ */
1198
+ cdn?: Transform<CdnArgs>;
1199
+ /**
1200
+ * Transform the WAF WebACL resource.
1201
+ */
1202
+ waf?: Transform<wafv2.WebAclArgs>;
1203
+ /**
1204
+ * Transform the CloudWatch LogGroup resource used for WAF logs.
1205
+ */
1206
+ wafLogGroup?: Transform<cloudwatch.LogGroupArgs>;
1207
+ /**
1208
+ * Transform the WAF WebACL logging configuration resource.
1209
+ */
1210
+ wafLogging?: Transform<wafv2.WebAclLoggingConfigurationArgs>;
1211
+ };
1212
+ /**
1213
+ * @internal
1214
+ */
1215
+ _skipHint?: boolean;
1216
+ }
1217
+
1218
+ interface RouterRef {
1219
+ ref: boolean;
1220
+ distributionID: Input<string>;
1221
+ }
1222
+
1223
+ /**
1224
+ * The `Router` component lets you use a CloudFront distribution to direct
1225
+ * requests to various parts of your application like:
1226
+ *
1227
+ * - A URL
1228
+ * - A function
1229
+ * - A frontend
1230
+ * - An S3 bucket
1231
+ *
1232
+ * @example
1233
+ *
1234
+ * #### Minimal example
1235
+ *
1236
+ * ```ts title="sst.config.ts"
1237
+ * new sst.aws.Router("MyRouter");
1238
+ * ```
1239
+ *
1240
+ * #### Add a custom domain
1241
+ *
1242
+ * ```ts {2} title="sst.config.ts"
1243
+ * new sst.aws.Router("MyRouter", {
1244
+ * domain: "myapp.com"
1245
+ * });
1246
+ * ```
1247
+ *
1248
+ * #### Sharing the router across stages
1249
+ *
1250
+ * ```ts title="sst.config.ts"
1251
+ * const router = $app.stage === "production"
1252
+ * ? new sst.aws.Router("MyRouter", {
1253
+ * domain: {
1254
+ * name: "example.com",
1255
+ * aliases: ["*.example.com"]
1256
+ * }
1257
+ * })
1258
+ * : sst.aws.Router.get("MyRouter", "E1XWRGCYGTFB7Z");
1259
+ * ```
1260
+ *
1261
+ * #### Route to a URL
1262
+ *
1263
+ * ```ts title="sst.config.ts" {3}
1264
+ * const router = new sst.aws.Router("MyRouter");
1265
+ *
1266
+ * router.route("/", "https://some-external-service.com");
1267
+ * ```
1268
+ *
1269
+ * #### Route to an S3 bucket
1270
+ *
1271
+ * ```ts title="sst.config.ts" {2,6}
1272
+ * const myBucket = new sst.aws.Bucket("MyBucket", {
1273
+ * access: "cloudfront"
1274
+ * });
1275
+ *
1276
+ * const router = new sst.aws.Router("MyRouter");
1277
+ * router.routeBucket("/files", myBucket);
1278
+ * ```
1279
+ *
1280
+ * You need to allow CloudFront to access the bucket by setting the `access` prop
1281
+ * on the bucket.
1282
+ *
1283
+ * #### Route to a function
1284
+ *
1285
+ * ```ts title="sst.config.ts" {8-11}
1286
+ * const router = new sst.aws.Router("MyRouter", {
1287
+ * domain: "example.com"
1288
+ * });
1289
+ *
1290
+ * const myFunction = new sst.aws.Function("MyFunction", {
1291
+ * handler: "src/api.handler",
1292
+ * url: {
1293
+ * router: {
1294
+ * instance: router,
1295
+ * path: "/api"
1296
+ * }
1297
+ * }
1298
+ * });
1299
+ * ```
1300
+ *
1301
+ * Setting the route through the function, instead of `router.route()` makes
1302
+ * it so that `myFunction.url` gives you the URL based on the Router domain.
1303
+ *
1304
+ * #### Route to a frontend
1305
+ *
1306
+ * ```ts title="sst.config.ts" {4-6}
1307
+ * const router = new sst.aws.Router("MyRouter");
1308
+ *
1309
+ * const mySite = new sst.aws.Nextjs("MyWeb", {
1310
+ * router: {
1311
+ * instance: router
1312
+ * }
1313
+ * });
1314
+ * ```
1315
+ *
1316
+ * Setting the route through the site, instead of `router.route()` makes
1317
+ * it so that `mySite.url` gives you the URL based on the Router domain.
1318
+ *
1319
+ * #### Route to a frontend on a path
1320
+ *
1321
+ * ```ts title="sst.config.ts" {4-7}
1322
+ * const router = new sst.aws.Router("MyRouter");
1323
+ *
1324
+ * new sst.aws.Nextjs("MyWeb", {
1325
+ * router: {
1326
+ * instance: router,
1327
+ * path: "/docs"
1328
+ * }
1329
+ * });
1330
+ * ```
1331
+ *
1332
+ * If you are routing to a path, you'll need to configure the base path in your
1333
+ * frontend app as well. [Learn more](/docs/component/aws/nextjs/#router).
1334
+ *
1335
+ * #### Route to a frontend on a subdomain
1336
+ *
1337
+ * ```ts title="sst.config.ts" {4,9-12}
1338
+ * const router = new sst.aws.Router("MyRouter", {
1339
+ * domain: {
1340
+ * name: "example.com",
1341
+ * aliases: ["*.example.com"]
1342
+ * }
1343
+ * });
1344
+ *
1345
+ * new sst.aws.Nextjs("MyWeb", {
1346
+ * router: {
1347
+ * instance: router,
1348
+ * domain: "docs.example.com"
1349
+ * }
1350
+ * });
1351
+ * ```
1352
+ *
1353
+ * We configure `*.example.com` as an alias so that we can route to a subdomain.
1354
+ *
1355
+ * #### How it works
1356
+ *
1357
+ * This uses a CloudFront KeyValueStore to store the routing data and a CloudFront
1358
+ * function to route the request. As routes are added, the store is updated.
1359
+ *
1360
+ * So when a request comes in, it does a lookup in the store and dynamically sets
1361
+ * the origin based on the routing data. For frontends, that have their server
1362
+ * functions deployed to multiple `regions`, it routes to the closest region based
1363
+ * on the user's location.
1364
+ *
1365
+ * You might notice a _placeholder.sst.dev_ behavior in CloudFront. This is not
1366
+ * used and is only there because CloudFront requires a default behavior.
1367
+ *
1368
+ * #### Limits
1369
+ *
1370
+ * There are some limits on this setup but it's managed by SST.
1371
+ *
1372
+ * - The CloudFront function can be a maximum of 10KB in size. But because all
1373
+ * the route data is stored in the KeyValueStore, the function can be kept small.
1374
+ * - Each value in the KeyValueStore needs to be less than 1KB. This component
1375
+ * splits the routes into multiple values to keep it under the limit.
1376
+ * - The KeyValueStore can be a maximum of 5MB. This is fairly large. But to
1377
+ * handle sites that have a lot of files, only top-level assets get individual
1378
+ * entries. Folders with prerendered routes are the exception: their files get
1379
+ * entries too, up to 1MB per site, so they don't hide server routes.
1380
+ */
1381
+ export class Router extends Component implements Link.Linkable {
1382
+ private constructorName: string;
1383
+ private constructorOpts: ComponentResourceOptions;
1384
+ private cdn: Output<Cdn>;
1385
+ private kvStoreArn?: Output<string>;
1386
+ private kvNamespace?: Output<string>;
1387
+ private hasInlineRoutes: Output<boolean>;
1388
+ private _protectionMode: Output<ProtectionConfig>;
1389
+
1390
+ constructor(
1391
+ name: string,
1392
+ args: RouterArgs = {},
1393
+ opts: ComponentResourceOptions = {},
1394
+ ) {
1395
+ super(__pulumiType, name, args, opts);
1396
+ const _refVersion = 2;
1397
+ const self = this;
1398
+ this.constructorName = name;
1399
+ this.constructorOpts = opts;
1400
+
1401
+ if (args && "ref" in args) {
1402
+ const ref = reference();
1403
+ this.cdn = output(ref.cdn);
1404
+ this.kvStoreArn = ref.kvStoreArn;
1405
+ this.kvNamespace = ref.kvNamespace;
1406
+ this.hasInlineRoutes = ref.hasInlineRoutes;
1407
+ this._protectionMode = ref.protection;
1408
+ registerOutputs();
1409
+ return;
1410
+ }
1411
+
1412
+ const hasInlineRoutes = args.routes !== undefined;
1413
+ const protection = normalizeProtection();
1414
+
1415
+ if (hasInlineRoutes) {
1416
+ protection.apply((p) => {
1417
+ if (p.mode !== "none")
1418
+ throw new VisibleError(
1419
+ `Cannot set "protection" on a Router with inline routes. Use lazy routes instead.`,
1420
+ );
1421
+ });
1422
+ }
1423
+
1424
+ const waf = createWaf();
1425
+ const wafArn = waf?.arn;
1426
+ const wafLogging = normalizeWafLogging();
1427
+ createWafLogging();
1428
+
1429
+ let cdn, kvStoreArn, kvNamespace;
1430
+ if (hasInlineRoutes) {
1431
+ cdn = handleInlineRoutes();
1432
+ } else {
1433
+ const r = handleLazyRoutes();
1434
+ cdn = output(r.distribution);
1435
+ kvStoreArn = r.kvStoreArn;
1436
+ kvNamespace = output(r.kvNamespace);
1437
+ }
1438
+
1439
+ this.cdn = cdn;
1440
+ this.kvStoreArn = kvStoreArn;
1441
+ this.kvNamespace = kvNamespace;
1442
+ this.hasInlineRoutes = output(hasInlineRoutes);
1443
+ this._protectionMode = protection;
1444
+ registerOutputs();
1445
+
1446
+ function reference() {
1447
+ const ref = args as unknown as RouterRef;
1448
+ const cdn = Cdn.get(`${name}Cdn`, ref.distributionID, { parent: self });
1449
+ const tags = cdn.nodes.distribution.tagsAll.apply((tags) => {
1450
+ if (tags?.["sst:ref:version"] !== _refVersion.toString()) {
1451
+ throw new VisibleError(
1452
+ [
1453
+ `There have been some minor changes to the "Router" component that's being referenced by "${name}".\n`,
1454
+ `To update, you'll need to redeploy the stage where the Router was created. And then redeploy this stage.`,
1455
+ ].join("\n"),
1456
+ );
1457
+ }
1458
+
1459
+ return {
1460
+ kvStoreArn: tags?.["sst:ref:kv"],
1461
+ kvNamespace: tags?.["sst:ref:kv-namespace"],
1462
+ hasInlineRoutes: tags?.["sst:ref:kv"] === undefined,
1463
+ protection: tags?.["sst:ref:protection"] ?? "none",
1464
+ };
1465
+ });
1466
+
1467
+ return {
1468
+ cdn,
1469
+ kvStoreArn: tags.kvStoreArn,
1470
+ kvNamespace: tags.kvNamespace,
1471
+ hasInlineRoutes: tags.hasInlineRoutes,
1472
+ protection: tags.protection.apply((p) => ({
1473
+ mode: p as ProtectionConfig["mode"],
1474
+ })),
1475
+ };
1476
+ }
1477
+
1478
+ function createWaf(): wafv2.WebAcl | undefined {
1479
+ if (!args.waf) return undefined;
1480
+
1481
+ const wafInput = output(args.waf);
1482
+ const config = wafInput.apply((waf) =>
1483
+ typeof waf === "boolean" || !waf ? {} : waf,
1484
+ );
1485
+ const rateLimitPerIp = config.apply((c) => c.rateLimitPerIp ?? 2000);
1486
+ const managedRules = config.apply((c) => c.managedRules ?? {});
1487
+ const enableCoreRuleSet = managedRules.apply(
1488
+ (m) => m.coreRuleSet !== false,
1489
+ );
1490
+ const enableKnownBadInputs = managedRules.apply(
1491
+ (m) => m.knownBadInputs !== false,
1492
+ );
1493
+ const enableSqlInjection = managedRules.apply(
1494
+ (m) => m.sqlInjection !== false,
1495
+ );
1496
+
1497
+ // Build rules array dynamically based on config
1498
+ const rules = all([
1499
+ rateLimitPerIp,
1500
+ enableCoreRuleSet,
1501
+ enableKnownBadInputs,
1502
+ enableSqlInjection,
1503
+ ]).apply(([rateLimit, coreRuleSet, knownBadInputs, sqlInjection]) => {
1504
+ const r: wafv2.WebAclArgs["rules"] = [];
1505
+ let priority = 0;
1506
+
1507
+ r.push({
1508
+ name: "RateLimitPerIP",
1509
+ priority: priority++,
1510
+ action: { block: {} },
1511
+ statement: {
1512
+ rateBasedStatement: {
1513
+ limit: rateLimit,
1514
+ aggregateKeyType: "IP",
1515
+ },
1516
+ },
1517
+ visibilityConfig: {
1518
+ cloudwatchMetricsEnabled: true,
1519
+ metricName: `${name}RateLimitPerIP`,
1520
+ sampledRequestsEnabled: true,
1521
+ },
1522
+ });
1523
+
1524
+ if (coreRuleSet) {
1525
+ r.push({
1526
+ name: "AWSManagedRulesCommonRuleSet",
1527
+ priority: priority++,
1528
+ overrideAction: { none: {} },
1529
+ statement: {
1530
+ managedRuleGroupStatement: {
1531
+ vendorName: "AWS",
1532
+ name: "AWSManagedRulesCommonRuleSet",
1533
+ // Set SizeRestrictions_BODY to COUNT to avoid blocking large request bodies
1534
+ ruleActionOverrides: [
1535
+ {
1536
+ name: "SizeRestrictions_BODY",
1537
+ actionToUse: { count: {} },
1538
+ },
1539
+ ],
1540
+ },
1541
+ },
1542
+ visibilityConfig: {
1543
+ cloudwatchMetricsEnabled: true,
1544
+ metricName: `${name}AWSManagedRulesCommonRuleSet`,
1545
+ sampledRequestsEnabled: true,
1546
+ },
1547
+ });
1548
+ }
1549
+
1550
+ if (knownBadInputs) {
1551
+ r.push({
1552
+ name: "AWSManagedRulesKnownBadInputsRuleSet",
1553
+ priority: priority++,
1554
+ overrideAction: { none: {} },
1555
+ statement: {
1556
+ managedRuleGroupStatement: {
1557
+ vendorName: "AWS",
1558
+ name: "AWSManagedRulesKnownBadInputsRuleSet",
1559
+ },
1560
+ },
1561
+ visibilityConfig: {
1562
+ cloudwatchMetricsEnabled: true,
1563
+ metricName: `${name}AWSManagedRulesKnownBadInputsRuleSet`,
1564
+ sampledRequestsEnabled: true,
1565
+ },
1566
+ });
1567
+ }
1568
+
1569
+ if (sqlInjection) {
1570
+ r.push({
1571
+ name: "AWSManagedRulesSQLiRuleSet",
1572
+ priority: priority++,
1573
+ overrideAction: { none: {} },
1574
+ statement: {
1575
+ managedRuleGroupStatement: {
1576
+ vendorName: "AWS",
1577
+ name: "AWSManagedRulesSQLiRuleSet",
1578
+ },
1579
+ },
1580
+ visibilityConfig: {
1581
+ cloudwatchMetricsEnabled: true,
1582
+ metricName: `${name}AWSManagedRulesSQLiRuleSet`,
1583
+ sampledRequestsEnabled: true,
1584
+ },
1585
+ });
1586
+ }
1587
+
1588
+ return r;
1589
+ });
1590
+
1591
+ // WAF must be created in us-east-1 for CloudFront
1592
+ return new wafv2.WebAcl(
1593
+ ...transform(
1594
+ args.transform?.waf,
1595
+ `${name}Waf`,
1596
+ {
1597
+ scope: "CLOUDFRONT",
1598
+ defaultAction: { allow: {} },
1599
+ rules,
1600
+ visibilityConfig: {
1601
+ cloudwatchMetricsEnabled: true,
1602
+ metricName: `${name}Waf`,
1603
+ sampledRequestsEnabled: true,
1604
+ },
1605
+ },
1606
+ { parent: self, provider: useProvider("us-east-1") },
1607
+ ),
1608
+ );
1609
+ }
1610
+
1611
+ function normalizeWafLogging() {
1612
+ return output(args.waf)
1613
+ .apply((waf) => {
1614
+ if (!waf || typeof waf === "boolean") return undefined;
1615
+ return output(waf.logging);
1616
+ })
1617
+ .apply((logging) => {
1618
+ if (!logging) return undefined;
1619
+ const l = (
1620
+ typeof logging === "boolean" ? {} : logging
1621
+ ) as WafLoggingArgs;
1622
+ const defaultRedact = {
1623
+ queryString: true as boolean,
1624
+ headers: ["cookie", "authorization"] as string[],
1625
+ };
1626
+ const redact = l.redact;
1627
+ return {
1628
+ include: (l.include ?? "all") as "all" | "blocked",
1629
+ retention: (l.retention ?? "1 month") as keyof typeof RETENTION,
1630
+ redact:
1631
+ redact === false
1632
+ ? undefined
1633
+ : redact ?? defaultRedact,
1634
+ };
1635
+ });
1636
+ }
1637
+
1638
+ function createWafLogging() {
1639
+ if (!waf) return;
1640
+
1641
+ wafLogging.apply((logging) => {
1642
+ if (!logging) return;
1643
+
1644
+ // CloudWatch Log Group name MUST start with "aws-waf-logs-"
1645
+ const logGroup = new cloudwatch.LogGroup(
1646
+ ...transform(
1647
+ args.transform?.wafLogGroup,
1648
+ `${name}WafLogGroup`,
1649
+ {
1650
+ name: `aws-waf-logs-${physicalName(64, name)}`,
1651
+ retentionInDays: RETENTION[logging.retention],
1652
+ },
1653
+ {
1654
+ parent: self,
1655
+ provider: useProvider("us-east-1"),
1656
+ ignoreChanges: ["name"],
1657
+ },
1658
+ ),
1659
+ );
1660
+
1661
+ const redactedFields = logging.redact
1662
+ ? output(logging.redact).apply((redact) => {
1663
+ if (!redact || typeof redact === "boolean") return [];
1664
+ const fields: wafv2.WebAclLoggingConfigurationArgs["redactedFields"] &
1665
+ {}[] = [];
1666
+ if (redact.method) fields.push({ method: {} });
1667
+ if (redact.queryString) fields.push({ queryString: {} });
1668
+ if (redact.uriPath) fields.push({ uriPath: {} });
1669
+ if (redact.headers) {
1670
+ for (const header of redact.headers) {
1671
+ fields.push({
1672
+ singleHeader: { name: header.toLowerCase() },
1673
+ });
1674
+ }
1675
+ }
1676
+ return fields;
1677
+ })
1678
+ : undefined;
1679
+
1680
+ const loggingFilter =
1681
+ logging.include === "blocked"
1682
+ ? {
1683
+ defaultBehavior: "DROP",
1684
+ filters: [
1685
+ {
1686
+ behavior: "KEEP" as const,
1687
+ requirement: "MEETS_ANY" as const,
1688
+ conditions: [
1689
+ {
1690
+ actionCondition: {
1691
+ action: "BLOCK",
1692
+ },
1693
+ },
1694
+ ],
1695
+ },
1696
+ ],
1697
+ }
1698
+ : undefined;
1699
+
1700
+ new wafv2.WebAclLoggingConfiguration(
1701
+ ...transform(
1702
+ args.transform?.wafLogging,
1703
+ `${name}WafLogging`,
1704
+ {
1705
+ resourceArn: waf!.arn,
1706
+ logDestinationConfigs: [logGroup.arn],
1707
+ ...(redactedFields ? { redactedFields } : {}),
1708
+ ...(loggingFilter ? { loggingFilter } : {}),
1709
+ },
1710
+ {
1711
+ parent: self,
1712
+ provider: useProvider("us-east-1"),
1713
+ },
1714
+ ),
1715
+ );
1716
+ });
1717
+ }
1718
+
1719
+ function registerOutputs() {
1720
+ self.registerOutputs({
1721
+ _hint: args._skipHint ? undefined : self.url,
1722
+ });
1723
+ }
1724
+
1725
+ function normalizeProtection(): Output<ProtectionConfig> {
1726
+ return output(args.protection).apply((protection) => {
1727
+ if (!protection) return { mode: "none" as const };
1728
+
1729
+ if (typeof protection === "string") {
1730
+ return { mode: protection };
1731
+ }
1732
+
1733
+ if (
1734
+ protection.mode === "oac-with-edge-signing" &&
1735
+ protection.edgeFunction?.arn
1736
+ ) {
1737
+ const arn = protection.edgeFunction.arn;
1738
+ if (typeof arn === "string") {
1739
+ parseLambdaEdgeArn(arn);
1740
+ }
1741
+ }
1742
+
1743
+ return protection;
1744
+ });
1745
+ }
1746
+
1747
+ function handleInlineRoutes() {
1748
+ let defaultCachePolicy: cloudfront.CachePolicy;
1749
+ let defaultCfFunction: cloudfront.Function;
1750
+ let defaultOac: OriginAccessControl;
1751
+ const routes = normalizeRoutes();
1752
+ const cdn = createCdn();
1753
+ return cdn;
1754
+
1755
+ function normalizeRoutes() {
1756
+ return output(args.routes!).apply((routes) => {
1757
+ const normalizedRoutes = Object.fromEntries(
1758
+ Object.entries(routes).map(([path, route]) => {
1759
+ // Route path must start with "/"
1760
+ if (!path.startsWith("/"))
1761
+ throw new Error(
1762
+ `In "${name}" Router, the route path "${path}" must start with a "/"`,
1763
+ );
1764
+
1765
+ route = typeof route === "string" ? { url: route } : route;
1766
+
1767
+ const hasUrl = "url" in route ? 1 : 0;
1768
+ const hasBucket = "bucket" in route ? 1 : 0;
1769
+ if (hasUrl + hasBucket !== 1)
1770
+ throw new Error(
1771
+ `In "${name}" Router, the route path "${path}" can only have one of url or bucket`,
1772
+ );
1773
+
1774
+ return [path, route];
1775
+ }),
1776
+ );
1777
+
1778
+ normalizedRoutes["/*"] = normalizedRoutes["/*"] ?? {
1779
+ url: "https://do-not-exist.sst.dev",
1780
+ };
1781
+
1782
+ return normalizedRoutes;
1783
+ });
1784
+ }
1785
+
1786
+ function createCfRequestDefaultFunction() {
1787
+ defaultCfFunction =
1788
+ defaultCfFunction ??
1789
+ new cloudfront.Function(
1790
+ `${name}CloudfrontFunction`,
1791
+ {
1792
+ runtime: "cloudfront-js-2.0",
1793
+ code: [
1794
+ `async function handler(event) {`,
1795
+ ` event.request.headers["x-forwarded-host"] = event.request.headers.host;`,
1796
+ ` return event.request;`,
1797
+ `}`,
1798
+ ].join("\n"),
1799
+ },
1800
+ { parent: self },
1801
+ );
1802
+ return defaultCfFunction;
1803
+ }
1804
+
1805
+ function createCfRequestFunction(
1806
+ path: string,
1807
+ config:
1808
+ | {
1809
+ injection: string;
1810
+ kvStore?: string;
1811
+ kvStores?: string[];
1812
+ }
1813
+ | undefined,
1814
+ rewrite:
1815
+ | {
1816
+ regex: string;
1817
+ to: string;
1818
+ }
1819
+ | undefined,
1820
+ injectHostHeader: boolean,
1821
+ ) {
1822
+ return new cloudfront.Function(
1823
+ `${name}CloudfrontFunction${hashStringToPrettyString(path, 8)}`,
1824
+ {
1825
+ runtime: "cloudfront-js-2.0",
1826
+ keyValueStoreAssociations: config?.kvStore
1827
+ ? [config.kvStore]
1828
+ : config?.kvStores ?? [],
1829
+ code: `
1830
+ async function handler(event) {
1831
+ ${
1832
+ injectHostHeader
1833
+ ? `event.request.headers["x-forwarded-host"] = event.request.headers.host;`
1834
+ : ""
1835
+ }
1836
+ ${
1837
+ rewrite
1838
+ ? `
1839
+ const re = new RegExp("${rewrite.regex}");
1840
+ event.request.uri = event.request.uri.replace(re, "${rewrite.to}");`
1841
+ : ""
1842
+ }
1843
+ ${config?.injection ?? ""}
1844
+ return event.request;
1845
+ }`,
1846
+ },
1847
+ { parent: self },
1848
+ );
1849
+ }
1850
+
1851
+ function createCfResponseFunction(
1852
+ path: string,
1853
+ config: {
1854
+ injection: string;
1855
+ kvStore?: string;
1856
+ kvStores?: string[];
1857
+ },
1858
+ ) {
1859
+ return new cloudfront.Function(
1860
+ `${name}CloudfrontFunctionResponse${hashStringToPrettyString(
1861
+ path,
1862
+ 8,
1863
+ )}`,
1864
+ {
1865
+ runtime: "cloudfront-js-2.0",
1866
+ keyValueStoreAssociations: config.kvStore
1867
+ ? [config.kvStore]
1868
+ : config.kvStores ?? [],
1869
+ code: `
1870
+ async function handler(event) {
1871
+ ${config.injection ?? ""}
1872
+ return event.response;
1873
+ }`,
1874
+ },
1875
+ { parent: self },
1876
+ );
1877
+ }
1878
+
1879
+ function createOriginAccessControl() {
1880
+ defaultOac =
1881
+ defaultOac ??
1882
+ new OriginAccessControl(
1883
+ `${name}S3AccessControl`,
1884
+ { name: physicalName(64, name) },
1885
+ { parent: self, ignoreChanges: ["name"] },
1886
+ );
1887
+ return defaultOac;
1888
+ }
1889
+
1890
+ function createCachePolicy() {
1891
+ defaultCachePolicy =
1892
+ defaultCachePolicy ??
1893
+ new cloudfront.CachePolicy(
1894
+ ...transform(
1895
+ args.transform?.cachePolicy,
1896
+ `${name}CachePolicy`,
1897
+ {
1898
+ comment: `${name} router cache policy`,
1899
+ defaultTtl: 0,
1900
+ maxTtl: 31536000, // 1 year
1901
+ minTtl: 0,
1902
+ parametersInCacheKeyAndForwardedToOrigin: {
1903
+ cookiesConfig: {
1904
+ cookieBehavior: "none",
1905
+ },
1906
+ headersConfig: {
1907
+ headerBehavior: "none",
1908
+ },
1909
+ queryStringsConfig: {
1910
+ queryStringBehavior: "all",
1911
+ },
1912
+ enableAcceptEncodingBrotli: true,
1913
+ enableAcceptEncodingGzip: true,
1914
+ },
1915
+ },
1916
+ { parent: self },
1917
+ ),
1918
+ );
1919
+
1920
+ return defaultCachePolicy;
1921
+ }
1922
+
1923
+ function createCdn() {
1924
+ return routes.apply((routes) => {
1925
+ const distributionData = Object.entries(routes).map(
1926
+ ([path, route]) => {
1927
+ if ("url" in route) {
1928
+ return {
1929
+ origin: {
1930
+ originId: path,
1931
+ domainName: new URL(route.url).host,
1932
+ customOriginConfig: {
1933
+ httpPort: 80,
1934
+ httpsPort: 443,
1935
+ originProtocolPolicy: "https-only",
1936
+ originReadTimeout: 20,
1937
+ originSslProtocols: ["TLSv1.2"],
1938
+ },
1939
+ },
1940
+ behavior: {
1941
+ pathPattern: path,
1942
+ targetOriginId: path,
1943
+ functionAssociations: [
1944
+ {
1945
+ eventType: "viewer-request",
1946
+ functionArn:
1947
+ route.edge?.viewerRequest || route.rewrite
1948
+ ? createCfRequestFunction(
1949
+ path,
1950
+ route.edge?.viewerRequest,
1951
+ route.rewrite,
1952
+ true,
1953
+ ).arn
1954
+ : createCfRequestDefaultFunction().arn,
1955
+ },
1956
+ ...(route.edge?.viewerResponse
1957
+ ? [
1958
+ {
1959
+ eventType: "viewer-response",
1960
+ functionArn: createCfResponseFunction(
1961
+ path,
1962
+ route.edge.viewerResponse,
1963
+ ).arn,
1964
+ },
1965
+ ]
1966
+ : []),
1967
+ ],
1968
+ viewerProtocolPolicy: "redirect-to-https",
1969
+ allowedMethods: [
1970
+ "DELETE",
1971
+ "GET",
1972
+ "HEAD",
1973
+ "OPTIONS",
1974
+ "PATCH",
1975
+ "POST",
1976
+ "PUT",
1977
+ ],
1978
+ cachedMethods: ["GET", "HEAD"],
1979
+ defaultTtl: 0,
1980
+ compress: true,
1981
+ cachePolicyId: route.cachePolicy ?? createCachePolicy().id,
1982
+ // CloudFront's Managed-AllViewerExceptHostHeader policy
1983
+ originRequestPolicyId:
1984
+ "b689b0a8-53d0-40ab-baf2-68738e2966ac",
1985
+ },
1986
+ };
1987
+ } else if ("bucket" in route) {
1988
+ return {
1989
+ origin: {
1990
+ originId: path,
1991
+ domainName:
1992
+ route.bucket instanceof Bucket
1993
+ ? route.bucket.nodes.bucket.bucketRegionalDomainName
1994
+ : route.bucket!,
1995
+ originPath: "",
1996
+ originAccessControlId: createOriginAccessControl().id,
1997
+ },
1998
+ behavior: {
1999
+ pathPattern: path,
2000
+ targetOriginId: path,
2001
+ functionAssociations: [
2002
+ ...(route.edge?.viewerRequest || route.rewrite
2003
+ ? [
2004
+ {
2005
+ eventType: "viewer-request",
2006
+ functionArn:
2007
+ route.edge?.viewerRequest || route.rewrite
2008
+ ? createCfRequestFunction(
2009
+ path,
2010
+ route.edge?.viewerRequest,
2011
+ route.rewrite,
2012
+ false,
2013
+ ).arn
2014
+ : createCfRequestDefaultFunction().arn,
2015
+ },
2016
+ ]
2017
+ : []),
2018
+ ...(route.edge?.viewerResponse
2019
+ ? [
2020
+ {
2021
+ eventType: "viewer-response",
2022
+ functionArn: createCfResponseFunction(
2023
+ path,
2024
+ route.edge.viewerResponse,
2025
+ ).arn,
2026
+ },
2027
+ ]
2028
+ : []),
2029
+ ],
2030
+ viewerProtocolPolicy: "redirect-to-https",
2031
+ allowedMethods: ["GET", "HEAD", "OPTIONS"],
2032
+ cachedMethods: ["GET", "HEAD"],
2033
+ compress: true,
2034
+ // CloudFront's managed CachingOptimized policy
2035
+ cachePolicyId:
2036
+ route.cachePolicy ??
2037
+ "658327ea-f89d-4fab-a63d-7e88639e58f6",
2038
+ },
2039
+ };
2040
+ }
2041
+ throw new Error("Invalid route type");
2042
+ },
2043
+ );
2044
+
2045
+ return new Cdn(
2046
+ ...transform(
2047
+ args.transform?.cdn,
2048
+ `${name}Cdn`,
2049
+ {
2050
+ comment: `${name} router`,
2051
+ origins: distributionData.map((d) => d.origin),
2052
+ defaultCacheBehavior: {
2053
+ ...distributionData.find(
2054
+ (d) => d.behavior.pathPattern === "/*",
2055
+ )!.behavior,
2056
+ // @ts-expect-error
2057
+ pathPattern: undefined,
2058
+ },
2059
+ orderedCacheBehaviors: distributionData
2060
+ .filter((d) => d.behavior.pathPattern !== "/*")
2061
+ .map((d) => d.behavior),
2062
+ domain: args.domain,
2063
+ wait: true,
2064
+ webAclArn: wafArn,
2065
+ },
2066
+ { parent: self },
2067
+ ),
2068
+ );
2069
+ });
2070
+ }
2071
+ }
2072
+
2073
+ function handleLazyRoutes() {
2074
+ const kvNamespace = buildRequestKvNamespace();
2075
+ const kvStoreArn = createRequestKvStore();
2076
+ const requestFunction = createRequestFunction();
2077
+ const responseFunction = createResponseFunction();
2078
+ const cachePolicyId = createCachePolicy().id;
2079
+ const edgeFunction = createLambdaEdgeFunction();
2080
+ const distribution = createDistribution();
2081
+
2082
+ return { kvNamespace, kvStoreArn, distribution };
2083
+
2084
+ function buildRequestKvNamespace() {
2085
+ // In the case multiple routers use the same kv store, we need to namespace the keys
2086
+ return crypto
2087
+ .createHash("md5")
2088
+ .update(`${$app.name}-${$app.stage}-${name}`)
2089
+ .digest("hex")
2090
+ .substring(0, 4);
2091
+ }
2092
+
2093
+ function createRequestKvStore() {
2094
+ return output(args.edge).apply((edge) => {
2095
+ const viewerRequest = edge?.viewerRequest;
2096
+ const userKvStore = viewerRequest?.kvStore;
2097
+ if (userKvStore) return output(userKvStore);
2098
+
2099
+ return new cloudfront.KeyValueStore(
2100
+ `${name}KvStore`,
2101
+ {},
2102
+ { parent: self },
2103
+ ).arn;
2104
+ });
2105
+ }
2106
+
2107
+ function createCachePolicy() {
2108
+ return new cloudfront.CachePolicy(
2109
+ ...transform(
2110
+ args.transform?.cachePolicy,
2111
+ `${name}ServerCachePolicy`,
2112
+ {
2113
+ comment: "SST server response cache policy",
2114
+ defaultTtl: 0,
2115
+ maxTtl: 31536000, // 1 year
2116
+ minTtl: 0,
2117
+ parametersInCacheKeyAndForwardedToOrigin: {
2118
+ cookiesConfig: {
2119
+ cookieBehavior: "none",
2120
+ },
2121
+ headersConfig: {
2122
+ headerBehavior: "whitelist",
2123
+ headers: {
2124
+ items: ["x-open-next-cache-key", "x-forwarded-host"],
2125
+ },
2126
+ },
2127
+ queryStringsConfig: {
2128
+ queryStringBehavior: "all",
2129
+ },
2130
+ enableAcceptEncodingBrotli: true,
2131
+ enableAcceptEncodingGzip: true,
2132
+ },
2133
+ },
2134
+ { parent: self },
2135
+ ),
2136
+ );
2137
+ }
2138
+
2139
+ function createRequestFunction() {
2140
+ return output(args.edge).apply((edge) => {
2141
+ const userInjection = edge?.viewerRequest?.injection ?? "";
2142
+ const blockCloudfrontUrlInjection = args.domain
2143
+ ? CF_BLOCK_CLOUDFRONT_URL_INJECTION
2144
+ : "";
2145
+ return new cloudfront.Function(
2146
+ `${name}CloudfrontFunctionRequest`,
2147
+ {
2148
+ runtime: "cloudfront-js-2.0",
2149
+ keyValueStoreAssociations: kvStoreArn ? [kvStoreArn] : [],
2150
+ code: interpolate`
2151
+ import cf from "cloudfront";
2152
+ async function handler(event) {
2153
+ ${userInjection}
2154
+ ${blockCloudfrontUrlInjection}
2155
+ ${CF_ROUTER_INJECTION}
2156
+
2157
+ async function getRoutes() {
2158
+ const routerNS = "${kvNamespace}";
2159
+ let routes = [];
2160
+ try {
2161
+ const v = await cf.kvs().get(routerNS + ":routes");
2162
+ routes = JSON.parse(v);
2163
+
2164
+ // handle chunked routes
2165
+ if (routes.parts) {
2166
+ const chunkPromises = [];
2167
+ for (let i = 0; i < routes.parts; i++) {
2168
+ chunkPromises.push(cf.kvs().get(routerNS + ":routes:" + i));
2169
+ }
2170
+ const chunks = await Promise.all(chunkPromises);
2171
+ routes = JSON.parse(chunks.join(""));
2172
+ }
2173
+ } catch (e) {}
2174
+ return routes;
2175
+ }
2176
+
2177
+ async function matchRoute(routes) {
2178
+ const requestHost = event.request.headers.host.value;
2179
+ const requestHostWithEscapedDots = requestHost.replace(/\\./g, "\\\\.");
2180
+ const requestHostRegexPattern = "^" + requestHost + "$";
2181
+ let match;
2182
+ routes.forEach(r => {
2183
+ ${
2184
+ /*
2185
+ Route format: [type, routeNamespace, hostRegex, pathPrefix]
2186
+ - First sort by host pattern (longest first)
2187
+ - Then sort by path prefix (longest first)
2188
+ */ ""
2189
+ }
2190
+ var parts = r.split(",");
2191
+ const type = parts[0];
2192
+ const routeNs = parts[1];
2193
+ const host = parts[2];
2194
+ const hostLength = host.length;
2195
+ const path = parts[3];
2196
+ const pathLength = path.length;
2197
+
2198
+ // Do not consider if the current match is a better winner
2199
+ if (match && (
2200
+ hostLength < match.hostLength
2201
+ || (hostLength === match.hostLength && pathLength < match.pathLength)
2202
+ )) return;
2203
+
2204
+ const hostMatches = host === ""
2205
+ || host === requestHostWithEscapedDots
2206
+ || (host.includes("*") && new RegExp(host).test(requestHostRegexPattern));
2207
+ if (!hostMatches) return;
2208
+
2209
+ const pathMatches = event.request.uri.startsWith(path) && (event.request.uri === path || path.endsWith('/') || event.request.uri[path.length] === '/' || path === '/');
2210
+ if (!pathMatches) return;
2211
+
2212
+ match = {
2213
+ type,
2214
+ routeNs,
2215
+ host,
2216
+ hostLength,
2217
+ path,
2218
+ pathLength,
2219
+ };
2220
+ });
2221
+
2222
+ // Load metadata
2223
+ if (match) {
2224
+ try {
2225
+ const type = match.type;
2226
+ const routeNs = match.routeNs;
2227
+ const v = await cf.kvs().get(routeNs + ":metadata");
2228
+ return { type, routeNs, metadata: JSON.parse(v) };
2229
+ } catch (e) {}
2230
+ }
2231
+ }
2232
+
2233
+ // Look up the route
2234
+ const routes = await getRoutes();
2235
+ const route = await matchRoute(routes);
2236
+ if (!route) return event.request;
2237
+ if (route.metadata.rewrite) {
2238
+ const rw = route.metadata.rewrite;
2239
+ event.request.uri = event.request.uri.replace(new RegExp(rw.regex), rw.to);
2240
+ }
2241
+ if (route.type === "url") setUrlOrigin(route.metadata.host, route.metadata.origin);
2242
+ if (route.type === "bucket") setS3Origin(route.metadata.domain, route.metadata.origin);
2243
+ if (route.type === "site") {
2244
+ const response = await routeSite(route.routeNs, route.metadata);
2245
+ return response || event.request;
2246
+ }
2247
+ return event.request;
2248
+ }`,
2249
+ },
2250
+ { parent: self },
2251
+ );
2252
+ });
2253
+ }
2254
+
2255
+ function createResponseFunction() {
2256
+ return output(args.edge).apply((edge) => {
2257
+ const userConfig = edge?.viewerResponse;
2258
+ const userInjection = userConfig?.injection;
2259
+ const kvStoreArn = userConfig?.kvStore;
2260
+
2261
+ if (!userInjection) return;
2262
+
2263
+ return new cloudfront.Function(
2264
+ `${name}CloudfrontFunctionResponse`,
2265
+ {
2266
+ runtime: "cloudfront-js-2.0",
2267
+ keyValueStoreAssociations: kvStoreArn ? [kvStoreArn] : [],
2268
+ code: `
2269
+ import cf from "cloudfront";
2270
+ async function handler(event) {
2271
+ ${userInjection}
2272
+ return event.response;
2273
+ }`,
2274
+ },
2275
+ { parent: self },
2276
+ );
2277
+ });
2278
+ }
2279
+
2280
+ function createLambdaEdgeFunction() {
2281
+ return protection.apply((protectionConfig) => {
2282
+ if (
2283
+ protectionConfig.mode !== "oac-with-edge-signing" ||
2284
+ protectionConfig.edgeFunction?.arn
2285
+ ) {
2286
+ return undefined;
2287
+ }
2288
+
2289
+ const edgeConfig = protectionConfig.edgeFunction;
2290
+ const memory = edgeConfig?.memory ? toMBs(edgeConfig.memory) : 128;
2291
+ const timeout = edgeConfig?.timeout
2292
+ ? toSeconds(edgeConfig.timeout)
2293
+ : 5;
2294
+
2295
+ const edgeRole = new iam.Role(
2296
+ ...transform(
2297
+ undefined,
2298
+ `${name}EdgeFunctionRole`,
2299
+ {
2300
+ name: physicalName(64, `${name}EdgeRole`),
2301
+ assumeRolePolicy: JSON.stringify({
2302
+ Version: "2012-10-17",
2303
+ Statement: [
2304
+ {
2305
+ Action: "sts:AssumeRole",
2306
+ Effect: "Allow",
2307
+ Principal: {
2308
+ Service: [
2309
+ "lambda.amazonaws.com",
2310
+ "edgelambda.amazonaws.com",
2311
+ ],
2312
+ },
2313
+ },
2314
+ ],
2315
+ }),
2316
+ managedPolicyArns: [
2317
+ "arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
2318
+ ],
2319
+ },
2320
+ { parent: self, ignoreChanges: ["name"] },
2321
+ ),
2322
+ );
2323
+
2324
+ const edgeFn = new lambda.Function(
2325
+ ...transform(
2326
+ undefined,
2327
+ `${name}EdgeFunction`,
2328
+ {
2329
+ name: physicalName(64, `${name}EdgeFn`),
2330
+ runtime: "nodejs24.x",
2331
+ handler: "index.handler",
2332
+ role: edgeRole.arn,
2333
+ code: new asset.FileArchive(
2334
+ path.join($cli.paths.platform, "dist", "oac-edge-signer"),
2335
+ ),
2336
+ publish: true,
2337
+ timeout: timeout,
2338
+ memorySize: memory,
2339
+ description: `${name} Lambda@Edge function for OAC request signing`,
2340
+ },
2341
+ {
2342
+ parent: self,
2343
+ provider: useProvider("us-east-1"),
2344
+ ignoreChanges: ["name"],
2345
+ },
2346
+ ),
2347
+ );
2348
+
2349
+ return edgeFn;
2350
+ });
2351
+ }
2352
+
2353
+ function createDistribution() {
2354
+ return new Cdn(
2355
+ ...transform(
2356
+ args.transform?.cdn,
2357
+ `${name}Cdn`,
2358
+ {
2359
+ comment: `${name} app`,
2360
+ domain: args.domain,
2361
+ origins: [
2362
+ {
2363
+ originId: "default",
2364
+ domainName: "placeholder.sst.dev",
2365
+ customOriginConfig: {
2366
+ httpPort: 80,
2367
+ httpsPort: 443,
2368
+ originProtocolPolicy: "http-only",
2369
+ originReadTimeout: 20,
2370
+ originSslProtocols: ["TLSv1.2"],
2371
+ },
2372
+ },
2373
+ ],
2374
+ defaultCacheBehavior: {
2375
+ targetOriginId: "default",
2376
+ viewerProtocolPolicy: "redirect-to-https",
2377
+ allowedMethods: [
2378
+ "DELETE",
2379
+ "GET",
2380
+ "HEAD",
2381
+ "OPTIONS",
2382
+ "PATCH",
2383
+ "POST",
2384
+ "PUT",
2385
+ ],
2386
+ cachedMethods: ["GET", "HEAD"],
2387
+ compress: true,
2388
+ cachePolicyId,
2389
+ // CloudFront's Managed-AllViewerExceptHostHeader policy
2390
+ originRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
2391
+ functionAssociations: all([
2392
+ requestFunction,
2393
+ responseFunction,
2394
+ ]).apply(([reqFn, resFn]) => [
2395
+ { eventType: "viewer-request", functionArn: reqFn.arn },
2396
+ ...(resFn
2397
+ ? [{ eventType: "viewer-response", functionArn: resFn.arn }]
2398
+ : []),
2399
+ ]),
2400
+ lambdaFunctionAssociations: all([
2401
+ protection,
2402
+ edgeFunction,
2403
+ ]).apply(([protectionConfig, autoEdgeFunction]) => {
2404
+ if (protectionConfig.mode !== "oac-with-edge-signing") {
2405
+ return [];
2406
+ }
2407
+
2408
+ if (protectionConfig.edgeFunction?.arn) {
2409
+ return [
2410
+ {
2411
+ eventType: "origin-request",
2412
+ lambdaArn: protectionConfig.edgeFunction.arn,
2413
+ includeBody: true,
2414
+ },
2415
+ ];
2416
+ }
2417
+
2418
+ if (autoEdgeFunction) {
2419
+ return [
2420
+ {
2421
+ eventType: "origin-request",
2422
+ lambdaArn: autoEdgeFunction.qualifiedArn,
2423
+ includeBody: true,
2424
+ },
2425
+ ];
2426
+ }
2427
+
2428
+ return [];
2429
+ }),
2430
+ },
2431
+ tags: {
2432
+ "sst:ref:kv": kvStoreArn,
2433
+ "sst:ref:kv-namespace": kvNamespace,
2434
+ "sst:ref:version": _refVersion.toString(),
2435
+ "sst:ref:protection": protection.apply((p) => p.mode),
2436
+ },
2437
+ webAclArn: wafArn,
2438
+ },
2439
+ { parent: self },
2440
+ ),
2441
+ );
2442
+ }
2443
+ }
2444
+ }
2445
+
2446
+ /**
2447
+ * The ID of the Router distribution.
2448
+ */
2449
+ public get distributionID() {
2450
+ return this.cdn.nodes.distribution.id;
2451
+ }
2452
+
2453
+ /**
2454
+ * The URL of the Router.
2455
+ *
2456
+ * If the `domain` is set, this is the URL with the custom domain.
2457
+ * Otherwise, it's the auto-generated CloudFront URL.
2458
+ */
2459
+ public get url() {
2460
+ return all([this.cdn.domainUrl, this.cdn.url]).apply(
2461
+ ([domainUrl, url]) => domainUrl ?? url,
2462
+ );
2463
+ }
2464
+
2465
+ /** @internal */
2466
+ public get _kvStoreArn() {
2467
+ return this.kvStoreArn;
2468
+ }
2469
+
2470
+ /** @internal */
2471
+ public get _kvNamespace() {
2472
+ return this.kvNamespace;
2473
+ }
2474
+
2475
+ /** @internal */
2476
+ public get _hasInlineRoutes() {
2477
+ return this.hasInlineRoutes;
2478
+ }
2479
+
2480
+ /** @internal */
2481
+ public get _protection() {
2482
+ return this._protectionMode;
2483
+ }
2484
+
2485
+ /** @internal */
2486
+ public get _distributionArn() {
2487
+ return this.cdn.apply((cdn) => cdn.nodes.distribution.arn);
2488
+ }
2489
+
2490
+ /**
2491
+ * The underlying [resources](/docs/components/#nodes) this component creates.
2492
+ */
2493
+ public get nodes() {
2494
+ return {
2495
+ /**
2496
+ * The Amazon CloudFront CDN resource.
2497
+ */
2498
+ cdn: this.cdn,
2499
+ };
2500
+ }
2501
+
2502
+ /**
2503
+ * Add a route to a destination URL.
2504
+ *
2505
+ * @param pattern The path prefix to match for this route.
2506
+ * @param url The destination URL to route matching requests to.
2507
+ * @param args Configure the route.
2508
+ *
2509
+ * @example
2510
+ *
2511
+ * You can match a route based on:
2512
+ *
2513
+ * - A path prefix like `/api`
2514
+ * - A domain pattern like `api.example.com`
2515
+ * - A combined pattern like `dev.example.com/api`
2516
+ *
2517
+ * For example, to match a path prefix.
2518
+ *
2519
+ * ```ts title="sst.config.ts"
2520
+ * router.route("/api", "https://api.example.com");
2521
+ * ```
2522
+ *
2523
+ * Or match a domain.
2524
+ *
2525
+ * ```ts title="sst.config.ts"
2526
+ * router.route("api.myapp.com/", "https://api.example.com");
2527
+ * ```
2528
+ *
2529
+ * Or a combined pattern.
2530
+ *
2531
+ * ```ts title="sst.config.ts"
2532
+ * router.route("dev.myapp.com/api", "https://api.example.com");
2533
+ * ```
2534
+ *
2535
+ * You can also rewrite the request path.
2536
+ *
2537
+ * ```ts title="sst.config.ts"
2538
+ * router.route("/api", "https://api.example.com", {
2539
+ * rewrite: {
2540
+ * regex: "^/api/(.*)$",
2541
+ * to: "/$1"
2542
+ * }
2543
+ * });
2544
+ * ```
2545
+ *
2546
+ * Here something like `/api/users/profile` will be routed to
2547
+ * `https://api.example.com/users/profile`.
2548
+ */
2549
+ public route(
2550
+ pattern: Input<string>,
2551
+ url: Input<string>,
2552
+ args?: Input<RouterUrlRouteArgs>,
2553
+ ) {
2554
+ all([pattern, args, this.hasInlineRoutes]).apply(
2555
+ ([pattern, args, hasInlineRoutes]) => {
2556
+ if (hasInlineRoutes)
2557
+ throw new VisibleError(
2558
+ "Cannot use both `routes` and `.route()` function to add routes.",
2559
+ );
2560
+
2561
+ new RouterUrlRoute(
2562
+ `${this.constructorName}Route${pattern}`,
2563
+ {
2564
+ store: this.kvStoreArn!,
2565
+ routerNamespace: this.kvNamespace!,
2566
+ pattern,
2567
+ url,
2568
+ routeArgs: args,
2569
+ },
2570
+ { provider: this.constructorOpts.provider },
2571
+ );
2572
+ },
2573
+ );
2574
+ }
2575
+
2576
+ /**
2577
+ * Add a route to an S3 bucket.
2578
+ *
2579
+ * @param pattern The path prefix to match for this route.
2580
+ * @param bucket The S3 bucket to route matching requests to.
2581
+ * @param args Configure the route.
2582
+ *
2583
+ * @example
2584
+ *
2585
+ * Let's say you have an S3 bucket that gives CloudFront `access`.
2586
+ *
2587
+ * ```ts title="sst.config.ts" {2}
2588
+ * const bucket = new sst.aws.Bucket("MyBucket", {
2589
+ * access: "cloudfront"
2590
+ * });
2591
+ * ```
2592
+ *
2593
+ * You can match a pattern and route to it based on:
2594
+ *
2595
+ * - A path prefix like `/api`
2596
+ * - A domain pattern like `api.example.com`
2597
+ * - A combined pattern like `dev.example.com/api`
2598
+ *
2599
+ * For example, to match a path prefix.
2600
+ *
2601
+ * ```ts title="sst.config.ts"
2602
+ * router.routeBucket("/files", bucket);
2603
+ * ```
2604
+ *
2605
+ * Or match a domain.
2606
+ *
2607
+ * ```ts title="sst.config.ts"
2608
+ * router.routeBucket("files.example.com", bucket);
2609
+ * ```
2610
+ *
2611
+ * Or a combined pattern.
2612
+ *
2613
+ * ```ts title="sst.config.ts"
2614
+ * router.routeBucket("dev.example.com/files", bucket);
2615
+ * ```
2616
+ *
2617
+ * You can also rewrite the request path.
2618
+ *
2619
+ * ```ts title="sst.config.ts"
2620
+ * router.routeBucket("/files", bucket, {
2621
+ * rewrite: {
2622
+ * regex: "^/files/(.*)$",
2623
+ * to: "/$1"
2624
+ * }
2625
+ * });
2626
+ * ```
2627
+ *
2628
+ * Here something like `/files/logo.png` will be routed to
2629
+ * `/logo.png`.
2630
+ */
2631
+ public routeBucket(
2632
+ pattern: Input<string>,
2633
+ bucket: Input<Bucket>,
2634
+ args?: Input<RouterBucketRouteArgs>,
2635
+ ) {
2636
+ all([pattern, args, this.hasInlineRoutes]).apply(
2637
+ ([pattern, args, hasInlineRoutes]) => {
2638
+ if (hasInlineRoutes)
2639
+ throw new VisibleError(
2640
+ "Cannot use both `routes` and `.routeBucket()` function to add routes.",
2641
+ );
2642
+
2643
+ new RouterBucketRoute(
2644
+ `${this.constructorName}Route${pattern}`,
2645
+ {
2646
+ store: this.kvStoreArn!,
2647
+ routerNamespace: this.kvNamespace!,
2648
+ pattern,
2649
+ bucket,
2650
+ routeArgs: args,
2651
+ },
2652
+ { provider: this.constructorOpts.provider },
2653
+ );
2654
+ },
2655
+ );
2656
+ }
2657
+
2658
+ /**
2659
+ * Add a route to a frontend or static site.
2660
+ *
2661
+ * @param pattern The path prefix to match for this route.
2662
+ * @param site The frontend or static site to route matching requests to.
2663
+ *
2664
+ * @deprecated The `routeSite` function has been deprecated. Set the `route` on the
2665
+ * site components to route the site through this Router.
2666
+ */
2667
+ public routeSite(pattern: Input<string>, site: any) {
2668
+ throw new VisibleError(
2669
+ `The "routeSite" function has been deprecated. Configure the new "route" prop on the site component to route the site through this Router.`,
2670
+ );
2671
+ }
2672
+
2673
+ /** @internal */
2674
+ public getSSTLink() {
2675
+ return {
2676
+ properties: {
2677
+ url: this.url,
2678
+ },
2679
+ };
2680
+ }
2681
+
2682
+ /**
2683
+ * Reference an existing Router with the given Router distribution ID.
2684
+ *
2685
+ * @param name The name of the component.
2686
+ * @param distributionID The ID of the existing Router distribution.
2687
+ * @param opts Resource options.
2688
+ *
2689
+ * This is useful when you create a Router in one stage and want to share it in
2690
+ * another. It avoids having to create a new Router in the other stage.
2691
+ *
2692
+ * :::tip
2693
+ * You can use the `static get` method to share a Router across stages.
2694
+ * :::
2695
+ *
2696
+ * @example
2697
+ * Let's say you create a Router in the `dev` stage. And in your personal stage
2698
+ * `frank`, you want to share the same Router.
2699
+ *
2700
+ * ```ts title="sst.config.ts"
2701
+ * const router = $app.stage === "frank"
2702
+ * ? sst.aws.Router.get("MyRouter", "E2IDLMESRN6V62")
2703
+ * : new sst.aws.Router("MyRouter");
2704
+ * ```
2705
+ *
2706
+ * Here `E2IDLMESRN6V62` is the ID of the Router distribution created in the
2707
+ * `dev` stage. You can find this by outputting the distribution ID in the `dev`
2708
+ * stage.
2709
+ *
2710
+ * ```ts title="sst.config.ts"
2711
+ * return {
2712
+ * router: router.distributionID
2713
+ * };
2714
+ * ```
2715
+ *
2716
+ * Learn more about [how to configure a router for your app](/docs/configure-a-router).
2717
+ */
2718
+ public static get(
2719
+ name: string,
2720
+ distributionID: Input<string>,
2721
+ opts?: ComponentResourceOptions,
2722
+ ) {
2723
+ return new Router(
2724
+ name,
2725
+ {
2726
+ ref: true,
2727
+ distributionID: distributionID,
2728
+ } as unknown as RouterArgs,
2729
+ opts,
2730
+ );
2731
+ }
2732
+ }
2733
+
2734
+ const __pulumiType = "sst:aws:Router";
2735
+ // @ts-expect-error
2736
+ Router.__pulumiType = __pulumiType;
2737
+
2738
+ // CloudFront Functions have a 10KB limit on the forwarded request size.
2739
+ // We reserve 512 bytes for origin-request overhead CloudFront can still add after
2740
+ // this viewer-request function runs, so borderline requests fail with a clear 431.
2741
+ const CLOUDFRONT_FUNCTION_SAFE_HEADER_LIMIT = 10240 - 512;
2742
+
2743
+ export const CF_BLOCK_CLOUDFRONT_URL_INJECTION = `
2744
+ if (event.request.headers.host.value.includes('cloudfront.net')) {
2745
+ return {
2746
+ statusCode: 403,
2747
+ statusDescription: 'Forbidden',
2748
+ body: {
2749
+ encoding: "text",
2750
+ data: '<html><head><title>403 Forbidden</title></head><body><center><h1>403 Forbidden</h1></center></body></html>'
2751
+ }
2752
+ };
2753
+ }`;
2754
+
2755
+ // CloudFront Function handler code injected into site and router CF functions.
2756
+ // NOTE: This string is size-sensitive — CloudFront Functions have a 10KB limit.
2757
+ // NOTE: `s3Key` is the S3 key of a file: the folder, the path prefix the files were
2758
+ // uploaded under (`s3.prefix`), then the uri without the site's base path. Without
2759
+ // `s3.prefix` (metadata from an older version) it is the folder and the whole uri.
2760
+ // The base is only taken off the start of the uri, and only at a segment boundary
2761
+ // (`/admin` is not taken off `/administrator`), so don't go back to `replace`. The base
2762
+ // never has a trailing slash (the route's path prefix is normalized in this file, and an
2763
+ // SSR site's base in `ssr-site.ts`), so `base + "/"` is safe.
2764
+ // `s3Key` takes everything as arguments: reading `baselessUri` from `routeSite` fails with
2765
+ // "cannot access variable before initialization" in the CloudFront function runtime.
2766
+ // The custom 404 and the "unmatched" branches below still use the old key.
2767
+ export const CF_ROUTER_INJECTION = minify`
2768
+ async function routeSite(kvNamespace, metadata) {
2769
+ const baselessUri = metadata.base && (event.request.uri === metadata.base || event.request.uri.startsWith(metadata.base + "/"))
2770
+ ? event.request.uri.slice(metadata.base.length)
2771
+ : event.request.uri;
2772
+
2773
+ function s3Key(metadata, uri, baselessUri) {
2774
+ return metadata.s3.dir + (metadata.s3.prefix === undefined ? uri : metadata.s3.prefix + baselessUri);
2775
+ }
2776
+
2777
+ // Route to S3 files
2778
+ try {
2779
+ // check using baselessUri b/c files are stored in the root
2780
+ const u = decodeURIComponent(baselessUri);
2781
+ const postfixes = u.endsWith("/")
2782
+ ? ["index.html"]
2783
+ : ["", ".html", "/index.html"];
2784
+ const v = await Promise.any(postfixes.map(p => cf.kvs().get(kvNamespace + ":" + u + p).then(v => p)));
2785
+ // files are stored in a subdirectory, add it to the request uri
2786
+ event.request.uri = s3Key(metadata, event.request.uri, baselessUri) + v;
2787
+ setS3Origin(metadata.s3.domain);
2788
+ return;
2789
+ } catch (e) {}
2790
+
2791
+ // Route to S3 routes
2792
+ if (metadata.s3 && metadata.s3.routes) {
2793
+ for (var i=0, l=metadata.s3.routes.length; i<l; i++) {
2794
+ const route = metadata.s3.routes[i];
2795
+ if (baselessUri.startsWith(route)) {
2796
+ event.request.uri = s3Key(metadata, event.request.uri, baselessUri);
2797
+ // uri ends with /, ie. /usage/ -> /usage/index.html
2798
+ if (event.request.uri.endsWith("/")) {
2799
+ event.request.uri += "index.html";
2800
+ }
2801
+ // uri ends with non-file, ie. /usage -> /usage/index.html
2802
+ else if (!event.request.uri.split("/").pop().includes(".")) {
2803
+ event.request.uri += "/index.html";
2804
+ }
2805
+ setS3Origin(metadata.s3.domain);
2806
+ return;
2807
+ }
2808
+ }
2809
+ }
2810
+
2811
+ // Route to S3 custom 404 (SPA fallback, no servers)
2812
+ if (metadata.custom404 && !metadata.errorResponseCode) {
2813
+ event.request.uri = metadata.s3.dir + (metadata.base ? metadata.base : "") + metadata.custom404;
2814
+ setS3Origin(metadata.s3.domain);
2815
+ return;
2816
+ }
2817
+
2818
+ // Route unmatched to S3 (triggers customErrorResponses)
2819
+ if (metadata.s3 && !metadata.servers) {
2820
+ event.request.uri = metadata.s3.dir + event.request.uri;
2821
+ setS3Origin(metadata.s3.domain);
2822
+ return;
2823
+ }
2824
+
2825
+ // Route to image optimizer
2826
+ if (metadata.image && baselessUri.startsWith(metadata.image.route)) {
2827
+ setForwardedHost();
2828
+ setNextjsCacheKey();
2829
+ if (isRequestHeaderTooLarge()) return buildOversizedHeadersResponse();
2830
+ setUrlOrigin(metadata.image.host, metadata.image.originAccessControlConfig ? { originAccessControlConfig: metadata.image.originAccessControlConfig } : undefined);
2831
+ return;
2832
+ }
2833
+
2834
+ // Route to servers
2835
+ if (metadata.servers){
2836
+ setForwardedHost();
2837
+ // In SvelteKit, form action requests contain "/" in request query string
2838
+ // ie. POST request with query string "?/action"
2839
+ // CloudFront does not allow query string with "/". It needs to be encoded.
2840
+ for (var key in event.request.querystring) {
2841
+ if (key.includes("/")) {
2842
+ event.request.querystring[encodeURIComponent(key)] = event.request.querystring[key];
2843
+ delete event.request.querystring[key];
2844
+ }
2845
+ }
2846
+ setNextjsGeoHeaders();
2847
+ setNextjsCacheKey();
2848
+ if (isRequestHeaderTooLarge()) return buildOversizedHeadersResponse();
2849
+ setUrlOrigin(findNearestServer(metadata.servers), metadata.origin);
2850
+ }
2851
+
2852
+ // Inject the CloudFront viewer country, region, latitude, and longitude headers into
2853
+ // the request headers for OpenNext to use them
2854
+ function setNextjsGeoHeaders() {
2855
+ var keys = ["city","country","region","latitude","longitude"];
2856
+ for (var i=0; i<keys.length; i++) {
2857
+ if (event.request.headers["cloudfront-viewer-" + keys[i]])
2858
+ event.request.headers["x-open-next-" + keys[i]] = event.request.headers["cloudfront-viewer-" + keys[i]];
2859
+ }
2860
+ }
2861
+
2862
+ // This function is used to improve cache hit ratio by setting the cache key
2863
+ // based on the request headers and the path. next/image only needs the
2864
+ // accept header, and this header is not useful for the rest of the query
2865
+ function setNextjsCacheKey() {
2866
+ var cacheKey = "";
2867
+ if (event.request.uri.startsWith("/_next/image")) {
2868
+ cacheKey = getHeader("accept");
2869
+ } else {
2870
+ var headers = ["rsc","next-router-prefetch","next-router-state-tree","next-url","x-prerender-revalidate"];
2871
+ for (var i=0; i<headers.length; i++) cacheKey += getHeader(headers[i]);
2872
+ }
2873
+ if (event.request.cookies["__prerender_bypass"]) {
2874
+ cacheKey += event.request.cookies["__prerender_bypass"]
2875
+ ? event.request.cookies["__prerender_bypass"].value
2876
+ : "";
2877
+ }
2878
+ var crypto = require("crypto");
2879
+ var hashedKey = crypto.createHash("md5").update(cacheKey).digest("hex");
2880
+ event.request.headers["x-open-next-cache-key"] = { value: hashedKey };
2881
+ }
2882
+
2883
+ function getHeader(key) {
2884
+ var header = event.request.headers[key];
2885
+ if (header) {
2886
+ if (header.multiValue) {
2887
+ return header.multiValue.map((header) => header.value).join(",");
2888
+ }
2889
+ if (header.value) {
2890
+ return header.value;
2891
+ }
2892
+ }
2893
+ return "";
2894
+ }
2895
+
2896
+ function isRequestHeaderTooLarge() {
2897
+ return getRequestHeaderSize() > ${CLOUDFRONT_FUNCTION_SAFE_HEADER_LIMIT};
2898
+ }
2899
+
2900
+ function buildOversizedHeadersResponse() {
2901
+ return {
2902
+ statusCode: 431,
2903
+ statusDescription: "Request Header Fields Too Large",
2904
+ headers: {
2905
+ "cache-control": { value: "no-store" },
2906
+ "content-type": { value: "text/plain; charset=utf-8" },
2907
+ },
2908
+ body: {
2909
+ encoding: "text",
2910
+ data: "Request headers are too large. Reduce cookie size and try again.",
2911
+ },
2912
+ };
2913
+ }
2914
+
2915
+ function getRequestHeaderSize() {
2916
+ var size = 0;
2917
+
2918
+ for (var key in event.request.headers) {
2919
+ var header = event.request.headers[key];
2920
+ if (header.multiValue) {
2921
+ for (var i=0; i<header.multiValue.length; i++) {
2922
+ size += key.length + header.multiValue[i].value.length + 4;
2923
+ }
2924
+ } else if (header.value) {
2925
+ size += key.length + header.value.length + 4;
2926
+ }
2927
+ }
2928
+
2929
+ var cookies = [];
2930
+ for (var key in event.request.cookies) {
2931
+ var cookie = event.request.cookies[key];
2932
+ if (cookie.multiValue) {
2933
+ for (var i=0; i<cookie.multiValue.length; i++) {
2934
+ cookies.push(key + "=" + cookie.multiValue[i].value);
2935
+ }
2936
+ } else {
2937
+ cookies.push(key + "=" + cookie.value);
2938
+ }
2939
+ }
2940
+
2941
+ if (cookies.length) {
2942
+ size += 10 + cookies.join("; ").length;
2943
+ }
2944
+
2945
+ return size;
2946
+ }
2947
+
2948
+ function findNearestServer(servers) {
2949
+ if (servers.length === 1) return servers[0][0];
2950
+
2951
+ const h = event.request.headers;
2952
+ const lat = h["cloudfront-viewer-latitude"] && h["cloudfront-viewer-latitude"].value;
2953
+ const lon = h["cloudfront-viewer-longitude"] && h["cloudfront-viewer-longitude"].value;
2954
+ if (!lat || !lon) return servers[0][0];
2955
+
2956
+ return servers
2957
+ .map((s) => ({
2958
+ distance: haversineDistance(lat, lon, s[1], s[2]),
2959
+ host: s[0],
2960
+ }))
2961
+ .sort((a, b) => a.distance - b.distance)[0]
2962
+ .host;
2963
+ }
2964
+
2965
+ function haversineDistance(lat1, lon1, lat2, lon2) {
2966
+ const toRad = angle => angle * Math.PI / 180;
2967
+ const radLat1 = toRad(lat1);
2968
+ const radLat2 = toRad(lat2);
2969
+ const dLat = toRad(lat2 - lat1);
2970
+ const dLon = toRad(lon2 - lon1);
2971
+ const a = Math.sin(dLat / 2) ** 2 + Math.cos(radLat1) * Math.cos(radLat2) * Math.sin(dLon / 2) ** 2;
2972
+ return 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
2973
+ }
2974
+ }
2975
+
2976
+ function setForwardedHost() {
2977
+ // Lambda URLs expect the original viewer host in x-forwarded-host.
2978
+ event.request.headers["x-forwarded-host"] = event.request.headers.host;
2979
+ }
2980
+
2981
+ function setUrlOrigin(urlHost, override) {
2982
+ setForwardedHost();
2983
+ const origin = {
2984
+ domainName: urlHost,
2985
+ customOriginConfig: {
2986
+ port: 443,
2987
+ protocol: "https",
2988
+ sslProtocols: ["TLSv1.2"],
2989
+ },
2990
+ originAccessControlConfig: {
2991
+ enabled: false,
2992
+ }
2993
+ };
2994
+ override = override ?? {};
2995
+ if (override.protocol === "http") {
2996
+ delete origin.customOriginConfig;
2997
+ }
2998
+ if (override.connectionAttempts) {
2999
+ origin.connectionAttempts = override.connectionAttempts;
3000
+ }
3001
+ if (override.timeouts) {
3002
+ origin.timeouts = override.timeouts;
3003
+ }
3004
+ if (override.originAccessControlConfig) {
3005
+ origin.originAccessControlConfig = override.originAccessControlConfig;
3006
+ }
3007
+ cf.updateRequestOrigin(origin);
3008
+ }
3009
+
3010
+ function setS3Origin(s3Domain, override) {
3011
+ delete event.request.headers["Cookies"];
3012
+ delete event.request.headers["cookies"];
3013
+ delete event.request.cookies;
3014
+
3015
+ const origin = {
3016
+ domainName: s3Domain,
3017
+ originAccessControlConfig: {
3018
+ enabled: true,
3019
+ signingBehavior: "always",
3020
+ signingProtocol: "sigv4",
3021
+ originType: "s3",
3022
+ }
3023
+ };
3024
+ override = override ?? {};
3025
+ if (override.connectionAttempts) {
3026
+ origin.connectionAttempts = override.connectionAttempts;
3027
+ }
3028
+ if (override.timeouts) {
3029
+ origin.timeouts = override.timeouts;
3030
+ }
3031
+ cf.updateRequestOrigin(origin);
3032
+ }`;
3033
+
3034
+ export type KV_SITE_METADATA = {
3035
+ base?: string; // Undefined or "" if no base path. Otherwise starts with "/" and never ends with one (so never "/"): the router strips it with `base + "/"`.
3036
+ custom404?: string;
3037
+ errorResponseCode?: number;
3038
+ s3: {
3039
+ domain: string;
3040
+ dir: string; // Should be "" if no dir
3041
+ prefix?: string; // The path prefix the files are stored under, "" if none. Missing in metadata from older versions.
3042
+ routes: string[];
3043
+ };
3044
+ image?: {
3045
+ host: string;
3046
+ route: string;
3047
+ originAccessControlConfig?: {
3048
+ enabled: boolean;
3049
+ signingBehavior: string;
3050
+ signingProtocol: string;
3051
+ originType: string;
3052
+ };
3053
+ };
3054
+ servers?: [string, number, number][];
3055
+ origin?: {
3056
+ timeouts: {
3057
+ readTimeout: number;
3058
+ };
3059
+ originAccessControlConfig?: {
3060
+ enabled: boolean;
3061
+ signingBehavior: string;
3062
+ signingProtocol: string;
3063
+ originType: string;
3064
+ };
3065
+ };
3066
+ };
3067
+
3068
+ export type ProtectionConfig = {
3069
+ mode: "none" | "oac" | "oac-with-edge-signing";
3070
+ edgeFunction?: {
3071
+ arn?: string;
3072
+ memory?: Size;
3073
+ timeout?: DurationSeconds;
3074
+ };
3075
+ };
3076
+
3077
+ export type RouterRouteArgs = {
3078
+ /**
3079
+ * The `Router` component to use for routing requests.
3080
+ *
3081
+ * @example
3082
+ *
3083
+ * Let's say you have a Router component.
3084
+ *
3085
+ * ```ts title="sst.config.ts"
3086
+ * const router = new sst.aws.Router("MyRouter", {
3087
+ * domain: "example.com"
3088
+ * });
3089
+ * ```
3090
+ *
3091
+ * You can attach it to the Router, instead of creating a standalone CloudFront
3092
+ * distribution.
3093
+ *
3094
+ * ```ts
3095
+ * router: {
3096
+ * instance: router
3097
+ * }
3098
+ * ```
3099
+ */
3100
+ instance: Input<Router>;
3101
+ /**
3102
+ * Route requests matching a specific domain pattern.
3103
+ *
3104
+ * @example
3105
+ *
3106
+ * You can serve your resource from a subdomain. For example, if you want to make
3107
+ * it available at `https://dev.example.com`, set the `Router` to match the
3108
+ * domain or a wildcard.
3109
+ *
3110
+ * ```ts {2} title="sst.config.ts"
3111
+ * const router = new sst.aws.Router("MyRouter", {
3112
+ * domain: "*.example.com"
3113
+ * });
3114
+ * ```
3115
+ *
3116
+ * Then set the domain pattern.
3117
+ *
3118
+ * ```ts {3}
3119
+ * router: {
3120
+ * instance: router,
3121
+ * domain: "dev.example.com"
3122
+ * }
3123
+ * ```
3124
+ *
3125
+ * While `dev.example.com` matches `*.example.com`. Something like
3126
+ * `docs.dev.example.com` will not match `*.example.com`.
3127
+ *
3128
+ * :::tip
3129
+ * Nested wildcards domain patterns are not supported.
3130
+ * :::
3131
+ *
3132
+ * You'll need to add `*.dev.example.com` as an alias.
3133
+ */
3134
+ domain?: Input<string>;
3135
+ /**
3136
+ * Route requests matching a specific path prefix.
3137
+ *
3138
+ * @default `"/"`
3139
+ *
3140
+ * @example
3141
+ *
3142
+ * ```ts {3}
3143
+ * router: {
3144
+ * instance: router,
3145
+ * path: "/docs"
3146
+ * }
3147
+ * ```
3148
+ */
3149
+ path?: Input<string>;
3150
+ /**
3151
+ * Rewrite the request path.
3152
+ *
3153
+ * @example
3154
+ *
3155
+ * If the route path is `/api/*` and a request comes in for `/api/users/profile`,
3156
+ * the request path the destination sees is `/api/users/profile`.
3157
+ *
3158
+ * If you want to serve the route from the root, you can rewrite the request
3159
+ * path to `/users/profile`.
3160
+ *
3161
+ * ```js
3162
+ * router: {
3163
+ * instance: router,
3164
+ * path: "/api",
3165
+ * rewrite: {
3166
+ * regex: "^/api/(.*)$",
3167
+ * to: "/$1"
3168
+ * }
3169
+ * }
3170
+ * ```
3171
+ */
3172
+ rewrite?: Input<{
3173
+ /**
3174
+ * The regex to match the request path.
3175
+ */
3176
+ regex: Input<string>;
3177
+ /**
3178
+ * The replacement for the matched path.
3179
+ */
3180
+ to: Input<string>;
3181
+ }>;
3182
+ /**
3183
+ * The number of seconds that CloudFront waits for a response after routing a
3184
+ * request to the destination. Must be between 1 and 60 seconds.
3185
+ *
3186
+ * When compared to the `connectionTimeout`, this is the total time for the
3187
+ * request.
3188
+ *
3189
+ * @default `"20 seconds"`
3190
+ * @example
3191
+ * ```js
3192
+ * router: {
3193
+ * instance: router,
3194
+ * readTimeout: "60 seconds"
3195
+ * }
3196
+ * ```
3197
+ */
3198
+ readTimeout?: Input<DurationSeconds>;
3199
+ /**
3200
+ * The number of seconds that CloudFront should try to maintain the connection
3201
+ * to the destination after receiving the last packet of the response. Must be
3202
+ * between 1 and 60 seconds.
3203
+ *
3204
+ * @default `"5 seconds"`
3205
+ * @example
3206
+ * ```js
3207
+ * router: {
3208
+ * instance: router,
3209
+ * keepAliveTimeout: "10 seconds"
3210
+ * }
3211
+ * ```
3212
+ */
3213
+ keepAliveTimeout?: Input<DurationSeconds>;
3214
+ /**
3215
+ * The number of seconds that CloudFront waits before timing out and closing the
3216
+ * connection to the origin. Must be between 1 and 10 seconds.
3217
+ *
3218
+ * @default `"10 seconds"`
3219
+ * @example
3220
+ * ```js
3221
+ * router: {
3222
+ * instance: router,
3223
+ * connectionTimeout: "3 seconds"
3224
+ * }
3225
+ * ```
3226
+ */
3227
+ connectionTimeout?: Input<DurationSeconds>;
3228
+ /**
3229
+ * The number of times that CloudFront attempts to connect to the origin. Must be
3230
+ * between 1 and 3.
3231
+ *
3232
+ * @default `3`
3233
+ * @example
3234
+ * ```js
3235
+ * router: {
3236
+ * instance: router,
3237
+ * connectionAttempts: 1
3238
+ * }
3239
+ * ```
3240
+ */
3241
+ connectionAttempts?: Input<number>;
3242
+ };
3243
+
3244
+ export type RouterRouteArgsDeprecated = {
3245
+ router: Input<Router>;
3246
+ domain?: Input<string>;
3247
+ path?: Input<string>;
3248
+ };
3249
+
3250
+ export function normalizeRouteArgs(
3251
+ route?: Input<RouterRouteArgs>,
3252
+ routeDeprecated?: Input<RouterRouteArgsDeprecated>,
3253
+ ) {
3254
+ if (!route && !routeDeprecated) return undefined;
3255
+
3256
+ return all([route, routeDeprecated]).apply(([route, routeDeprecated]) => {
3257
+ const v = route
3258
+ ? route
3259
+ : { ...routeDeprecated, instance: routeDeprecated!.router };
3260
+
3261
+ return v.instance._hasInlineRoutes.apply((hasInlineRoutes) => {
3262
+ if (hasInlineRoutes)
3263
+ throw new VisibleError(
3264
+ "Cannot route the site using the provided router. The Router component uses inline routes which has been deprecated.",
3265
+ );
3266
+
3267
+ const pathPrefix = v.path
3268
+ ? "/" + v.path.replace(/^\//, "").replace(/\/$/, "")
3269
+ : undefined;
3270
+ return {
3271
+ hostPattern: v.domain
3272
+ ? v.domain
3273
+ .replace(/[.+?^${}()|[\]\\]/g, "\\$&") // Escape special regex chars
3274
+ .replace(/\*/g, ".*") // Replace * with .*
3275
+ : undefined,
3276
+ pathPrefix,
3277
+ routerDistributionId: v.instance.nodes.cdn.nodes.distribution.id,
3278
+ routerUrl: v.instance.url.apply(
3279
+ (url) =>
3280
+ (v.domain ? `https://${v.domain}` : url) + (pathPrefix ?? ""),
3281
+ ),
3282
+ routerKvNamespace: v.instance._kvNamespace!,
3283
+ routerKvStoreArn: v.instance._kvStoreArn!,
3284
+ routerProtection: v.instance._protection,
3285
+ routerDistributionArn: v.instance._distributionArn,
3286
+ rewrite: v.rewrite,
3287
+ readTimeout: v.readTimeout,
3288
+ keepAliveTimeout: v.keepAliveTimeout,
3289
+ connectionTimeout: v.connectionTimeout,
3290
+ connectionAttempts: v.connectionAttempts,
3291
+ };
3292
+ });
3293
+ });
3294
+ }