sst 1.16.0 → 2.0.0-rc.0

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 (518) hide show
  1. package/LICENSE +21 -0
  2. package/{dist/app.d.ts → app.d.ts} +8 -1
  3. package/app.js +122 -0
  4. package/{dist/bootstrap.d.ts → bootstrap.d.ts} +1 -0
  5. package/bootstrap.js +79 -0
  6. package/{dist/bus.d.ts → bus.d.ts} +0 -0
  7. package/{dist/bus.js → bus.js} +0 -0
  8. package/{dist/cache.d.ts → cache.d.ts} +0 -0
  9. package/{dist/cache.js → cache.js} +0 -0
  10. package/{dist/cdk → cdk}/cloudformation-deployments.d.ts +1 -1
  11. package/{dist/cdk → cdk}/cloudformation-deployments.js +1 -0
  12. package/{dist/cdk → cdk}/deploy-stack.d.ts +0 -0
  13. package/{dist/cdk → cdk}/deploy-stack.js +13 -6
  14. package/{dist/cli → cli}/commands/bind.d.ts +3 -1
  15. package/{dist/cli → cli}/commands/bind.js +8 -4
  16. package/{dist/cli → cli}/commands/build.d.ts +2 -0
  17. package/cli/commands/build.js +12 -0
  18. package/cli/commands/console.d.ts +9 -0
  19. package/cli/commands/console.js +15 -0
  20. package/{dist/cli → cli}/commands/deploy.d.ts +7 -1
  21. package/cli/commands/deploy.js +48 -0
  22. package/cli/commands/dev.d.ts +11 -0
  23. package/cli/commands/dev.js +188 -0
  24. package/cli/commands/env.d.ts +11 -0
  25. package/cli/commands/env.js +39 -0
  26. package/cli/commands/plugins/kysely.d.ts +1 -0
  27. package/cli/commands/plugins/kysely.js +91 -0
  28. package/cli/commands/plugins/pothos.d.ts +1 -0
  29. package/cli/commands/plugins/pothos.js +52 -0
  30. package/cli/commands/plugins/warmer.d.ts +1 -0
  31. package/cli/commands/plugins/warmer.js +33 -0
  32. package/cli/commands/remove.d.ts +13 -0
  33. package/cli/commands/remove.js +39 -0
  34. package/{dist/cli → cli}/commands/secrets/get.d.ts +2 -0
  35. package/{dist/cli → cli}/commands/secrets/get.js +0 -0
  36. package/{dist/cli → cli}/commands/secrets/list.d.ts +2 -0
  37. package/{dist/cli → cli}/commands/secrets/list.js +5 -5
  38. package/{dist/cli → cli}/commands/secrets/remove.d.ts +2 -0
  39. package/{dist/cli → cli}/commands/secrets/remove.js +0 -0
  40. package/{dist/cli → cli}/commands/secrets/secrets.d.ts +0 -0
  41. package/{dist/cli → cli}/commands/secrets/secrets.js +0 -0
  42. package/{dist/cli → cli}/commands/secrets/set.d.ts +2 -0
  43. package/{dist/cli → cli}/commands/secrets/set.js +13 -11
  44. package/{dist/cli → cli}/commands/update.d.ts +2 -0
  45. package/{dist/cli → cli}/commands/update.js +17 -21
  46. package/cli/local/router.d.ts +42 -0
  47. package/cli/local/router.js +43 -0
  48. package/cli/local/server.d.ts +20 -0
  49. package/cli/local/server.js +212 -0
  50. package/cli/program.d.ts +9 -0
  51. package/{dist/cli → cli}/program.js +6 -1
  52. package/{dist/cli → cli}/spinner.d.ts +0 -0
  53. package/{dist/cli → cli}/spinner.js +0 -0
  54. package/cli/sst.d.ts +2 -0
  55. package/{dist/cli → cli}/sst.js +27 -16
  56. package/cli/telemetry/environment.d.ts +15 -0
  57. package/cli/telemetry/environment.js +27 -0
  58. package/cli/telemetry/post-payload.d.ts +1 -0
  59. package/cli/telemetry/post-payload.js +18 -0
  60. package/cli/telemetry/project-id.d.ts +2 -0
  61. package/cli/telemetry/project-id.js +47 -0
  62. package/cli/telemetry/telemetry.d.ts +4 -0
  63. package/cli/telemetry/telemetry.js +90 -0
  64. package/cli/ui/deploy.d.ts +8 -0
  65. package/{dist/cli → cli}/ui/deploy.js +39 -1
  66. package/{dist/config.d.ts → config.d.ts} +0 -0
  67. package/{dist/config.js → config.js} +16 -4
  68. package/{dist/constructs → constructs}/Api.d.ts +98 -12
  69. package/{dist/constructs → constructs}/Api.js +93 -7
  70. package/{dist/constructs → constructs}/ApiGatewayV1Api.d.ts +0 -0
  71. package/{dist/constructs → constructs}/ApiGatewayV1Api.js +10 -5
  72. package/{dist/constructs → constructs}/App.d.ts +4 -26
  73. package/{dist/constructs → constructs}/App.js +119 -99
  74. package/{dist/constructs → constructs}/AppSyncApi.d.ts +3 -3
  75. package/{dist/constructs → constructs}/AppSyncApi.js +27 -20
  76. package/constructs/AstroSite.d.ts +25 -0
  77. package/constructs/AstroSite.js +111 -0
  78. package/constructs/AstroSite.tsdoc.d.ts +2 -0
  79. package/constructs/AstroSite.tsdoc.js +2 -0
  80. package/{dist/constructs → constructs}/Auth.d.ts +1 -1
  81. package/{dist/constructs → constructs}/Auth.js +6 -4
  82. package/{dist/constructs → constructs}/BaseSite.d.ts +0 -0
  83. package/{dist/constructs → constructs}/BaseSite.js +0 -0
  84. package/{dist/constructs → constructs}/Bucket.d.ts +0 -0
  85. package/{dist/constructs → constructs}/Bucket.js +6 -3
  86. package/{dist/constructs → constructs}/Cognito.d.ts +0 -0
  87. package/{dist/constructs → constructs}/Cognito.js +4 -1
  88. package/{dist/constructs → constructs}/Config.d.ts +0 -0
  89. package/{dist/constructs → constructs}/Config.js +0 -0
  90. package/{dist/constructs → constructs}/Construct.d.ts +0 -0
  91. package/{dist/constructs → constructs}/Construct.js +0 -0
  92. package/{dist/constructs → constructs}/Cron.d.ts +0 -0
  93. package/{dist/constructs → constructs}/Cron.js +7 -0
  94. package/{dist/constructs → constructs}/DebugApp.d.ts +2 -2
  95. package/{dist/constructs → constructs}/DebugApp.js +16 -0
  96. package/{dist/constructs → constructs}/DebugStack.d.ts +0 -0
  97. package/{dist/constructs → constructs}/DebugStack.js +4 -0
  98. package/{dist/constructs → constructs}/EdgeFunction.d.ts +1 -0
  99. package/{dist/constructs → constructs}/EdgeFunction.js +27 -22
  100. package/{dist/constructs → constructs}/EventBus.d.ts +0 -0
  101. package/{dist/constructs → constructs}/EventBus.js +7 -4
  102. package/{dist/constructs → constructs}/Function.d.ts +73 -174
  103. package/{dist/constructs → constructs}/Function.js +43 -83
  104. package/{dist/constructs → constructs}/FunctionalStack.d.ts +0 -0
  105. package/{dist/constructs → constructs}/FunctionalStack.js +5 -5
  106. package/{dist/constructs → constructs}/GraphQLApi.d.ts +11 -1
  107. package/{dist/constructs → constructs}/GraphQLApi.js +3 -0
  108. package/{dist/constructs → constructs}/Job.d.ts +0 -14
  109. package/{dist/constructs → constructs}/Job.js +50 -46
  110. package/{dist/constructs → constructs}/KinesisStream.d.ts +0 -0
  111. package/{dist/constructs → constructs}/KinesisStream.js +6 -3
  112. package/{dist/constructs → constructs}/Metadata.d.ts +1 -1
  113. package/{dist/constructs → constructs}/Metadata.js +0 -0
  114. package/constructs/NextjsSite.d.ts +33 -0
  115. package/constructs/NextjsSite.js +285 -0
  116. package/{dist/constructs → constructs}/Parameter.d.ts +0 -0
  117. package/{dist/constructs → constructs}/Parameter.js +3 -0
  118. package/{dist/constructs → constructs}/Queue.d.ts +0 -0
  119. package/{dist/constructs → constructs}/Queue.js +19 -12
  120. package/{dist/constructs → constructs}/RDS.d.ts +0 -0
  121. package/{dist/constructs → constructs}/RDS.js +26 -19
  122. package/{dist/constructs → constructs}/ReactStaticSite.d.ts +0 -0
  123. package/{dist/constructs → constructs}/ReactStaticSite.js +1 -1
  124. package/constructs/RemixSite.d.ts +28 -0
  125. package/constructs/RemixSite.js +150 -0
  126. package/constructs/RemixSite.tsdoc.d.ts +2 -0
  127. package/constructs/RemixSite.tsdoc.js +2 -0
  128. package/{dist/constructs → constructs}/Script/cfn-response.d.ts +0 -0
  129. package/{dist/constructs → constructs}/Script/cfn-response.js +0 -0
  130. package/{dist/constructs → constructs}/Script/index.d.ts +0 -0
  131. package/{dist/constructs → constructs}/Script/index.js +0 -0
  132. package/{dist/constructs → constructs}/Script/outbound.d.ts +1 -1
  133. package/{dist/constructs → constructs}/Script/outbound.js +0 -0
  134. package/{dist/constructs → constructs}/Script/util.d.ts +0 -0
  135. package/{dist/constructs → constructs}/Script/util.js +0 -0
  136. package/{dist/constructs → constructs}/Script.d.ts +0 -0
  137. package/{dist/constructs → constructs}/Script.js +13 -0
  138. package/{dist/constructs → constructs}/Secret.d.ts +0 -0
  139. package/{dist/constructs → constructs}/Secret.js +2 -0
  140. package/constructs/SolidStartSite.d.ts +24 -0
  141. package/constructs/SolidStartSite.js +103 -0
  142. package/constructs/SolidStartSite.tsdoc.d.ts +2 -0
  143. package/constructs/SolidStartSite.tsdoc.js +2 -0
  144. package/{dist/constructs/RemixSite.d.ts → constructs/SsrSite.d.ts} +69 -107
  145. package/{dist/constructs/RemixSite.js → constructs/SsrSite.js} +243 -446
  146. package/{dist/constructs → constructs}/Stack.d.ts +1 -1
  147. package/{dist/constructs → constructs}/Stack.js +19 -4
  148. package/{dist/constructs → constructs}/StaticSite.d.ts +44 -17
  149. package/{dist/constructs → constructs}/StaticSite.js +121 -72
  150. package/{dist/constructs → constructs}/Table.d.ts +0 -0
  151. package/{dist/constructs → constructs}/Table.js +9 -3
  152. package/{dist/constructs → constructs}/Topic.d.ts +0 -0
  153. package/{dist/constructs → constructs}/Topic.js +6 -3
  154. package/{dist/constructs → constructs}/ViteStaticSite.d.ts +0 -0
  155. package/{dist/constructs → constructs}/ViteStaticSite.js +2 -2
  156. package/{dist/constructs → constructs}/WebSocketApi.d.ts +0 -0
  157. package/{dist/constructs → constructs}/WebSocketApi.js +9 -4
  158. package/{dist/constructs → constructs}/context.d.ts +1 -1
  159. package/{dist/constructs → constructs}/context.js +0 -0
  160. package/{dist/constructs → constructs}/deferred_task.d.ts +0 -0
  161. package/{dist/constructs → constructs}/deferred_task.js +4 -2
  162. package/{dist/constructs → constructs/deprecated}/NextjsSite.d.ts +12 -8
  163. package/{dist/constructs → constructs/deprecated}/NextjsSite.js +112 -89
  164. package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.d.ts +0 -0
  165. package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.js +3 -3
  166. package/constructs/deprecated/index.d.ts +1 -0
  167. package/constructs/deprecated/index.js +1 -0
  168. package/{dist/constructs → constructs}/index.d.ts +3 -2
  169. package/{dist/constructs → constructs}/index.js +2 -0
  170. package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.d.ts +0 -0
  171. package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.js +0 -0
  172. package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.d.ts +0 -0
  173. package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.js +4 -4
  174. package/{dist/constructs → constructs}/util/apiGatewayV2Cors.d.ts +0 -0
  175. package/{dist/constructs → constructs}/util/apiGatewayV2Cors.js +0 -0
  176. package/{dist/constructs → constructs}/util/apiGatewayV2Domain.d.ts +0 -0
  177. package/{dist/constructs → constructs}/util/apiGatewayV2Domain.js +0 -0
  178. package/{dist/constructs → constructs}/util/appSyncApiDomain.d.ts +1 -1
  179. package/{dist/constructs → constructs}/util/appSyncApiDomain.js +15 -9
  180. package/{dist/constructs → constructs}/util/builder.d.ts +0 -0
  181. package/{dist/constructs → constructs}/util/builder.js +0 -0
  182. package/{dist/constructs → constructs}/util/duration.d.ts +0 -0
  183. package/{dist/constructs → constructs}/util/duration.js +0 -0
  184. package/{dist/constructs → constructs}/util/functionBinding.d.ts +0 -0
  185. package/{dist/constructs → constructs}/util/functionBinding.js +0 -0
  186. package/{dist/constructs → constructs}/util/functionUrlCors.d.ts +0 -0
  187. package/{dist/constructs → constructs}/util/functionUrlCors.js +0 -0
  188. package/{dist/constructs → constructs}/util/permission.d.ts +0 -0
  189. package/{dist/constructs → constructs}/util/permission.js +32 -16
  190. package/{dist/constructs → constructs}/util/python/bundling.d.ts +0 -0
  191. package/{dist/constructs → constructs}/util/python/bundling.js +0 -0
  192. package/{dist/constructs → constructs}/util/size.d.ts +0 -0
  193. package/{dist/constructs → constructs}/util/size.js +0 -0
  194. package/{dist/constructs → constructs}/util/warning.d.ts +0 -0
  195. package/{dist/constructs → constructs}/util/warning.js +0 -0
  196. package/{dist/context → context}/context.d.ts +1 -1
  197. package/{dist/context → context}/context.js +3 -4
  198. package/{dist/context → context}/handler.d.ts +0 -0
  199. package/{dist/context → context}/handler.js +1 -1
  200. package/{dist/context → context}/index.d.ts +0 -0
  201. package/{dist/context → context}/index.js +0 -0
  202. package/{dist/credentials.d.ts → credentials.d.ts} +3 -1
  203. package/{dist/credentials.js → credentials.js} +11 -3
  204. package/{dist/error.d.ts → error.d.ts} +0 -0
  205. package/{dist/error.js → error.js} +0 -0
  206. package/{dist/iot.d.ts → iot.d.ts} +0 -0
  207. package/{dist/iot.js → iot.js} +3 -0
  208. package/logger.d.ts +3 -0
  209. package/{dist/logger.js → logger.js} +12 -8
  210. package/node/api/index.d.ts +42 -0
  211. package/node/api/index.js +88 -0
  212. package/node/auth/adapter/adapter.d.ts +3 -0
  213. package/node/auth/adapter/adapter.js +3 -0
  214. package/node/auth/adapter/facebook.d.ts +2 -0
  215. package/node/auth/adapter/facebook.js +26 -0
  216. package/node/auth/adapter/github.d.ts +2 -0
  217. package/node/auth/adapter/github.js +21 -0
  218. package/node/auth/adapter/google.d.ts +9 -0
  219. package/node/auth/adapter/google.js +18 -0
  220. package/node/auth/adapter/link.d.ts +8 -0
  221. package/node/auth/adapter/link.js +39 -0
  222. package/node/auth/adapter/oauth.d.ts +25 -0
  223. package/node/auth/adapter/oauth.js +52 -0
  224. package/node/auth/adapter/oidc.d.ts +17 -0
  225. package/node/auth/adapter/oidc.js +50 -0
  226. package/node/auth/adapter/twitch.d.ts +2 -0
  227. package/node/auth/adapter/twitch.js +11 -0
  228. package/node/auth/auth.d.ts +24 -0
  229. package/node/auth/auth.js +118 -0
  230. package/node/auth/index.d.ts +10 -0
  231. package/node/auth/index.js +10 -0
  232. package/node/auth/session.d.ts +76 -0
  233. package/node/auth/session.js +109 -0
  234. package/node/bucket/index.d.ts +3 -0
  235. package/node/bucket/index.js +3 -0
  236. package/node/config/index.d.ts +13 -0
  237. package/node/config/index.js +88 -0
  238. package/node/event-bus/index.d.ts +3 -0
  239. package/node/event-bus/index.js +3 -0
  240. package/node/function/index.d.ts +3 -0
  241. package/node/function/index.js +3 -0
  242. package/node/graphql/index.d.ts +38 -0
  243. package/node/graphql/index.js +48 -0
  244. package/node/job/index.d.ts +34 -0
  245. package/node/job/index.js +51 -0
  246. package/node/kinesis-stream/index.d.ts +3 -0
  247. package/node/kinesis-stream/index.js +3 -0
  248. package/node/queue/index.d.ts +3 -0
  249. package/node/queue/index.js +3 -0
  250. package/node/rds/index.d.ts +3 -0
  251. package/node/rds/index.js +3 -0
  252. package/node/site/index.d.ts +15 -0
  253. package/node/site/index.js +64 -0
  254. package/node/table/index.d.ts +3 -0
  255. package/node/table/index.js +3 -0
  256. package/node/topic/index.d.ts +3 -0
  257. package/node/topic/index.js +3 -0
  258. package/node/util/index.d.ts +7 -0
  259. package/node/util/index.js +57 -0
  260. package/package.json +107 -40
  261. package/pothos.d.ts +8 -0
  262. package/pothos.js +156 -0
  263. package/runtime/handlers/dotnet.d.ts +1 -0
  264. package/runtime/handlers/dotnet.js +117 -0
  265. package/runtime/handlers/go.d.ts +1 -0
  266. package/runtime/handlers/go.js +105 -0
  267. package/runtime/handlers/java.d.ts +1 -0
  268. package/runtime/handlers/java.js +97 -0
  269. package/{dist/runtime → runtime/handlers}/node.d.ts +0 -0
  270. package/runtime/handlers/node.js +172 -0
  271. package/runtime/handlers/python.d.ts +1 -0
  272. package/runtime/handlers/python.js +89 -0
  273. package/{dist/runtime → runtime}/handlers.d.ts +30 -12
  274. package/runtime/handlers.js +117 -0
  275. package/{dist/runtime → runtime}/iot.d.ts +0 -0
  276. package/{dist/runtime → runtime}/iot.js +1 -1
  277. package/{dist/runtime → runtime}/runtime.d.ts +2 -0
  278. package/{dist/runtime → runtime}/runtime.js +0 -0
  279. package/{dist/runtime → runtime}/server.d.ts +0 -0
  280. package/{dist/runtime → runtime}/server.js +39 -3
  281. package/{dist/runtime → runtime}/workers.d.ts +1 -0
  282. package/{dist/runtime → runtime}/workers.js +12 -4
  283. package/{dist/cli/sst.d.ts → scrap.d.ts} +0 -0
  284. package/scrap.js +58 -0
  285. package/site-env.d.ts +13 -0
  286. package/site-env.js +47 -0
  287. package/sst.mjs +21848 -0
  288. package/{dist/stacks → stacks}/build.d.ts +0 -0
  289. package/{dist/stacks → stacks}/build.js +18 -9
  290. package/stacks/deploy.d.ts +8 -0
  291. package/stacks/deploy.js +105 -0
  292. package/stacks/index.d.ts +7 -0
  293. package/stacks/index.js +7 -0
  294. package/stacks/metadata.d.ts +9 -0
  295. package/{dist/stacks → stacks}/metadata.js +2 -14
  296. package/stacks/monitor.d.ts +27 -0
  297. package/stacks/monitor.js +111 -0
  298. package/stacks/remove.d.ts +8 -0
  299. package/stacks/remove.js +80 -0
  300. package/stacks/synth.d.ts +10 -0
  301. package/stacks/synth.js +77 -0
  302. package/support/astro-site-html-stub/index.html +99 -0
  303. package/support/base-site-archiver.cjs +12 -11
  304. package/support/base-site-archiver.mjs +20 -0
  305. package/support/bridge/bridge.mjs +59 -0
  306. package/{dist/support → support}/custom-resources/index.mjs +44209 -42781
  307. package/support/dotnet31-bootstrap/Program.cs +17 -0
  308. package/support/dotnet31-bootstrap/dotnet-bootstrap.csproj +12 -0
  309. package/support/dotnet31-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
  310. package/support/dotnet31-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
  311. package/support/dotnet31-bootstrap/release/System.Runtime.CompilerServices.Unsafe.dll +0 -0
  312. package/support/dotnet31-bootstrap/release/System.Text.Encodings.Web.dll +0 -0
  313. package/support/dotnet31-bootstrap/release/System.Text.Json.dll +0 -0
  314. package/support/dotnet31-bootstrap/release/dotnet-bootstrap +0 -0
  315. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.deps.json +230 -0
  316. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.dll +0 -0
  317. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.pdb +0 -0
  318. package/support/dotnet31-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +9 -0
  319. package/support/dotnet6-bootstrap/Program.cs +17 -0
  320. package/support/dotnet6-bootstrap/dotnet-bootstrap.csproj +12 -0
  321. package/support/dotnet6-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
  322. package/support/dotnet6-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
  323. package/support/dotnet6-bootstrap/release/dotnet-bootstrap +0 -0
  324. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +59 -0
  325. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.dll +0 -0
  326. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.pdb +0 -0
  327. package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +12 -0
  328. package/support/edge-function/edge-lambda-version.mjs +3 -0
  329. package/support/edge-function/edge-lambda.mjs +3 -0
  330. package/support/edge-function/s3-bucket.mjs +3 -0
  331. package/{dist/support/base-site-custom-resource/cf-invalidate.py → support/edge-function-code-replacer/lambda-code-updater.py} +56 -30
  332. package/support/java-runtime/install.sh +25 -0
  333. package/support/java-runtime/pom.xml +39 -0
  334. package/support/java-runtime/release/aws-lambda-java-core-1.2.0.jar +0 -0
  335. package/support/java-runtime/release/aws-lambda-java-runtime-interface-client-1.1.0.jar +0 -0
  336. package/support/java-runtime/release/aws-lambda-java-serialization-1.0.0.jar +0 -0
  337. package/support/nextjs-site-html-stub/index.html +99 -0
  338. package/{dist/support → support}/nodejs-runtime/index.mjs +7822 -2771
  339. package/support/python-runtime/runtime.py +116 -0
  340. package/support/rds-migrator/index.mjs +28 -0
  341. package/support/remix-site-function/edge-server.js +158 -0
  342. package/support/remix-site-function/polyfill.js +24 -0
  343. package/support/remix-site-function/regional-server.js +162 -0
  344. package/support/remix-site-html-stub/index.html +99 -0
  345. package/support/sls-nextjs-site-build-helper/build.cjs +91 -0
  346. package/support/sls-nextjs-site-build-helper/index-wrapper.js +19 -0
  347. package/support/sls-nextjs-site-stub/index.html +99 -0
  348. package/support/solid-start-site-html-stub/index.html +99 -0
  349. package/support/ssr-site-function-stub/index.js +5 -0
  350. package/util/fs.d.ts +4 -0
  351. package/util/fs.js +46 -0
  352. package/util/module.d.ts +1 -0
  353. package/util/module.js +5 -0
  354. package/util/process.d.ts +2 -0
  355. package/util/process.js +3 -0
  356. package/{dist/watcher.d.ts → watcher.d.ts} +0 -0
  357. package/{dist/watcher.js → watcher.js} +1 -1
  358. package/.build/sst-debug.log +0 -10
  359. package/.turbo/turbo-build.log +0 -2
  360. package/CHANGELOG.md +0 -332
  361. package/analyze +0 -11090
  362. package/bin/sst.mjs +0 -3
  363. package/build.mjs +0 -116
  364. package/debug.log +0 -6
  365. package/dist/app.js +0 -92
  366. package/dist/bootstrap.js +0 -23
  367. package/dist/cli/commands/build.js +0 -8
  368. package/dist/cli/commands/deploy.js +0 -20
  369. package/dist/cli/commands/env.d.ts +0 -0
  370. package/dist/cli/commands/env.js +0 -1
  371. package/dist/cli/commands/scrap.d.ts +0 -5
  372. package/dist/cli/commands/scrap.js +0 -1
  373. package/dist/cli/commands/start.d.ts +0 -7
  374. package/dist/cli/commands/start.js +0 -136
  375. package/dist/cli/program.d.ts +0 -7
  376. package/dist/cli/ui/deploy.d.ts +0 -6
  377. package/dist/constructs/nextjs-site/custom-resource/cfn-response.d.ts +0 -19
  378. package/dist/constructs/nextjs-site/custom-resource/cfn-response.js +0 -94
  379. package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.d.ts +0 -1
  380. package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.js +0 -138
  381. package/dist/constructs/nextjs-site/custom-resource/edge-lambda.d.ts +0 -1
  382. package/dist/constructs/nextjs-site/custom-resource/edge-lambda.js +0 -136
  383. package/dist/constructs/nextjs-site/custom-resource/s3-bucket.d.ts +0 -1
  384. package/dist/constructs/nextjs-site/custom-resource/s3-bucket.js +0 -94
  385. package/dist/constructs/nextjs-site/custom-resource/util.d.ts +0 -1
  386. package/dist/constructs/nextjs-site/custom-resource/util.js +0 -4
  387. package/dist/logger.d.ts +0 -9
  388. package/dist/runtime/handlers.js +0 -72
  389. package/dist/runtime/node.js +0 -99
  390. package/dist/sst.mjs +0 -164202
  391. package/dist/stacks/deploy.d.ts +0 -33
  392. package/dist/stacks/deploy.js +0 -168
  393. package/dist/stacks/index.d.ts +0 -21
  394. package/dist/stacks/index.js +0 -57
  395. package/dist/stacks/metadata.d.ts +0 -9
  396. package/dist/support/base-site-archiver.cjs +0 -115
  397. package/dist/support/base-site-custom-resource/s3-handler.py +0 -195
  398. package/dist/support/base-site-custom-resource/s3-upload.py +0 -91
  399. package/dist/support/bridge/bridge.mjs +0 -86
  400. package/dist/support/static-site-stub/index.html +0 -90
  401. package/src/app.ts +0 -140
  402. package/src/bootstrap.ts +0 -28
  403. package/src/bus.ts +0 -81
  404. package/src/cache.ts +0 -34
  405. package/src/cdk/cloudformation-deployments.ts +0 -730
  406. package/src/cdk/deploy-stack.ts +0 -1030
  407. package/src/cli/commands/bind.ts +0 -31
  408. package/src/cli/commands/build.ts +0 -16
  409. package/src/cli/commands/deploy.ts +0 -34
  410. package/src/cli/commands/env.ts +0 -0
  411. package/src/cli/commands/scrap.ts +0 -5
  412. package/src/cli/commands/secrets/get.ts +0 -50
  413. package/src/cli/commands/secrets/list.ts +0 -66
  414. package/src/cli/commands/secrets/remove.ts +0 -36
  415. package/src/cli/commands/secrets/secrets.ts +0 -17
  416. package/src/cli/commands/secrets/set.ts +0 -59
  417. package/src/cli/commands/start.tsx +0 -162
  418. package/src/cli/commands/update.ts +0 -100
  419. package/src/cli/program.ts +0 -22
  420. package/src/cli/spinner.ts +0 -14
  421. package/src/cli/sst.ts +0 -50
  422. package/src/cli/ui/deploy.tsx +0 -139
  423. package/src/config.ts +0 -226
  424. package/src/constructs/Api.ts +0 -1448
  425. package/src/constructs/ApiGatewayV1Api.ts +0 -1481
  426. package/src/constructs/App.ts +0 -744
  427. package/src/constructs/AppSyncApi.ts +0 -1045
  428. package/src/constructs/Auth.ts +0 -252
  429. package/src/constructs/BaseSite.ts +0 -146
  430. package/src/constructs/Bucket.ts +0 -670
  431. package/src/constructs/Cognito.ts +0 -708
  432. package/src/constructs/Config.ts +0 -4
  433. package/src/constructs/Construct.ts +0 -77
  434. package/src/constructs/Cron.ts +0 -235
  435. package/src/constructs/DebugApp.ts +0 -97
  436. package/src/constructs/DebugStack.ts +0 -182
  437. package/src/constructs/EdgeFunction.ts +0 -460
  438. package/src/constructs/EventBus.ts +0 -651
  439. package/src/constructs/Function.ts +0 -1329
  440. package/src/constructs/FunctionalStack.ts +0 -90
  441. package/src/constructs/GraphQLApi.ts +0 -140
  442. package/src/constructs/Job.ts +0 -557
  443. package/src/constructs/KinesisStream.ts +0 -388
  444. package/src/constructs/Metadata.ts +0 -75
  445. package/src/constructs/NextjsSite.ts +0 -1498
  446. package/src/constructs/Parameter.ts +0 -72
  447. package/src/constructs/Queue.ts +0 -360
  448. package/src/constructs/RDS.ts +0 -578
  449. package/src/constructs/ReactStaticSite.ts +0 -66
  450. package/src/constructs/RemixSite.ts +0 -1397
  451. package/src/constructs/Script/cfn-response.ts +0 -116
  452. package/src/constructs/Script/index.ts +0 -103
  453. package/src/constructs/Script/outbound.ts +0 -59
  454. package/src/constructs/Script/package.json +0 -3
  455. package/src/constructs/Script/util.ts +0 -19
  456. package/src/constructs/Script.ts +0 -270
  457. package/src/constructs/Secret.ts +0 -66
  458. package/src/constructs/Stack.ts +0 -319
  459. package/src/constructs/StaticSite.ts +0 -995
  460. package/src/constructs/Table.ts +0 -844
  461. package/src/constructs/Topic.ts +0 -486
  462. package/src/constructs/ViteStaticSite.ts +0 -99
  463. package/src/constructs/WebSocketApi.ts +0 -687
  464. package/src/constructs/context.ts +0 -12
  465. package/src/constructs/deferred_task.ts +0 -53
  466. package/src/constructs/descs.d.ts +0 -1
  467. package/src/constructs/index.ts +0 -39
  468. package/src/constructs/nextjs-site/cross-region-helper.ts +0 -189
  469. package/src/constructs/nextjs-site/custom-resource/cfn-response.ts +0 -146
  470. package/src/constructs/nextjs-site/custom-resource/edge-lambda-version.ts +0 -162
  471. package/src/constructs/nextjs-site/custom-resource/edge-lambda.ts +0 -167
  472. package/src/constructs/nextjs-site/custom-resource/s3-bucket.ts +0 -112
  473. package/src/constructs/nextjs-site/custom-resource/util.ts +0 -11
  474. package/src/constructs/util/apiGatewayV1AccessLog.ts +0 -106
  475. package/src/constructs/util/apiGatewayV2AccessLog.ts +0 -139
  476. package/src/constructs/util/apiGatewayV2Cors.ts +0 -94
  477. package/src/constructs/util/apiGatewayV2Domain.ts +0 -312
  478. package/src/constructs/util/appSyncApiDomain.ts +0 -204
  479. package/src/constructs/util/builder.ts +0 -17
  480. package/src/constructs/util/duration.ts +0 -27
  481. package/src/constructs/util/functionBinding.ts +0 -102
  482. package/src/constructs/util/functionUrlCors.ts +0 -96
  483. package/src/constructs/util/permission.ts +0 -299
  484. package/src/constructs/util/python/bundling.ts +0 -174
  485. package/src/constructs/util/size.ts +0 -13
  486. package/src/constructs/util/warning.ts +0 -20
  487. package/src/context/context.ts +0 -79
  488. package/src/context/handler.ts +0 -53
  489. package/src/context/index.ts +0 -2
  490. package/src/credentials.ts +0 -103
  491. package/src/error.ts +0 -5
  492. package/src/iot.ts +0 -105
  493. package/src/logger.ts +0 -35
  494. package/src/runtime/handlers.ts +0 -121
  495. package/src/runtime/iot.ts +0 -16
  496. package/src/runtime/node.ts +0 -111
  497. package/src/runtime/runtime.ts +0 -27
  498. package/src/runtime/server.ts +0 -149
  499. package/src/runtime/workers.ts +0 -96
  500. package/src/stacks/build.ts +0 -69
  501. package/src/stacks/deploy.ts +0 -232
  502. package/src/stacks/index.ts +0 -73
  503. package/src/stacks/metadata.ts +0 -125
  504. package/src/watcher.ts +0 -47
  505. package/sst.config.mjs +0 -6
  506. package/support/bridge/bridge.ts +0 -136
  507. package/support/bridge/build.mjs +0 -18
  508. package/support/custom-resources/auth-keys.ts +0 -113
  509. package/support/custom-resources/build.mjs +0 -18
  510. package/support/custom-resources/cfn-response.ts +0 -151
  511. package/support/custom-resources/index.ts +0 -18
  512. package/support/custom-resources/secrets-migration.ts +0 -82
  513. package/support/custom-resources/stack-metadata.ts +0 -75
  514. package/support/custom-resources/util.ts +0 -44
  515. package/support/nodejs-runtime/index.ts +0 -69
  516. package/support/tsconfig.json +0 -11
  517. package/tsconfig.json +0 -13
  518. package/yarn-error.log +0 -75
@@ -1,312 +0,0 @@
1
- import { Construct } from "constructs";
2
- import * as cdk from "aws-cdk-lib";
3
- import * as apig from "@aws-cdk/aws-apigatewayv2-alpha";
4
- import * as route53 from "aws-cdk-lib/aws-route53";
5
- import * as route53Targets from "aws-cdk-lib/aws-route53-targets";
6
- import * as acm from "aws-cdk-lib/aws-certificatemanager";
7
-
8
- export interface CustomDomainProps {
9
- /**
10
- * The domain to be assigned to the API endpoint (ie. api.domain.com)
11
- */
12
- domainName?: string;
13
- /**
14
- * The hosted zone in Route 53 that contains the domain. By default, SST will look for a hosted zone by stripping out the first part of the domainName that's passed in. So, if your domainName is api.domain.com. SST will default the hostedZone to domain.com.
15
- */
16
- hostedZone?: string;
17
- /**
18
- * The base mapping for the custom domain.
19
- *
20
- * For example, by setting the domainName to api.domain.com and the path to v1, the custom domain URL of the API will become https://api.domain.com/v1/. If the path is not set, the custom domain URL will be https://api.domain.com. Note the additional trailing slash in the former case.
21
- */
22
- path?: string;
23
- /**
24
- * Set this option if the domain is not hosted on Amazon Route 53.
25
- */
26
- isExternalDomain?: boolean;
27
- cdk?: {
28
- /**
29
- * Override the internally created domain name
30
- */
31
- domainName?: apig.IDomainName;
32
- /**
33
- * Override the internally created hosted zone
34
- */
35
- hostedZone?: route53.IHostedZone;
36
- /**
37
- * Override the internally created certificate
38
- */
39
- certificate?: acm.ICertificate;
40
- };
41
- }
42
-
43
- export interface CustomDomainData {
44
- readonly apigDomain: apig.IDomainName;
45
- readonly mappingKey?: string;
46
- readonly certificate?: acm.ICertificate;
47
- readonly isApigDomainCreated: boolean;
48
- readonly isCertificatedCreated: boolean;
49
- readonly url: string;
50
- }
51
-
52
- export function buildCustomDomainData(
53
- scope: Construct,
54
- customDomain: string | CustomDomainProps | undefined
55
- ): CustomDomainData | undefined {
56
- if (customDomain === undefined) {
57
- return;
58
- }
59
- // customDomain is a string
60
- else if (typeof customDomain === "string") {
61
- return buildDataForStringInput(scope, customDomain);
62
- }
63
- // customDomain.domainName is a string
64
- else if (customDomain.domainName) {
65
- return customDomain.isExternalDomain
66
- ? buildDataForExternalDomainInput(scope, customDomain)
67
- : buildDataForInternalDomainInput(scope, customDomain);
68
- }
69
- // customDomain.domainName is a construct
70
- else if (customDomain.cdk?.domainName) {
71
- return buildDataForConstructInput(scope, customDomain);
72
- }
73
- // customDomain.domainName not exists
74
- throw new Error(`Missing "domainName" in sst.Api's customDomain setting`);
75
- }
76
-
77
- function buildDataForStringInput(
78
- scope: Construct,
79
- customDomain: string
80
- ): CustomDomainData {
81
- // validate: customDomain is a TOKEN string
82
- // ie. imported SSM value: ssm.StringParameter.valueForStringParameter()
83
- if (cdk.Token.isUnresolved(customDomain)) {
84
- throw new Error(
85
- `You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`
86
- );
87
- }
88
-
89
- assertDomainNameIsLowerCase(customDomain);
90
-
91
- const domainName = customDomain;
92
- const hostedZoneDomain = domainName.split(".").slice(1).join(".");
93
- const hostedZone = lookupHostedZone(scope, hostedZoneDomain);
94
- const certificate = createCertificate(scope, domainName, hostedZone);
95
- const apigDomain = createApigDomain(scope, domainName, certificate);
96
- createARecords(scope, hostedZone, domainName, apigDomain);
97
-
98
- return {
99
- apigDomain,
100
- certificate,
101
- isApigDomainCreated: true,
102
- isCertificatedCreated: true,
103
- url: buildDomainUrl(domainName),
104
- };
105
- }
106
-
107
- function buildDataForInternalDomainInput(
108
- scope: Construct,
109
- customDomain: CustomDomainProps
110
- ): CustomDomainData {
111
- // If customDomain is a TOKEN string, "hostedZone" has to be passed in. This
112
- // is because "hostedZone" cannot be parsed from a TOKEN value.
113
- if (cdk.Token.isUnresolved(customDomain.domainName)) {
114
- if (!customDomain.hostedZone && !customDomain.cdk?.hostedZone) {
115
- throw new Error(
116
- `You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`
117
- );
118
- }
119
- }
120
- // If domain is not a token, ensure it is lower case
121
- else {
122
- assertDomainNameIsLowerCase(customDomain.domainName!);
123
- }
124
- const domainName = customDomain.domainName!;
125
-
126
- // Lookup hosted zone
127
- // Note: Allow user passing in `hostedZone` object. The use case is when
128
- // there are multiple HostedZones with the same domain, but one is
129
- // public, and one is private.
130
- let hostedZone: route53.IHostedZone;
131
- if (customDomain.hostedZone) {
132
- const hostedZoneDomain = customDomain.hostedZone;
133
- hostedZone = lookupHostedZone(scope, hostedZoneDomain);
134
- } else if (customDomain.cdk?.hostedZone) {
135
- hostedZone = customDomain.cdk.hostedZone;
136
- } else {
137
- const hostedZoneDomain = domainName.split(".").slice(1).join(".");
138
- hostedZone = lookupHostedZone(scope, hostedZoneDomain);
139
- }
140
-
141
- // Create certificate
142
- // Note: Allow user passing in `certificate` object. The use case is for
143
- // user to create wildcard certificate or using an imported certificate.
144
- let certificate: acm.ICertificate;
145
- let isCertificatedCreated: boolean;
146
- if (customDomain.cdk?.certificate) {
147
- certificate = customDomain.cdk.certificate;
148
- isCertificatedCreated = false;
149
- } else {
150
- certificate = createCertificate(scope, domainName, hostedZone);
151
- isCertificatedCreated = true;
152
- }
153
-
154
- const apigDomain = createApigDomain(scope, domainName, certificate);
155
- const mappingKey = customDomain.path;
156
- createARecords(scope, hostedZone, domainName, apigDomain);
157
-
158
- return {
159
- apigDomain,
160
- mappingKey,
161
- certificate,
162
- isApigDomainCreated: true,
163
- isCertificatedCreated,
164
- url: buildDomainUrl(domainName, mappingKey),
165
- };
166
- }
167
-
168
- function buildDataForExternalDomainInput(
169
- scope: Construct,
170
- customDomain: CustomDomainProps
171
- ): CustomDomainData {
172
- // if it is external, then a certificate is required
173
- if (!customDomain.cdk?.certificate) {
174
- throw new Error(
175
- `A valid certificate is required when "isExternalDomain" is set to "true".`
176
- );
177
- }
178
- // if it is external, then the hostedZone is not required
179
- if (customDomain.hostedZone || customDomain.cdk?.hostedZone) {
180
- throw new Error(
181
- `Hosted zones can only be configured for domains hosted on Amazon Route 53. Do not set the "hostedZone" when "isExternalDomain" is enabled.`
182
- );
183
- }
184
-
185
- // If domain is not a token, ensure it is lower case
186
- if (!cdk.Token.isUnresolved(customDomain.domainName)) {
187
- assertDomainNameIsLowerCase(customDomain.domainName!);
188
- }
189
-
190
- const domainName = customDomain.domainName!;
191
- const certificate = customDomain.cdk.certificate;
192
- const apigDomain = createApigDomain(scope, domainName, certificate);
193
- const mappingKey = customDomain.path;
194
-
195
- return {
196
- apigDomain,
197
- mappingKey,
198
- certificate,
199
- isApigDomainCreated: true,
200
- isCertificatedCreated: false,
201
- url: buildDomainUrl(domainName, mappingKey),
202
- };
203
- }
204
-
205
- function buildDataForConstructInput(
206
- scope: Construct,
207
- customDomain: CustomDomainProps
208
- ): CustomDomainData {
209
- // Allow user passing in `apigDomain` object. The use case is a user creates
210
- // multiple API endpoints, and is mapping them under the same custom domain.
211
- // `sst.Api` needs to expose the `apigDomain` construct created in the first
212
- // Api, and lets user pass it in when creating the second Api.
213
-
214
- if (customDomain.hostedZone || customDomain.cdk?.hostedZone) {
215
- throw new Error(
216
- `Cannot configure the "hostedZone" when the "domainName" is a construct`
217
- );
218
- }
219
- if (customDomain.cdk?.certificate) {
220
- throw new Error(
221
- `Cannot configure the "certificate" when the "domainName" is a construct`
222
- );
223
- }
224
-
225
- const apigDomain = customDomain.cdk?.domainName!;
226
- const domainName = apigDomain.name;
227
- const mappingKey = customDomain.path;
228
-
229
- return {
230
- apigDomain,
231
- mappingKey,
232
- certificate: undefined,
233
- isApigDomainCreated: false,
234
- isCertificatedCreated: false,
235
- url: buildDomainUrl(domainName, mappingKey),
236
- };
237
- }
238
-
239
- function lookupHostedZone(scope: Construct, hostedZoneDomain: string) {
240
- return route53.HostedZone.fromLookup(scope, "HostedZone", {
241
- domainName: hostedZoneDomain,
242
- });
243
- }
244
-
245
- function createCertificate(
246
- scope: Construct,
247
- domainName: string,
248
- hostedZone: route53.IHostedZone
249
- ) {
250
- return new acm.Certificate(scope, "Certificate", {
251
- domainName,
252
- validation: acm.CertificateValidation.fromDns(hostedZone),
253
- });
254
- }
255
-
256
- function createApigDomain(
257
- scope: Construct,
258
- domainName: string,
259
- certificate: acm.ICertificate
260
- ) {
261
- return new apig.DomainName(scope, "DomainName", {
262
- domainName,
263
- certificate,
264
- });
265
- }
266
-
267
- function createARecords(
268
- scope: Construct,
269
- hostedZone: route53.IHostedZone,
270
- domainName: string,
271
- apigDomain: apig.IDomainName
272
- ) {
273
- // create DNS record
274
- const recordProps = {
275
- recordName: domainName,
276
- zone: hostedZone,
277
- target: route53.RecordTarget.fromAlias(
278
- new route53Targets.ApiGatewayv2DomainProperties(
279
- apigDomain.regionalDomainName,
280
- apigDomain.regionalHostedZoneId
281
- )
282
- ),
283
- };
284
- const records = [
285
- new route53.ARecord(scope, "AliasRecord", recordProps),
286
- new route53.AaaaRecord(scope, "AliasRecordAAAA", recordProps),
287
- ];
288
- // note: If domainName is a TOKEN string ie. ${TOKEN..}, the route53.ARecord
289
- // construct will append ".${hostedZoneName}" to the end of the domain.
290
- // This is because the construct tries to check if the record name
291
- // ends with the domain name. If not, it will append the domain name.
292
- // So, we need remove this behavior.
293
- if (cdk.Token.isUnresolved(domainName)) {
294
- records.forEach((record) => {
295
- const cfnRecord = record.node.defaultChild as route53.CfnRecordSet;
296
- cfnRecord.name = domainName;
297
- });
298
- }
299
- }
300
-
301
- function buildDomainUrl(domainName: string, mappingKey?: string) {
302
- // Note: If mapping key is set, the URL needs a trailing slash. Without the
303
- // trailing slash, the API fails with the error
304
- // {"message":"Not Found"}
305
- return mappingKey ? `${domainName}/${mappingKey}/` : domainName;
306
- }
307
-
308
- function assertDomainNameIsLowerCase(domainName: string): void {
309
- if (domainName !== domainName.toLowerCase()) {
310
- throw new Error(`The domain name needs to be in lowercase`);
311
- }
312
- }
@@ -1,204 +0,0 @@
1
- import { Token, Lazy } from "aws-cdk-lib";
2
- import * as route53 from "aws-cdk-lib/aws-route53";
3
- import * as appsync from "@aws-cdk/aws-appsync-alpha";
4
- import * as acm from "aws-cdk-lib/aws-certificatemanager";
5
- import { AppSyncApi } from "../AppSyncApi";
6
-
7
- export interface CustomDomainProps {
8
- /**
9
- * The domain to be assigned to the API endpoint (ie. api.domain.com)
10
- */
11
- domainName?: string;
12
- /**
13
- * The hosted zone in Route 53 that contains the domain. By default, SST will look for a hosted zone by stripping out the first part of the domainName that's passed in. So, if your domainName is api.domain.com. SST will default the hostedZone to domain.com.
14
- */
15
- hostedZone?: string;
16
- /**
17
- * Set this option if the domain is not hosted on Amazon Route 53.
18
- */
19
- isExternalDomain?: boolean;
20
- cdk?: {
21
- /**
22
- * Override the internally created hosted zone
23
- */
24
- hostedZone?: route53.IHostedZone;
25
- /**
26
- * Override the internally created certificate
27
- */
28
- certificate?: acm.ICertificate;
29
- };
30
- }
31
-
32
- export function buildCustomDomainData(
33
- scope: AppSyncApi,
34
- customDomain: string | CustomDomainProps | undefined
35
- ): appsync.DomainOptions | undefined {
36
- if (customDomain === undefined) {
37
- return;
38
- }
39
- // customDomain is a string
40
- else if (typeof customDomain === "string") {
41
- return buildDataForStringInput(scope, customDomain);
42
- }
43
- // customDomain.domainName is a string
44
- else if (customDomain.domainName) {
45
- return customDomain.isExternalDomain
46
- ? buildDataForExternalDomainInput(scope, customDomain)
47
- : buildDataForInternalDomainInput(scope, customDomain);
48
- }
49
- // customDomain.domainName not exists
50
- throw new Error(
51
- `Missing "domainName" in sst.AppSyncApi's customDomain setting`
52
- );
53
- }
54
-
55
- function buildDataForStringInput(
56
- scope: AppSyncApi,
57
- customDomain: string
58
- ): appsync.DomainOptions {
59
- // validate: customDomain is a TOKEN string
60
- // ie. imported SSM value: ssm.StringParameter.valueForStringParameter()
61
- if (Token.isUnresolved(customDomain)) {
62
- throw new Error(
63
- `You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`
64
- );
65
- }
66
-
67
- assertDomainNameIsLowerCase(customDomain);
68
-
69
- const domainName = customDomain;
70
- const hostedZoneDomain = domainName.split(".").slice(1).join(".");
71
- const hostedZone = lookupHostedZone(scope, hostedZoneDomain);
72
- const certificate = createCertificate(scope, domainName, hostedZone);
73
- createRecord(scope, hostedZone, domainName);
74
-
75
- return {
76
- certificate,
77
- domainName,
78
- };
79
- }
80
-
81
- function buildDataForInternalDomainInput(
82
- scope: AppSyncApi,
83
- customDomain: CustomDomainProps
84
- ): appsync.DomainOptions {
85
- // If customDomain is a TOKEN string, "hostedZone" has to be passed in. This
86
- // is because "hostedZone" cannot be parsed from a TOKEN value.
87
- if (Token.isUnresolved(customDomain.domainName)) {
88
- if (!customDomain.hostedZone) {
89
- throw new Error(
90
- `You also need to specify the "hostedZone" if the "domainName" is passed in as a reference.`
91
- );
92
- }
93
- } else {
94
- assertDomainNameIsLowerCase(customDomain.domainName as string);
95
- }
96
-
97
- const domainName = customDomain.domainName as string;
98
-
99
- // Lookup hosted zone
100
- // Note: Allow user passing in `hostedZone` object. The use case is when
101
- // there are multiple HostedZones with the same domain, but one is
102
- // public, and one is private.
103
- let hostedZone: route53.IHostedZone;
104
- if (customDomain.hostedZone) {
105
- const hostedZoneDomain = customDomain.hostedZone;
106
- hostedZone = lookupHostedZone(scope, hostedZoneDomain);
107
- } else if (customDomain.cdk?.hostedZone) {
108
- hostedZone = customDomain.cdk.hostedZone;
109
- } else {
110
- const hostedZoneDomain = domainName.split(".").slice(1).join(".");
111
- hostedZone = lookupHostedZone(scope, hostedZoneDomain);
112
- }
113
-
114
- // Create certificate
115
- // Note: Allow user passing in `certificate` object. The use case is for
116
- // user to create wildcard certificate or using an imported certificate.
117
- const certificate = customDomain.cdk?.certificate
118
- ? customDomain.cdk.certificate
119
- : createCertificate(scope, domainName, hostedZone);
120
-
121
- createRecord(scope, hostedZone, domainName);
122
-
123
- return {
124
- certificate,
125
- domainName,
126
- };
127
- }
128
-
129
- function buildDataForExternalDomainInput(
130
- scope: AppSyncApi,
131
- customDomain: CustomDomainProps
132
- ): appsync.DomainOptions {
133
- // if it is external, then a certificate is required
134
- if (!customDomain.cdk?.certificate) {
135
- throw new Error(
136
- `A valid certificate is required when "isExternalDomain" is set to "true".`
137
- );
138
- }
139
- // if it is external, then the hostedZone is not required
140
- if (customDomain.hostedZone || customDomain.cdk?.hostedZone) {
141
- throw new Error(
142
- `Hosted zones can only be configured for domains hosted on Amazon Route 53. Do not set the "hostedZone" when "isExternalDomain" is enabled.`
143
- );
144
- }
145
-
146
- const domainName = customDomain.domainName as string;
147
- assertDomainNameIsLowerCase(domainName);
148
- const certificate = customDomain.cdk.certificate;
149
-
150
- return {
151
- certificate,
152
- domainName,
153
- };
154
- }
155
-
156
- function lookupHostedZone(scope: AppSyncApi, hostedZoneDomain: string) {
157
- return route53.HostedZone.fromLookup(scope, "HostedZone", {
158
- domainName: hostedZoneDomain,
159
- });
160
- }
161
-
162
- function createCertificate(
163
- scope: AppSyncApi,
164
- domainName: string,
165
- hostedZone: route53.IHostedZone
166
- ) {
167
- return new acm.Certificate(scope, "Certificate", {
168
- domainName,
169
- validation: acm.CertificateValidation.fromDns(hostedZone),
170
- });
171
- }
172
-
173
- function createRecord(
174
- scope: AppSyncApi,
175
- hostedZone: route53.IHostedZone,
176
- domainName: string
177
- ) {
178
- // create DNS record
179
- const record = new route53.CnameRecord(scope, "CnameRecord", {
180
- recordName: domainName,
181
- zone: hostedZone,
182
- domainName: Lazy.string({
183
- produce() {
184
- return scope._cfnDomainName!.attrAppSyncDomainName;
185
- },
186
- }),
187
- });
188
-
189
- // note: If domainName is a TOKEN string ie. ${TOKEN..}, the route53.ARecord
190
- // construct will append ".${hostedZoneName}" to the end of the domain.
191
- // This is because the construct tries to check if the record name
192
- // ends with the domain name. If not, it will append the domain name.
193
- // So, we need remove this behavior.
194
- if (Token.isUnresolved(domainName)) {
195
- const cfnRecord = record.node.defaultChild as route53.CfnRecordSet;
196
- cfnRecord.name = domainName;
197
- }
198
- }
199
-
200
- function assertDomainNameIsLowerCase(domainName: string): void {
201
- if (domainName !== domainName.toLowerCase()) {
202
- throw new Error(`The domain name needs to be in lowercase`);
203
- }
204
- }
@@ -1,17 +0,0 @@
1
- export function addExtensionToHandler(
2
- handler: string,
3
- extension: string
4
- ): string {
5
- return handler.replace(/\.[\w\d]+$/, extension);
6
- }
7
-
8
- export function getHandlerFullPosixPath(
9
- srcPath: string,
10
- handler: string
11
- ): string {
12
- return srcPath === "." ? handler : `${srcPath}/${handler}`;
13
- }
14
-
15
- export function getHandlerHash(posixPath: string): string {
16
- return `${posixPath.replace(/[\\/.]/g, "-")}-${Date.now()}`;
17
- }
@@ -1,27 +0,0 @@
1
- import { Duration as CDKDuration } from "aws-cdk-lib";
2
- export type Duration = `${number} ${
3
- | "second"
4
- | "seconds"
5
- | "minute"
6
- | "minutes"
7
- | "hour"
8
- | "hours"
9
- | "day"
10
- | "days"}`;
11
-
12
- export function toCdkDuration(duration: Duration): CDKDuration {
13
- const [count, unit] = duration.split(" ");
14
- const countNum = parseInt(count);
15
- const unitLower = unit.toLowerCase();
16
- if (unitLower.startsWith("second")) {
17
- return CDKDuration.seconds(countNum);
18
- } else if (unitLower.startsWith("minute")) {
19
- return CDKDuration.minutes(countNum);
20
- } else if (unitLower.startsWith("hour")) {
21
- return CDKDuration.hours(countNum);
22
- } else if (unitLower.startsWith("day")) {
23
- return CDKDuration.days(countNum);
24
- }
25
-
26
- return CDKDuration.days(0);
27
- }
@@ -1,102 +0,0 @@
1
- import * as ssm from "aws-cdk-lib/aws-ssm";
2
- import { SSTConstruct } from "../Construct.js";
3
- import { App } from "../App.js";
4
- import { Config } from "../../config.js";
5
-
6
- export const ENVIRONMENT_PLACEHOLDER = "__FETCH_FROM_SSM__";
7
-
8
- export interface FunctionBindingProps {
9
- clientPackage: string;
10
- permissions: Record<string, string[]>;
11
- variables: Record<
12
- string,
13
- {
14
- // environments are used for 2 purposes:
15
- // - pass binding values to the function (ie. bucket name)
16
- // - pass placeholder value to the function (ie. secret)
17
- environment: string;
18
- parameter?: string;
19
- }
20
- >;
21
- }
22
-
23
- export function bindEnvironment(c: SSTConstruct) {
24
- const binding = c.getFunctionBinding();
25
-
26
- const environment: Record<string, string> = {};
27
- if (binding) {
28
- Object.entries(binding.variables).forEach(([prop, variable]) => {
29
- const envName = getEnvironmentKey(c, prop);
30
- environment[envName] = variable.environment;
31
- });
32
- }
33
-
34
- return environment;
35
- }
36
-
37
- export function bindParameters(c: SSTConstruct) {
38
- const binding = c.getFunctionBinding();
39
- if (!binding) {
40
- return;
41
- }
42
-
43
- const app = c.node.root as App;
44
- Object.entries(binding.variables)
45
- .filter(([, variable]) => variable.parameter)
46
- .forEach(([prop, variable]) => {
47
- const resId = `Parameter_${prop}`;
48
- if (!c.node.tryFindChild(resId)) {
49
- new ssm.StringParameter(c, resId, {
50
- // Parameters, Secrets, and Jobs do not have a name
51
- parameterName: getParameterPath(c, prop),
52
- stringValue: variable.parameter!,
53
- });
54
- }
55
- });
56
- }
57
-
58
- export function bindPermissions(c: SSTConstruct) {
59
- return c.getFunctionBinding()?.permissions || {};
60
- }
61
-
62
- export function bindType(c: SSTConstruct) {
63
- const binding = c.getFunctionBinding();
64
- if (!binding) {
65
- return;
66
- }
67
-
68
- return {
69
- clientPackage: binding.clientPackage,
70
- variables: Object.keys(binding.variables),
71
- };
72
- }
73
-
74
- export function getEnvironmentKey(c: SSTConstruct, prop: string): string {
75
- return Config.envFor({
76
- type: c.constructor.name,
77
- id: c.id,
78
- prop: prop,
79
- });
80
- }
81
-
82
- export function getParameterPath(c: SSTConstruct, prop: string): string {
83
- const construct = c.constructor.name;
84
- return Config.pathFor({
85
- id: c.id,
86
- type: construct,
87
- prop: prop,
88
- });
89
- }
90
-
91
- export function getParameterFallbackPath(
92
- c: SSTConstruct,
93
- prop: string
94
- ): string {
95
- const construct = c.constructor.name;
96
- return Config.pathFor({
97
- id: c.id,
98
- type: construct,
99
- prop: prop,
100
- fallback: true,
101
- });
102
- }