@empire-builder-kit/nx 1.0.0-rc.46 → 1.0.0-rc.48

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 (780) hide show
  1. package/README.md +14 -169
  2. package/executors.json +24 -79
  3. package/generators.json +18 -18
  4. package/package.json +13 -71
  5. package/src/aws/identity.d.ts +1 -1
  6. package/src/aws-authority/boundary-transforms.d.ts +9 -0
  7. package/src/aws-authority/boundary-transforms.js +78 -0
  8. package/src/aws-authority/contracts.d.ts +116 -0
  9. package/src/aws-authority/contracts.js +40 -0
  10. package/src/aws-authority/deployment-guardrails.d.ts +4 -0
  11. package/src/aws-authority/deployment-guardrails.js +543 -0
  12. package/src/aws-authority/deployment-policy-groups.d.ts +3 -0
  13. package/src/aws-authority/deployment-policy-groups.js +299 -0
  14. package/src/aws-authority/deployment-resources.d.ts +64 -0
  15. package/src/aws-authority/deployment-resources.js +265 -0
  16. package/src/aws-authority/deployment-services.d.ts +3 -0
  17. package/src/aws-authority/deployment-services.js +717 -0
  18. package/src/aws-authority/development-authority.d.ts +11 -0
  19. package/src/aws-authority/development-authority.js +160 -0
  20. package/src/aws-authority/guardrail-actions.d.ts +87 -0
  21. package/src/aws-authority/guardrail-actions.js +463 -0
  22. package/src/aws-authority/policy-document.d.ts +15 -0
  23. package/src/aws-authority/policy-document.js +264 -0
  24. package/src/aws-authority/runtime-boundary.d.ts +7 -0
  25. package/src/aws-authority/runtime-boundary.js +211 -0
  26. package/src/aws-authority/service-actions.d.ts +96 -0
  27. package/src/aws-authority/service-actions.js +512 -0
  28. package/src/aws-authority/stage-authority.d.ts +6 -244
  29. package/src/aws-authority/stage-authority.js +114 -3419
  30. package/src/aws-authority/stage-identity.d.ts +6 -0
  31. package/src/aws-authority/stage-identity.js +134 -0
  32. package/src/cli/bootstrap.d.ts +0 -20
  33. package/src/cli/bootstrap.js +2 -153
  34. package/src/cli/dev-command.d.ts +2 -4
  35. package/src/cli/dev-command.js +1 -19
  36. package/src/cli/main.d.ts +0 -4
  37. package/src/cli/main.js +22 -80
  38. package/src/cli/output.d.ts +2 -4
  39. package/src/cli/output.js +2 -8
  40. package/src/executors/deployment-plan/deployment-plan.d.ts +0 -2
  41. package/src/executors/deployment-plan/deployment-plan.js +5 -67
  42. package/src/executors/dev-doctor/dev-doctor.d.ts +25 -3
  43. package/src/executors/dev-doctor/dev-doctor.js +137 -50
  44. package/src/executors/dev-setup/dev-setup.d.ts +18 -1
  45. package/src/executors/dev-setup/dev-setup.js +320 -196
  46. package/src/executors/foundation-preflight/foundation-preflight.js +9 -1
  47. package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +2 -2
  48. package/src/executors/local-deploy/deployed-smoke.d.ts +12 -0
  49. package/src/executors/local-deploy/deployed-smoke.js +115 -0
  50. package/src/executors/local-deploy/deployment-authority.d.ts +24 -0
  51. package/src/executors/local-deploy/deployment-authority.js +81 -0
  52. package/src/executors/local-deploy/deployment-child.d.ts +18 -0
  53. package/src/executors/local-deploy/deployment-child.js +77 -0
  54. package/src/executors/local-deploy/deployment-contracts.d.ts +96 -0
  55. package/src/executors/local-deploy/deployment-contracts.js +3 -0
  56. package/src/executors/local-deploy/deployment-projects.d.ts +4 -0
  57. package/src/executors/local-deploy/deployment-projects.js +16 -0
  58. package/src/executors/local-deploy/deployment-receipt.d.ts +4 -0
  59. package/src/executors/local-deploy/deployment-receipt.js +55 -0
  60. package/src/executors/local-deploy/deployment-scope.d.ts +17 -0
  61. package/src/executors/local-deploy/deployment-scope.js +239 -0
  62. package/src/executors/local-deploy/deployment-source.d.ts +13 -0
  63. package/src/executors/local-deploy/deployment-source.js +86 -0
  64. package/src/executors/local-deploy/local-deploy.d.ts +5 -106
  65. package/src/executors/local-deploy/local-deploy.js +56 -855
  66. package/src/executors/sst-lifecycle/governed-child-process.d.ts +27 -0
  67. package/src/executors/sst-lifecycle/governed-child-process.js +277 -0
  68. package/src/executors/sst-lifecycle/governed-native-operation.js +4 -10
  69. package/src/executors/sst-lifecycle/run-sst-command.d.ts +4 -85
  70. package/src/executors/sst-lifecycle/run-sst-command.js +28 -788
  71. package/src/executors/sst-lifecycle/sst-contracts.d.ts +44 -0
  72. package/src/executors/sst-lifecycle/sst-contracts.js +3 -0
  73. package/src/executors/sst-lifecycle/sst-invocation.d.ts +17 -0
  74. package/src/executors/sst-lifecycle/sst-invocation.js +502 -0
  75. package/src/executors/sst-lifecycle/task-unlock.js +3 -3
  76. package/src/foundation/discovery.d.ts +1 -5
  77. package/src/foundation/discovery.js +0 -2
  78. package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
  79. package/src/foundation/identity-domain-parent-ready.js +333 -0
  80. package/src/foundation/identity-domain.d.ts +94 -0
  81. package/src/foundation/identity-domain.js +115 -0
  82. package/src/foundation/index.d.ts +2 -2
  83. package/src/foundation/index.js +7 -9
  84. package/src/foundation/local-private-smoke-access.d.ts +6 -15
  85. package/src/foundation/local-private-smoke-access.js +8 -192
  86. package/src/foundation/observability.d.ts +16 -26
  87. package/src/foundation/observability.js +34 -135
  88. package/src/foundation/preflight.js +16 -14
  89. package/src/foundation/private-smoke-access.d.ts +7 -14
  90. package/src/foundation/private-smoke-access.js +4 -126
  91. package/src/foundation/root-site-workspace.d.ts +35 -0
  92. package/src/foundation/root-site-workspace.js +80 -0
  93. package/src/foundation/root-site.d.ts +82 -0
  94. package/src/foundation/root-site.js +276 -0
  95. package/src/generators/formatting.js +5 -4
  96. package/src/generators/framework-prerequisites.d.ts +2 -0
  97. package/src/generators/framework-prerequisites.js +34 -0
  98. package/src/generators/function/function.d.ts +20 -1
  99. package/src/generators/function/function.js +143 -90
  100. package/src/generators/function/schema.d.ts +1 -0
  101. package/src/generators/function/schema.json +8 -2
  102. package/src/generators/function-access/function-access.d.ts +8 -0
  103. package/src/generators/function-access/function-access.js +73 -0
  104. package/src/generators/function-access/schema.d.ts +6 -0
  105. package/src/generators/function-access/schema.json +25 -0
  106. package/src/generators/observability-policy.js +1 -2
  107. package/src/{supply-chain → generators}/pnpm-toolchain-authority.d.ts +3 -3
  108. package/src/{supply-chain → generators}/pnpm-toolchain-authority.js +12 -12
  109. package/src/generators/post-generation-install.d.ts +2 -9
  110. package/src/generators/post-generation-install.js +12 -140
  111. package/src/generators/preset/dependency-overrides.d.ts +14 -20
  112. package/src/generators/preset/dependency-overrides.js +13 -57
  113. package/src/generators/preset/generator.js +0 -3
  114. package/src/generators/preset/workspace-files-foundation-infra.d.ts +6 -0
  115. package/src/generators/preset/workspace-files-foundation-infra.js +586 -0
  116. package/src/generators/preset/workspace-files-foundation-readme.d.ts +5 -0
  117. package/src/generators/preset/workspace-files-foundation-readme.js +90 -0
  118. package/src/generators/preset/workspace-files-foundation.d.ts +3 -0
  119. package/src/generators/preset/workspace-files-foundation.js +170 -0
  120. package/src/generators/preset/workspace-files-ownership.d.ts +9 -0
  121. package/src/generators/preset/workspace-files-ownership.js +124 -0
  122. package/src/generators/preset/workspace-files-root-config.d.ts +32 -0
  123. package/src/generators/preset/workspace-files-root-config.js +356 -0
  124. package/src/generators/preset/workspace-files-root-docs.d.ts +5 -0
  125. package/src/generators/preset/workspace-files-root-docs.js +109 -0
  126. package/src/generators/preset/workspace-files-shared.d.ts +18 -0
  127. package/src/generators/preset/workspace-files-shared.js +7 -0
  128. package/src/generators/preset/workspace-files-workflows.d.ts +39 -0
  129. package/src/generators/preset/workspace-files-workflows.js +306 -0
  130. package/src/generators/preset/workspace-files-workspace-health.d.ts +6 -0
  131. package/src/generators/preset/workspace-files-workspace-health.js +148 -0
  132. package/src/generators/preset/workspace-files.d.ts +10 -24
  133. package/src/generators/preset/workspace-files.js +48 -10511
  134. package/src/generators/site/built-in-site-documentation-files.d.ts +3 -0
  135. package/src/generators/site/built-in-site-documentation-files.js +51 -0
  136. package/src/generators/site/built-in-site-files.d.ts +11 -0
  137. package/src/generators/site/built-in-site-files.js +41 -0
  138. package/src/generators/site/built-in-site-infrastructure-files.d.ts +3 -0
  139. package/src/generators/site/built-in-site-infrastructure-files.js +115 -0
  140. package/src/generators/site/built-in-site-plan.d.ts +23 -0
  141. package/src/generators/site/built-in-site-plan.js +67 -0
  142. package/src/generators/site/built-in-site-project-files.d.ts +11 -0
  143. package/src/generators/site/built-in-site-project-files.js +212 -0
  144. package/src/generators/site/built-in-site-script-files.d.ts +4 -0
  145. package/src/generators/site/built-in-site-script-files.js +102 -0
  146. package/src/generators/site/built-in-site-shared.d.ts +69 -0
  147. package/src/generators/site/built-in-site-shared.js +314 -0
  148. package/src/generators/site/built-in-site-sst-config-files.d.ts +3 -0
  149. package/src/generators/site/built-in-site-sst-config-files.js +107 -0
  150. package/src/generators/site/built-in-site-web-files.d.ts +3 -0
  151. package/src/generators/site/built-in-site-web-files.js +78 -0
  152. package/src/generators/site/schema.d.ts +9 -0
  153. package/src/generators/site/schema.json +26 -0
  154. package/src/generators/site/site.d.ts +5 -0
  155. package/src/generators/site/site.js +153 -0
  156. package/src/generators/slice/built-in-plan-api-files.d.ts +1 -2
  157. package/src/generators/slice/built-in-plan-api-files.js +30 -890
  158. package/src/generators/slice/built-in-plan-database-lifecycle-files.js +57 -1851
  159. package/src/generators/slice/built-in-plan-infrastructure-files.d.ts +5 -2
  160. package/src/generators/slice/built-in-plan-infrastructure-files.js +80 -3358
  161. package/src/generators/slice/built-in-plan-key-value-files.d.ts +3 -2
  162. package/src/generators/slice/built-in-plan-key-value-files.js +3 -21
  163. package/src/generators/slice/built-in-plan-project-files.d.ts +5 -3
  164. package/src/generators/slice/built-in-plan-project-files.js +79 -897
  165. package/src/generators/slice/built-in-plan-shared.d.ts +4 -19
  166. package/src/generators/slice/built-in-plan-shared.js +5 -58
  167. package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
  168. package/src/generators/slice/built-in-plan-sst-config.js +160 -0
  169. package/src/generators/slice/built-in-plan-web-files.d.ts +1 -1
  170. package/src/generators/slice/built-in-plan-web-files.js +14 -475
  171. package/src/generators/slice/built-in-plan.d.ts +2 -3
  172. package/src/generators/slice/built-in-plan.js +79 -277
  173. package/src/{developer-agent/preview-changes.d.ts → generators/slice/generation-tree.d.ts} +1 -5
  174. package/src/generators/slice/generation-tree.js +161 -0
  175. package/src/generators/slice/persistence-contract.js +2 -2
  176. package/src/generators/slice/schema.json +12 -4
  177. package/src/generators/slice/slice-config.d.ts +7 -0
  178. package/src/generators/slice/slice-config.js +125 -0
  179. package/src/generators/slice/slice.js +52 -257
  180. package/src/generators/slice/sql-bootstrap.d.ts +1 -0
  181. package/src/generators/slice/sql-bootstrap.js +505 -0
  182. package/src/generators/slice/sql-client.d.ts +1 -0
  183. package/src/generators/slice/sql-client.js +107 -0
  184. package/src/generators/slice/sql-infrastructure.d.ts +1 -0
  185. package/src/generators/slice/sql-infrastructure.js +225 -0
  186. package/src/generators/slice/sql-logging.d.ts +1 -0
  187. package/src/generators/slice/sql-logging.js +266 -0
  188. package/src/generators/slice/sql-migration.d.ts +2 -0
  189. package/src/generators/slice/sql-migration.js +202 -0
  190. package/src/generators/slice/standard-slice-contract.d.ts +25 -0
  191. package/src/generators/slice/standard-slice-contract.js +64 -0
  192. package/src/generators/sql/schema.json +1 -1
  193. package/src/generators/sql/sql.d.ts +1 -1
  194. package/src/generators/sql/sql.js +13 -7
  195. package/src/generators/upgrade/framework-package-upgrade.d.ts +35 -0
  196. package/src/generators/upgrade/framework-package-upgrade.js +55 -0
  197. package/src/generators/upgrade/framework-packages.d.ts +25 -0
  198. package/src/generators/upgrade/framework-packages.js +138 -0
  199. package/src/generators/upgrade/function-authentication-notice.d.ts +21 -0
  200. package/src/generators/upgrade/function-authentication-notice.js +54 -0
  201. package/src/generators/upgrade/schema.d.ts +0 -3
  202. package/src/generators/upgrade/schema.json +7 -17
  203. package/src/generators/upgrade/slice-compositions.d.ts +20 -0
  204. package/src/generators/upgrade/slice-compositions.js +100 -0
  205. package/src/generators/upgrade/slice-upgrade-guidance.d.ts +19 -0
  206. package/src/generators/upgrade/slice-upgrade-guidance.js +50 -0
  207. package/src/generators/upgrade/slice-upgrade.d.ts +4 -0
  208. package/src/generators/upgrade/slice-upgrade.js +231 -0
  209. package/src/generators/upgrade/upgrade-plan.d.ts +49 -0
  210. package/src/generators/upgrade/upgrade-plan.js +242 -0
  211. package/src/generators/upgrade/upgrade-preflight.d.ts +20 -0
  212. package/src/generators/upgrade/upgrade-preflight.js +64 -0
  213. package/src/generators/upgrade/upgrade.d.ts +8 -87
  214. package/src/generators/upgrade/upgrade.js +27 -1909
  215. package/src/generators/workload/schema.json +2 -2
  216. package/src/generators/workload/workload.d.ts +11 -11
  217. package/src/generators/workload/workload.js +167 -1200
  218. package/src/index.d.ts +0 -5
  219. package/src/index.js +0 -5
  220. package/src/local-dev/browser-verification.d.ts +0 -7
  221. package/src/local-dev/browser-verification.js +0 -136
  222. package/src/local-dev/contracts.d.ts +6 -0
  223. package/src/local-dev/contracts.js +17 -9
  224. package/src/local-dev/environment-checks.d.ts +126 -0
  225. package/src/local-dev/environment-checks.js +81 -0
  226. package/src/local-dev/environment-inspector.d.ts +3 -124
  227. package/src/local-dev/environment-inspector.js +9 -148
  228. package/src/local-dev/fleet-process.d.ts +9 -2
  229. package/src/local-dev/fleet-process.js +27 -7
  230. package/src/local-dev/gateway-daemon.d.ts +1 -1
  231. package/src/local-dev/gateway-daemon.js +6 -4
  232. package/src/local-dev/portless.d.ts +5 -0
  233. package/src/local-dev/portless.js +5 -0
  234. package/src/local-dev/private-state.d.ts +1 -0
  235. package/src/local-dev/private-state.js +19 -23
  236. package/src/local-dev/process-group.d.ts +10 -0
  237. package/src/local-dev/process-group.js +33 -0
  238. package/src/local-dev/process-identity.js +4 -2
  239. package/src/local-dev/slice-runner-child.d.ts +37 -0
  240. package/src/local-dev/slice-runner-child.js +127 -0
  241. package/src/local-dev/slice-runner-recovery.d.ts +32 -0
  242. package/src/local-dev/slice-runner-recovery.js +216 -0
  243. package/src/local-dev/slice-runner-state.d.ts +82 -0
  244. package/src/local-dev/slice-runner-state.js +265 -0
  245. package/src/local-dev/slice-runner.d.ts +4 -117
  246. package/src/local-dev/slice-runner.js +59 -594
  247. package/src/local-dev/tls.js +39 -99
  248. package/src/local-dev/trust-store.d.ts +42 -0
  249. package/src/local-dev/trust-store.js +87 -0
  250. package/src/ownership/composition.d.ts +7 -0
  251. package/src/ownership/composition.js +64 -56
  252. package/src/ownership/index.d.ts +2 -0
  253. package/src/ownership/index.js +7 -0
  254. package/src/ownership/pnpm-workspace.d.ts +77 -0
  255. package/src/ownership/pnpm-workspace.js +225 -0
  256. package/src/ownership/record.d.ts +19 -0
  257. package/src/ownership/record.js +26 -2
  258. package/src/ownership/site-record.d.ts +26 -0
  259. package/src/ownership/site-record.js +120 -0
  260. package/src/repository-policy/capacity-migration.d.ts +1 -1
  261. package/src/repository-policy/capacity-migration.js +1 -1
  262. package/src/repository-policy/deployment-plan.d.ts +3 -0
  263. package/src/repository-policy/deployment-plan.js +33 -4
  264. package/src/repository-policy/foundation-router.d.ts +17 -0
  265. package/src/repository-policy/foundation-router.js +44 -0
  266. package/src/repository-policy/index.d.ts +3 -0
  267. package/src/repository-policy/index.js +3 -0
  268. package/src/repository-policy/policy-accounts.d.ts +22 -0
  269. package/src/repository-policy/policy-accounts.js +134 -0
  270. package/src/repository-policy/policy-files.d.ts +8 -0
  271. package/src/repository-policy/policy-files.js +201 -0
  272. package/src/repository-policy/policy-internal.d.ts +2 -0
  273. package/src/repository-policy/policy-internal.js +11 -0
  274. package/src/repository-policy/policy-model.d.ts +95 -0
  275. package/src/repository-policy/policy-model.js +42 -0
  276. package/src/repository-policy/policy-validation.d.ts +4 -0
  277. package/src/repository-policy/policy-validation.js +308 -0
  278. package/src/repository-policy/policy.d.ts +6 -109
  279. package/src/repository-policy/policy.js +52 -626
  280. package/src/repository-policy/public-dns.d.ts +69 -0
  281. package/src/repository-policy/public-dns.js +265 -0
  282. package/src/{generators/repository-policy → repository-policy}/tree-policy.d.ts +1 -1
  283. package/src/{generators/repository-policy → repository-policy}/tree-policy.js +5 -5
  284. package/src/schemas/generated-ownership-v2.json +6 -0
  285. package/src/schemas/repository-policy-v1.json +106 -3
  286. package/src/secrets/index.d.ts +0 -5
  287. package/src/secrets/index.js +0 -5
  288. package/src/slice-infra/index.d.ts +57 -0
  289. package/src/slice-infra/index.js +117 -0
  290. package/src/slice-scripts/build.d.ts +27 -0
  291. package/src/slice-scripts/build.js +120 -0
  292. package/src/slice-scripts/database.d.ts +87 -0
  293. package/src/slice-scripts/database.js +328 -0
  294. package/src/slice-scripts/index.d.ts +11 -0
  295. package/src/slice-scripts/index.js +23 -0
  296. package/src/slice-scripts/root-site-routes.d.ts +11 -0
  297. package/src/slice-scripts/root-site-routes.js +83 -0
  298. package/src/slice-scripts/sql-migration-engine.mjs +180 -0
  299. package/src/workload-roles/effective-policy.d.ts +0 -37
  300. package/src/workload-roles/effective-policy.js +1 -174
  301. package/src/workload-roles/standard-slice.d.ts +2 -19
  302. package/src/workload-roles/standard-slice.js +3 -129
  303. package/src/workspace-deployment/ownership.d.ts +15 -0
  304. package/src/workspace-deployment/ownership.js +19 -3
  305. package/src/api-contract/baseline-update.d.ts +0 -82
  306. package/src/api-contract/baseline-update.js +0 -225
  307. package/src/api-contract/compatibility.d.ts +0 -30
  308. package/src/api-contract/compatibility.js +0 -643
  309. package/src/api-contract/contract-graph.d.ts +0 -35
  310. package/src/api-contract/contract-graph.js +0 -141
  311. package/src/api-contract/evidence.d.ts +0 -23
  312. package/src/api-contract/evidence.js +0 -87
  313. package/src/api-contract/index.d.ts +0 -6
  314. package/src/api-contract/index.js +0 -10
  315. package/src/api-contract/model.d.ts +0 -144
  316. package/src/api-contract/model.js +0 -993
  317. package/src/api-contract/rollout.d.ts +0 -32
  318. package/src/api-contract/rollout.js +0 -88
  319. package/src/authorization/compatibility.d.ts +0 -62
  320. package/src/authorization/compatibility.js +0 -175
  321. package/src/authorization/index.d.ts +0 -1
  322. package/src/authorization/index.js +0 -5
  323. package/src/blueprints/execution.d.ts +0 -55
  324. package/src/blueprints/execution.js +0 -329
  325. package/src/blueprints/external-sandbox.d.ts +0 -53
  326. package/src/blueprints/external-sandbox.js +0 -1194
  327. package/src/blueprints/index.d.ts +0 -5
  328. package/src/blueprints/index.js +0 -9
  329. package/src/blueprints/inputs.d.ts +0 -43
  330. package/src/blueprints/inputs.js +0 -103
  331. package/src/blueprints/manifest.d.ts +0 -281
  332. package/src/blueprints/manifest.js +0 -424
  333. package/src/blueprints/resolver.d.ts +0 -37
  334. package/src/blueprints/resolver.js +0 -387
  335. package/src/blueprints/transitions.d.ts +0 -20
  336. package/src/blueprints/transitions.js +0 -61
  337. package/src/cli/agent-command.d.ts +0 -30
  338. package/src/cli/agent-command.js +0 -204
  339. package/src/cli/agent-runtime.d.ts +0 -25
  340. package/src/cli/agent-runtime.js +0 -498
  341. package/src/cli/blueprint-authority.d.ts +0 -9
  342. package/src/cli/blueprint-authority.js +0 -43
  343. package/src/cli/blueprint-command.d.ts +0 -24
  344. package/src/cli/blueprint-command.js +0 -63
  345. package/src/data-lifecycle/index.d.ts +0 -3
  346. package/src/data-lifecycle/index.js +0 -7
  347. package/src/data-lifecycle/model.d.ts +0 -172
  348. package/src/data-lifecycle/model.js +0 -95
  349. package/src/data-lifecycle/sensitive-artifacts.d.ts +0 -28
  350. package/src/data-lifecycle/sensitive-artifacts.js +0 -146
  351. package/src/data-lifecycle/validation.d.ts +0 -32
  352. package/src/data-lifecycle/validation.js +0 -837
  353. package/src/database-retirement/contract.d.ts +0 -68
  354. package/src/database-retirement/contract.js +0 -166
  355. package/src/database-retirement/index.d.ts +0 -1
  356. package/src/database-retirement/index.js +0 -5
  357. package/src/developer-agent/context.d.ts +0 -57
  358. package/src/developer-agent/context.js +0 -662
  359. package/src/developer-agent/generator-planning.d.ts +0 -34
  360. package/src/developer-agent/generator-planning.js +0 -666
  361. package/src/developer-agent/generator-preview.d.ts +0 -8
  362. package/src/developer-agent/generator-preview.js +0 -650
  363. package/src/developer-agent/git-inspection.d.ts +0 -112
  364. package/src/developer-agent/git-inspection.js +0 -887
  365. package/src/developer-agent/handoff.d.ts +0 -43
  366. package/src/developer-agent/handoff.js +0 -713
  367. package/src/developer-agent/index.d.ts +0 -10
  368. package/src/developer-agent/index.js +0 -14
  369. package/src/developer-agent/model.d.ts +0 -493
  370. package/src/developer-agent/model.js +0 -143
  371. package/src/developer-agent/operation-registry.d.ts +0 -60
  372. package/src/developer-agent/operation-registry.js +0 -1550
  373. package/src/developer-agent/ordering.d.ts +0 -9
  374. package/src/developer-agent/ordering.js +0 -15
  375. package/src/developer-agent/planning.d.ts +0 -25
  376. package/src/developer-agent/planning.js +0 -478
  377. package/src/developer-agent/preview-changes.js +0 -215
  378. package/src/developer-agent/preview-source.d.ts +0 -2
  379. package/src/developer-agent/preview-source.js +0 -19
  380. package/src/developer-agent/validation.d.ts +0 -30
  381. package/src/developer-agent/validation.js +0 -2725
  382. package/src/developer-agent/workspace-inspection.d.ts +0 -20
  383. package/src/developer-agent/workspace-inspection.js +0 -1189
  384. package/src/developer-agent/workspace-path.d.ts +0 -6
  385. package/src/developer-agent/workspace-path.js +0 -22
  386. package/src/executors/blueprint-trust/blueprint-trust.d.ts +0 -29
  387. package/src/executors/blueprint-trust/blueprint-trust.js +0 -121
  388. package/src/executors/blueprint-trust/schema.json +0 -27
  389. package/src/executors/blueprint-verification/blueprint-verification.d.ts +0 -13
  390. package/src/executors/blueprint-verification/blueprint-verification.js +0 -110
  391. package/src/executors/blueprint-verification/schema.json +0 -44
  392. package/src/executors/developer-context/developer-context.d.ts +0 -38
  393. package/src/executors/developer-context/developer-context.js +0 -78
  394. package/src/executors/developer-context/schema.json +0 -87
  395. package/src/executors/foundation-profile-preflight/foundation-profile-preflight.d.ts +0 -19
  396. package/src/executors/foundation-profile-preflight/foundation-profile-preflight.js +0 -105
  397. package/src/executors/foundation-profile-preflight/schema.json +0 -32
  398. package/src/executors/github-bootstrap/github-bootstrap.d.ts +0 -13
  399. package/src/executors/github-bootstrap/github-bootstrap.js +0 -62
  400. package/src/executors/github-bootstrap/schema.json +0 -50
  401. package/src/executors/infrastructure-plan/infrastructure-plan.d.ts +0 -37
  402. package/src/executors/infrastructure-plan/infrastructure-plan.js +0 -268
  403. package/src/executors/infrastructure-plan/schema.json +0 -38
  404. package/src/executors/router-waf-rehearsal/router-waf-rehearsal.d.ts +0 -42
  405. package/src/executors/router-waf-rehearsal/router-waf-rehearsal.js +0 -1229
  406. package/src/executors/router-waf-rehearsal/schema.json +0 -29
  407. package/src/executors/secret-guardrails/schema.json +0 -6
  408. package/src/executors/secret-guardrails/secret-guardrails.d.ts +0 -3
  409. package/src/executors/secret-guardrails/secret-guardrails.js +0 -44
  410. package/src/executors/secret-initialize/schema.json +0 -42
  411. package/src/executors/secret-initialize/secret-initialize.d.ts +0 -34
  412. package/src/executors/secret-initialize/secret-initialize.js +0 -297
  413. package/src/executors/secret-metadata/schema.json +0 -36
  414. package/src/executors/secret-metadata/secret-metadata.d.ts +0 -46
  415. package/src/executors/secret-metadata/secret-metadata.js +0 -230
  416. package/src/executors/sst-lifecycle/generated-secret-retirement.d.ts +0 -53
  417. package/src/executors/sst-lifecycle/generated-secret-retirement.js +0 -192
  418. package/src/executors/sst-lifecycle/logging-preflight.d.ts +0 -22
  419. package/src/executors/sst-lifecycle/logging-preflight.js +0 -206
  420. package/src/executors/sst-lifecycle/secret-preflight.d.ts +0 -27
  421. package/src/executors/sst-lifecycle/secret-preflight.js +0 -125
  422. package/src/executors/work-markers/schema.json +0 -14
  423. package/src/executors/work-markers/work-markers.d.ts +0 -6
  424. package/src/executors/work-markers/work-markers.js +0 -20
  425. package/src/foundation/cost-estimate.d.ts +0 -175
  426. package/src/foundation/cost-estimate.js +0 -706
  427. package/src/foundation/private-smoke-admission.d.ts +0 -45
  428. package/src/foundation/private-smoke-admission.js +0 -180
  429. package/src/foundation/private-smoke-control-plane.d.ts +0 -18
  430. package/src/foundation/private-smoke-control-plane.js +0 -184
  431. package/src/foundation/router-waf-rate-rehearsal.d.ts +0 -97
  432. package/src/foundation/router-waf-rate-rehearsal.js +0 -210
  433. package/src/foundation/router-waf.d.ts +0 -149
  434. package/src/foundation/router-waf.js +0 -809
  435. package/src/frontend-security/index.d.ts +0 -1
  436. package/src/frontend-security/index.js +0 -5
  437. package/src/frontend-security/security-headers.d.ts +0 -50
  438. package/src/frontend-security/security-headers.js +0 -418
  439. package/src/generators/blueprint/blueprint.d.ts +0 -5
  440. package/src/generators/blueprint/blueprint.js +0 -102
  441. package/src/generators/blueprint/files.d.ts +0 -6
  442. package/src/generators/blueprint/files.js +0 -217
  443. package/src/generators/blueprint/schema.d.ts +0 -4
  444. package/src/generators/blueprint/schema.json +0 -18
  445. package/src/generators/feature-registry.d.ts +0 -13
  446. package/src/generators/feature-registry.js +0 -73
  447. package/src/generators/observability-infrastructure.d.ts +0 -2
  448. package/src/generators/observability-infrastructure.js +0 -31
  449. package/src/generators/preset/workspace-files-adopter-skills.d.ts +0 -7
  450. package/src/generators/preset/workspace-files-adopter-skills.js +0 -345
  451. package/src/generators/preset/workspace-files-agent-development.d.ts +0 -9
  452. package/src/generators/preset/workspace-files-agent-development.js +0 -42
  453. package/src/generators/preset/workspace-files-ci-acceptance.d.ts +0 -1
  454. package/src/generators/preset/workspace-files-ci-acceptance.js +0 -791
  455. package/src/generators/preset/workspace-files-ci-install.d.ts +0 -2
  456. package/src/generators/preset/workspace-files-ci-install.js +0 -196
  457. package/src/generators/preset/workspace-files-developer-agent.d.ts +0 -16
  458. package/src/generators/preset/workspace-files-developer-agent.js +0 -638
  459. package/src/generators/preset/workspace-files-ecr-inspector.d.ts +0 -18
  460. package/src/generators/preset/workspace-files-ecr-inspector.js +0 -298
  461. package/src/generators/preset/workspace-files-foundation-workload-roles.d.ts +0 -6
  462. package/src/generators/preset/workspace-files-foundation-workload-roles.js +0 -409
  463. package/src/generators/preset/workspace-files-performance-cost.d.ts +0 -66
  464. package/src/generators/preset/workspace-files-performance-cost.js +0 -866
  465. package/src/generators/preset/workspace-files-performance-load.d.ts +0 -73
  466. package/src/generators/preset/workspace-files-performance-load.js +0 -815
  467. package/src/generators/preset/workspace-files-shared-operation-claims.d.ts +0 -10
  468. package/src/generators/preset/workspace-files-shared-operation-claims.js +0 -59
  469. package/src/generators/preset/workspace-files-stage-authority.d.ts +0 -6
  470. package/src/generators/preset/workspace-files-stage-authority.js +0 -529
  471. package/src/generators/preset/workspace-files-thin-deploy.d.ts +0 -65
  472. package/src/generators/preset/workspace-files-thin-deploy.js +0 -2520
  473. package/src/generators/preset/workspace-files-thin-docs.d.ts +0 -7
  474. package/src/generators/preset/workspace-files-thin-docs.js +0 -358
  475. package/src/generators/preset/workspace-files-thin-release.d.ts +0 -14
  476. package/src/generators/preset/workspace-files-thin-release.js +0 -26
  477. package/src/generators/preset/workspace-files-workload-role-baseline.d.ts +0 -9
  478. package/src/generators/preset/workspace-files-workload-role-baseline.js +0 -1314
  479. package/src/generators/repository-policy/repository-policy.d.ts +0 -4
  480. package/src/generators/repository-policy/repository-policy.js +0 -293
  481. package/src/generators/repository-policy/schema.d.ts +0 -28
  482. package/src/generators/repository-policy/schema.json +0 -122
  483. package/src/generators/slice/built-in-plan-alarm-identity.d.ts +0 -173
  484. package/src/generators/slice/built-in-plan-alarm-identity.js +0 -202
  485. package/src/generators/slice/built-in-plan-api-contract-files.d.ts +0 -2
  486. package/src/generators/slice/built-in-plan-api-contract-files.js +0 -2830
  487. package/src/generators/slice/built-in-plan-async-work-files.d.ts +0 -2
  488. package/src/generators/slice/built-in-plan-async-work-files.js +0 -6100
  489. package/src/generators/slice/built-in-plan-authorization-files.d.ts +0 -2
  490. package/src/generators/slice/built-in-plan-authorization-files.js +0 -2082
  491. package/src/generators/slice/built-in-plan-authorization-infrastructure-files.d.ts +0 -2
  492. package/src/generators/slice/built-in-plan-authorization-infrastructure-files.js +0 -1301
  493. package/src/generators/slice/built-in-plan-authorization-storage.d.ts +0 -3
  494. package/src/generators/slice/built-in-plan-authorization-storage.js +0 -119
  495. package/src/generators/slice/built-in-plan-background-work-files.d.ts +0 -2
  496. package/src/generators/slice/built-in-plan-background-work-files.js +0 -99
  497. package/src/generators/slice/built-in-plan-data-deletion-files.d.ts +0 -2
  498. package/src/generators/slice/built-in-plan-data-deletion-files.js +0 -273
  499. package/src/generators/slice/built-in-plan-data-export-infrastructure-files.d.ts +0 -2
  500. package/src/generators/slice/built-in-plan-data-export-infrastructure-files.js +0 -223
  501. package/src/generators/slice/built-in-plan-data-files.d.ts +0 -2
  502. package/src/generators/slice/built-in-plan-data-files.js +0 -513
  503. package/src/generators/slice/built-in-plan-data-lifecycle-files.d.ts +0 -2
  504. package/src/generators/slice/built-in-plan-data-lifecycle-files.js +0 -775
  505. package/src/generators/slice/built-in-plan-data-lifecycle-runtime-files.d.ts +0 -2
  506. package/src/generators/slice/built-in-plan-data-lifecycle-runtime-files.js +0 -863
  507. package/src/generators/slice/built-in-plan-data-retention-job-files.d.ts +0 -2
  508. package/src/generators/slice/built-in-plan-data-retention-job-files.js +0 -169
  509. package/src/generators/slice/built-in-plan-data-retention-launcher-files.d.ts +0 -2
  510. package/src/generators/slice/built-in-plan-data-retention-launcher-files.js +0 -186
  511. package/src/generators/slice/built-in-plan-data-rights-files.d.ts +0 -2
  512. package/src/generators/slice/built-in-plan-data-rights-files.js +0 -152
  513. package/src/generators/slice/built-in-plan-database-retirement-rehearsal-files.d.ts +0 -2
  514. package/src/generators/slice/built-in-plan-database-retirement-rehearsal-files.js +0 -508
  515. package/src/generators/slice/built-in-plan-event-contract-literal.d.ts +0 -6
  516. package/src/generators/slice/built-in-plan-event-contract-literal.js +0 -52
  517. package/src/generators/slice/built-in-plan-foundation-files.d.ts +0 -3
  518. package/src/generators/slice/built-in-plan-foundation-files.js +0 -205
  519. package/src/generators/slice/built-in-plan-frontend-files.d.ts +0 -2
  520. package/src/generators/slice/built-in-plan-frontend-files.js +0 -2244
  521. package/src/generators/slice/built-in-plan-infrastructure-safety-files.d.ts +0 -2
  522. package/src/generators/slice/built-in-plan-infrastructure-safety-files.js +0 -373
  523. package/src/generators/slice/built-in-plan-key-value-cleanup.d.ts +0 -4
  524. package/src/generators/slice/built-in-plan-key-value-cleanup.js +0 -100
  525. package/src/generators/slice/built-in-plan-key-value-consumer.d.ts +0 -4
  526. package/src/generators/slice/built-in-plan-key-value-consumer.js +0 -151
  527. package/src/generators/slice/built-in-plan-key-value-deletion.d.ts +0 -2
  528. package/src/generators/slice/built-in-plan-key-value-deletion.js +0 -377
  529. package/src/generators/slice/built-in-plan-key-value-delivery.d.ts +0 -2
  530. package/src/generators/slice/built-in-plan-key-value-delivery.js +0 -137
  531. package/src/generators/slice/built-in-plan-key-value-export.d.ts +0 -2
  532. package/src/generators/slice/built-in-plan-key-value-export.js +0 -595
  533. package/src/generators/slice/built-in-plan-key-value-holds.d.ts +0 -2
  534. package/src/generators/slice/built-in-plan-key-value-holds.js +0 -189
  535. package/src/generators/slice/built-in-plan-key-value-infrastructure.d.ts +0 -2
  536. package/src/generators/slice/built-in-plan-key-value-infrastructure.js +0 -102
  537. package/src/generators/slice/built-in-plan-key-value-performance.d.ts +0 -5
  538. package/src/generators/slice/built-in-plan-key-value-performance.js +0 -530
  539. package/src/generators/slice/built-in-plan-key-value-provider.d.ts +0 -4
  540. package/src/generators/slice/built-in-plan-key-value-provider.js +0 -366
  541. package/src/generators/slice/built-in-plan-key-value-records.d.ts +0 -3
  542. package/src/generators/slice/built-in-plan-key-value-records.js +0 -232
  543. package/src/generators/slice/built-in-plan-key-value-retention-infrastructure.d.ts +0 -2
  544. package/src/generators/slice/built-in-plan-key-value-retention-infrastructure.js +0 -103
  545. package/src/generators/slice/built-in-plan-key-value-retention-job-files.d.ts +0 -2
  546. package/src/generators/slice/built-in-plan-key-value-retention-job-files.js +0 -160
  547. package/src/generators/slice/built-in-plan-key-value-retention-maintenance.d.ts +0 -2
  548. package/src/generators/slice/built-in-plan-key-value-retention-maintenance.js +0 -329
  549. package/src/generators/slice/built-in-plan-key-value-retention-worker.d.ts +0 -2
  550. package/src/generators/slice/built-in-plan-key-value-retention-worker.js +0 -477
  551. package/src/generators/slice/built-in-plan-key-value-retention.d.ts +0 -2
  552. package/src/generators/slice/built-in-plan-key-value-retention.js +0 -184
  553. package/src/generators/slice/built-in-plan-metadata-files.d.ts +0 -3
  554. package/src/generators/slice/built-in-plan-metadata-files.js +0 -384
  555. package/src/generators/slice/built-in-plan-native-runtime-authority-files.d.ts +0 -2
  556. package/src/generators/slice/built-in-plan-native-runtime-authority-files.js +0 -324
  557. package/src/generators/slice/built-in-plan-operations-files.d.ts +0 -2
  558. package/src/generators/slice/built-in-plan-operations-files.js +0 -1218
  559. package/src/generators/slice/built-in-plan-performance-files.d.ts +0 -4
  560. package/src/generators/slice/built-in-plan-performance-files.js +0 -2439
  561. package/src/generators/slice/built-in-plan-release-files.d.ts +0 -2
  562. package/src/generators/slice/built-in-plan-release-files.js +0 -6585
  563. package/src/generators/slice/built-in-plan-reliability-files.d.ts +0 -2
  564. package/src/generators/slice/built-in-plan-reliability-files.js +0 -4724
  565. package/src/generators/slice/built-in-plan-secret-runtime-files.d.ts +0 -2
  566. package/src/generators/slice/built-in-plan-secret-runtime-files.js +0 -1015
  567. package/src/generators/slice/built-in-plan-sql-events.d.ts +0 -2
  568. package/src/generators/slice/built-in-plan-sql-events.js +0 -276
  569. package/src/generators/slice/built-in-plan-testing-files.d.ts +0 -2
  570. package/src/generators/slice/built-in-plan-testing-files.js +0 -2575
  571. package/src/generators/slice/built-in-plan-testing-persistence-event-files.d.ts +0 -7
  572. package/src/generators/slice/built-in-plan-testing-persistence-event-files.js +0 -487
  573. package/src/generators/slice/built-in-plan-testing-persistence-files.d.ts +0 -2
  574. package/src/generators/slice/built-in-plan-testing-persistence-files.js +0 -180
  575. package/src/generators/slice/built-in-plan-thin-release-files.d.ts +0 -11
  576. package/src/generators/slice/built-in-plan-thin-release-files.js +0 -162
  577. package/src/generators/slice/built-in-plan-verification-files.d.ts +0 -2
  578. package/src/generators/slice/built-in-plan-verification-files.js +0 -431
  579. package/src/generators/slice/built-in-plan-workload-role-files.d.ts +0 -2
  580. package/src/generators/slice/built-in-plan-workload-role-files.js +0 -2220
  581. package/src/generators/slice/data-policy-review-seed.d.ts +0 -2
  582. package/src/generators/slice/data-policy-review-seed.js +0 -22
  583. package/src/generators/slice/deployed-smoke-readiness.d.ts +0 -2
  584. package/src/generators/slice/deployed-smoke-readiness.js +0 -214
  585. package/src/generators/slice/local-source-identity.d.ts +0 -2
  586. package/src/generators/slice/local-source-identity.js +0 -31
  587. package/src/generators/upgrade/sql-seeded-reconciliation.d.ts +0 -2
  588. package/src/generators/upgrade/sql-seeded-reconciliation.js +0 -170
  589. package/src/generators/workload/performance-registration.d.ts +0 -33
  590. package/src/generators/workload/performance-registration.js +0 -224
  591. package/src/generators/workload/reliability-registration.d.ts +0 -16
  592. package/src/generators/workload/reliability-registration.js +0 -150
  593. package/src/generators/workload/service-performance-files.d.ts +0 -5
  594. package/src/generators/workload/service-performance-files.js +0 -1883
  595. package/src/git-policy/action-pins.d.ts +0 -43
  596. package/src/git-policy/action-pins.js +0 -50
  597. package/src/git-policy/github-bootstrap.d.ts +0 -94
  598. package/src/git-policy/github-bootstrap.js +0 -1248
  599. package/src/git-policy/index.d.ts +0 -3
  600. package/src/git-policy/index.js +0 -7
  601. package/src/git-policy/routing.d.ts +0 -21
  602. package/src/git-policy/routing.js +0 -138
  603. package/src/infrastructure-change/convergence.d.ts +0 -13
  604. package/src/infrastructure-change/convergence.js +0 -85
  605. package/src/infrastructure-change/drift.d.ts +0 -13
  606. package/src/infrastructure-change/drift.js +0 -112
  607. package/src/infrastructure-change/index.d.ts +0 -7
  608. package/src/infrastructure-change/index.js +0 -11
  609. package/src/infrastructure-change/local-capability.d.ts +0 -73
  610. package/src/infrastructure-change/local-capability.js +0 -114
  611. package/src/infrastructure-change/model.d.ts +0 -274
  612. package/src/infrastructure-change/model.js +0 -29
  613. package/src/infrastructure-change/normalize.d.ts +0 -16
  614. package/src/infrastructure-change/normalize.js +0 -285
  615. package/src/infrastructure-change/plan.d.ts +0 -67
  616. package/src/infrastructure-change/plan.js +0 -671
  617. package/src/infrastructure-change/risk.d.ts +0 -9
  618. package/src/infrastructure-change/risk.js +0 -349
  619. package/src/infrastructure-change/summary.d.ts +0 -20
  620. package/src/infrastructure-change/summary.js +0 -130
  621. package/src/performance/cost-collection.d.ts +0 -225
  622. package/src/performance/cost-collection.js +0 -827
  623. package/src/performance/cost-controls.d.ts +0 -135
  624. package/src/performance/cost-controls.js +0 -347
  625. package/src/performance/evidence.d.ts +0 -140
  626. package/src/performance/evidence.js +0 -601
  627. package/src/performance/index.d.ts +0 -10
  628. package/src/performance/index.js +0 -14
  629. package/src/performance/load-safety.d.ts +0 -84
  630. package/src/performance/load-safety.js +0 -348
  631. package/src/performance/model.d.ts +0 -129
  632. package/src/performance/model.js +0 -451
  633. package/src/performance/pr-artifact-budget.d.ts +0 -42
  634. package/src/performance/pr-artifact-budget.js +0 -151
  635. package/src/performance/runner.d.ts +0 -75
  636. package/src/performance/runner.js +0 -227
  637. package/src/performance/scenario-endpoint.d.ts +0 -1
  638. package/src/performance/scenario-endpoint.js +0 -5
  639. package/src/performance/scenario.d.ts +0 -215
  640. package/src/performance/scenario.js +0 -744
  641. package/src/performance/unit-cost.d.ts +0 -105
  642. package/src/performance/unit-cost.js +0 -364
  643. package/src/release/index.d.ts +0 -2
  644. package/src/release/index.js +0 -6
  645. package/src/release/lifecycle.d.ts +0 -132
  646. package/src/release/lifecycle.js +0 -411
  647. package/src/release/manifest.d.ts +0 -148
  648. package/src/release/manifest.js +0 -503
  649. package/src/release/rollout.d.ts +0 -170
  650. package/src/release/rollout.js +0 -578
  651. package/src/release/source-authority.d.ts +0 -19
  652. package/src/release/source-authority.js +0 -212
  653. package/src/schemas/aggregate-count-evidence-v1.json +0 -135
  654. package/src/schemas/api-contract-baseline-v1.json +0 -674
  655. package/src/schemas/api-contract-compatibility-report-v1.json +0 -126
  656. package/src/schemas/aws-billing-actual-evidence-v1.json +0 -407
  657. package/src/schemas/blueprint-input-schema-v1.json +0 -23
  658. package/src/schemas/blueprint-v1.json +0 -188
  659. package/src/schemas/data-lifecycle-policy-v1.json +0 -517
  660. package/src/schemas/performance-policy-v1.json +0 -335
  661. package/src/schemas/testing-evidence-quarantine-v1.json +0 -168
  662. package/src/schemas/testing-evidence-result-v1.json +0 -319
  663. package/src/secrets/aws-control-plane.d.ts +0 -29
  664. package/src/secrets/aws-control-plane.js +0 -322
  665. package/src/secrets/generated-aws-control-plane.d.ts +0 -33
  666. package/src/secrets/generated-aws-control-plane.js +0 -322
  667. package/src/secrets/guardrails.d.ts +0 -26
  668. package/src/secrets/guardrails.js +0 -328
  669. package/src/secrets/metadata.d.ts +0 -48
  670. package/src/secrets/metadata.js +0 -199
  671. package/src/secrets/operator.d.ts +0 -190
  672. package/src/secrets/operator.js +0 -701
  673. package/src/secrets/verification.d.ts +0 -18
  674. package/src/secrets/verification.js +0 -152
  675. package/src/supply-chain/action-pins.d.ts +0 -26
  676. package/src/supply-chain/action-pins.js +0 -262
  677. package/src/supply-chain/blueprint-trust-git.d.ts +0 -130
  678. package/src/supply-chain/blueprint-trust-git.js +0 -1642
  679. package/src/supply-chain/blueprint-trust-process.d.ts +0 -4
  680. package/src/supply-chain/blueprint-trust-process.js +0 -88
  681. package/src/supply-chain/blueprint-trust.d.ts +0 -354
  682. package/src/supply-chain/blueprint-trust.js +0 -1558
  683. package/src/supply-chain/blueprint-verification-authority.d.ts +0 -62
  684. package/src/supply-chain/blueprint-verification-authority.js +0 -661
  685. package/src/supply-chain/blueprint-verification-execution.d.ts +0 -68
  686. package/src/supply-chain/blueprint-verification-execution.js +0 -639
  687. package/src/supply-chain/build-output-bounds.d.ts +0 -2
  688. package/src/supply-chain/build-output-bounds.js +0 -12
  689. package/src/supply-chain/build-output.d.ts +0 -41
  690. package/src/supply-chain/build-output.js +0 -551
  691. package/src/supply-chain/common.d.ts +0 -21
  692. package/src/supply-chain/common.js +0 -107
  693. package/src/supply-chain/container-artifact-contract.d.ts +0 -23
  694. package/src/supply-chain/container-artifact-contract.js +0 -208
  695. package/src/supply-chain/container-release.d.ts +0 -119
  696. package/src/supply-chain/container-release.js +0 -496
  697. package/src/supply-chain/ecr-applicability.d.ts +0 -19
  698. package/src/supply-chain/ecr-applicability.js +0 -103
  699. package/src/supply-chain/ecr-scanning.d.ts +0 -85
  700. package/src/supply-chain/ecr-scanning.js +0 -325
  701. package/src/supply-chain/ecs-deployed-image.d.ts +0 -87
  702. package/src/supply-chain/ecs-deployed-image.js +0 -302
  703. package/src/supply-chain/errors.d.ts +0 -6
  704. package/src/supply-chain/errors.js +0 -15
  705. package/src/supply-chain/generated-blueprint-trust-command.d.ts +0 -4
  706. package/src/supply-chain/generated-blueprint-trust-command.js +0 -1379
  707. package/src/supply-chain/generated-command.d.ts +0 -1
  708. package/src/supply-chain/generated-command.js +0 -775
  709. package/src/supply-chain/generated-container-release-command.d.ts +0 -16
  710. package/src/supply-chain/generated-container-release-command.js +0 -3248
  711. package/src/supply-chain/generated-ecr-collector-command.d.ts +0 -20
  712. package/src/supply-chain/generated-ecr-collector-command.js +0 -1445
  713. package/src/supply-chain/generated-files.d.ts +0 -13
  714. package/src/supply-chain/generated-files.js +0 -421
  715. package/src/supply-chain/generated-scanner-command.d.ts +0 -1
  716. package/src/supply-chain/generated-scanner-command.js +0 -778
  717. package/src/supply-chain/index.d.ts +0 -28
  718. package/src/supply-chain/index.js +0 -36
  719. package/src/supply-chain/inventory.d.ts +0 -96
  720. package/src/supply-chain/inventory.js +0 -828
  721. package/src/supply-chain/license-expression.d.ts +0 -7
  722. package/src/supply-chain/license-expression.js +0 -128
  723. package/src/supply-chain/policy.d.ts +0 -105
  724. package/src/supply-chain/policy.js +0 -304
  725. package/src/supply-chain/publication.d.ts +0 -48
  726. package/src/supply-chain/publication.js +0 -85
  727. package/src/supply-chain/sbom.d.ts +0 -228
  728. package/src/supply-chain/sbom.js +0 -913
  729. package/src/supply-chain/scanner.d.ts +0 -77
  730. package/src/supply-chain/scanner.js +0 -514
  731. package/src/supply-chain/vendored-source.d.ts +0 -95
  732. package/src/supply-chain/vendored-source.js +0 -315
  733. package/src/testing-evidence/fixture-scope.d.ts +0 -53
  734. package/src/testing-evidence/fixture-scope.js +0 -142
  735. package/src/testing-evidence/index.d.ts +0 -5
  736. package/src/testing-evidence/index.js +0 -9
  737. package/src/testing-evidence/quarantine.d.ts +0 -48
  738. package/src/testing-evidence/quarantine.js +0 -253
  739. package/src/testing-evidence/result.d.ts +0 -109
  740. package/src/testing-evidence/result.js +0 -585
  741. package/src/testing-evidence/runner-adapter.d.ts +0 -51
  742. package/src/testing-evidence/runner-adapter.js +0 -288
  743. package/src/testing-evidence/sensitive-artifacts.d.ts +0 -13
  744. package/src/testing-evidence/sensitive-artifacts.js +0 -93
  745. package/src/work-markers/index.d.ts +0 -1
  746. package/src/work-markers/index.js +0 -5
  747. package/src/work-markers/work-markers.d.ts +0 -39
  748. package/src/work-markers/work-markers.js +0 -360
  749. package/src/workload-roles/account-baseline.d.ts +0 -143
  750. package/src/workload-roles/account-baseline.js +0 -980
  751. package/src/workload-roles/authority.d.ts +0 -40
  752. package/src/workload-roles/authority.js +0 -202
  753. package/src/workload-roles/aws-adapter.d.ts +0 -99
  754. package/src/workload-roles/aws-adapter.js +0 -416
  755. package/src/workload-roles/aws-internal-handler.d.ts +0 -27
  756. package/src/workload-roles/aws-internal-handler.js +0 -58
  757. package/src/workload-roles/aws-s3-state.d.ts +0 -52
  758. package/src/workload-roles/aws-s3-state.js +0 -191
  759. package/src/workload-roles/aws-sdk-control-plane.d.ts +0 -12
  760. package/src/workload-roles/aws-sdk-control-plane.js +0 -291
  761. package/src/workload-roles/boundary.d.ts +0 -34
  762. package/src/workload-roles/boundary.js +0 -137
  763. package/src/workload-roles/convergence.d.ts +0 -66
  764. package/src/workload-roles/convergence.js +0 -186
  765. package/src/workload-roles/handler.d.ts +0 -43
  766. package/src/workload-roles/handler.js +0 -158
  767. package/src/workload-roles/history.d.ts +0 -47
  768. package/src/workload-roles/history.js +0 -324
  769. package/src/workload-roles/injection.d.ts +0 -119
  770. package/src/workload-roles/injection.js +0 -495
  771. package/src/workload-roles/manifest.d.ts +0 -54
  772. package/src/workload-roles/manifest.js +0 -343
  773. package/src/workload-roles/provisioner.d.ts +0 -70
  774. package/src/workload-roles/provisioner.js +0 -239
  775. package/src/workload-roles/registration.d.ts +0 -102
  776. package/src/workload-roles/registration.js +0 -462
  777. package/src/workload-roles/stage-boundary.d.ts +0 -31
  778. package/src/workload-roles/stage-boundary.js +0 -208
  779. /package/src/executors/{foundation-profile-preflight → local-deploy}/production-database-safeguard.d.ts +0 -0
  780. /package/src/executors/{foundation-profile-preflight → local-deploy}/production-database-safeguard.js +0 -0
@@ -1,3401 +1,123 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderProductInfrastructureFiles = renderProductInfrastructureFiles;
4
- const built_in_plan_alarm_identity_js_1 = require("./built-in-plan-alarm-identity.js");
5
- const built_in_plan_shared_js_1 = require("./built-in-plan-shared.js");
6
- const built_in_plan_key_value_retention_infrastructure_js_1 = require("./built-in-plan-key-value-retention-infrastructure.js");
7
- /** @internal */
8
- function renderProductInfrastructureFiles(name, pascalName, workspace, protectedRuntimeStages = ['staging', 'production'], sql = false, network = sql) {
9
- const identifierPrefix = (0, built_in_plan_shared_js_1.lowerCamelIdentifier)(pascalName);
10
- const recordExportWorkflowName = (0, built_in_plan_shared_js_1.stableGeneratedName)(40, name);
11
- const files = {
12
- 'infra/event-subscriptions.ts': `/**
13
- * Same-Slice routing reads only the Slice's own seeded EventContractSchema and
14
- * never broadens its source or stage filter. Foreign Slices are routed only
15
- * through the seeded contracts/event-subscriptions.json declaration below.
16
- */
17
- export function sameSliceEventDetailTypes(value: unknown): string[] {
18
- const contract = value as {
19
- kind?: unknown;
20
- schemaVersion?: unknown;
21
- slice?: unknown;
22
- events?: unknown;
23
- } | null;
24
- if (
25
- !contract || contract.kind !== 'ebk-event-contract-schema' ||
26
- contract.schemaVersion !== 1 || contract.slice !== '${name}' ||
27
- !Array.isArray(contract.events) || contract.events.length < 2 ||
28
- contract.events.length > 32
29
- ) throw new Error('Event subscriptions require the bounded seeded ${name} EventContractSchema.');
30
- const types = new Set<string>();
31
- for (const raw of contract.events) {
32
- const event = raw as {
33
- detailType?: unknown;
34
- source?: unknown;
35
- schemaVersion?: unknown;
36
- data?: unknown;
37
- } | null;
38
- if (
39
- !event || typeof event.detailType !== 'string' ||
40
- !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(event.detailType) ||
41
- event.source !== '${name}' || typeof event.schemaVersion !== 'number' ||
42
- !Number.isSafeInteger(event.schemaVersion) || event.schemaVersion < 1 ||
43
- !event.data || typeof event.data !== 'object' || Array.isArray(event.data) ||
44
- types.has(event.detailType)
45
- ) throw new Error('Event subscriptions require unique literal types, exact Slice sources and valid schemas.');
46
- types.add(event.detailType);
47
- }
48
- if (!types.has('${pascalName}Created') || !types.has('DataLifecycleChanged'))
49
- throw new Error('The generated event contract must retain its built-in event declarations.');
50
- // Lifecycle consumers have their own exact source declaration and rule.
51
- types.delete('DataLifecycleChanged');
52
- return [...types].sort();
53
- }
54
-
55
- /** One exact queue rule for each foreign Slice that the seeded declaration names. */
56
- export interface CrossSliceEventSubscription {
57
- readonly detailTypes: readonly string[];
58
- readonly ruleName: string;
59
- readonly schemaVersions: readonly number[];
60
- readonly source: string;
61
- }
62
-
63
- function exactKeys(
64
- value: unknown,
65
- keys: readonly string[],
66
- ): value is Record<string, unknown> {
67
- return !!value && typeof value === 'object' && !Array.isArray(value) &&
68
- Object.keys(value).length === keys.length &&
69
- keys.every((key) => Object.hasOwn(value, key));
70
- }
71
-
72
- function subscriptionError(detail: string): Error {
73
- return new Error('contracts/event-subscriptions.json ' + detail);
74
- }
75
-
76
- /**
77
- * Validate the seeded cross-Slice declaration before any rule registers.
78
- * Source and detail type are delivery filters, not authentication: the
79
- * consumer authorizes every effect from its own data and policy.
80
- */
81
- export function crossSliceEventSubscriptions(
82
- declaration: unknown,
83
- dependencies: unknown,
84
- ): CrossSliceEventSubscription[] {
85
- if (
86
- !exactKeys(declaration, ['schemaVersion', 'subscriptions']) ||
87
- declaration.schemaVersion !== 1 ||
88
- !Array.isArray(declaration.subscriptions) ||
89
- declaration.subscriptions.length > 8
90
- ) throw subscriptionError('must be a v1 declaration with at most 8 source subscriptions.');
91
- if (
92
- !exactKeys(dependencies, ['consumes', 'schemaVersion']) ||
93
- dependencies.schemaVersion !== 1 ||
94
- !Array.isArray(dependencies.consumes)
95
- ) throw subscriptionError('requires the v1 contracts/dependencies.json declaration.');
96
- const consumes = new Set<unknown>(dependencies.consumes);
97
- const sources = new Set<string>();
98
- const ruleNames = new Set<string>();
99
- const subscriptions: CrossSliceEventSubscription[] = [];
100
- for (const raw of declaration.subscriptions as unknown[]) {
101
- if (
102
- !exactKeys(raw, ['events', 'source']) || typeof raw.source !== 'string' ||
103
- raw.source.length > 63 || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(raw.source) ||
104
- raw.source === '${name}' || sources.has(raw.source)
105
- ) throw subscriptionError('requires unique foreign Slice sources other than ${name}.');
106
- const source = raw.source;
107
- sources.add(source);
108
- const contracts = '@${workspace}/' + source + '/contracts';
109
- if (!consumes.has(contracts))
110
- throw subscriptionError('source ' + source + ' requires ' + contracts + ' in contracts/dependencies.json consumes.');
111
- if (!Array.isArray(raw.events) || raw.events.length < 1 || raw.events.length > 32)
112
- throw subscriptionError('source ' + source + ' must declare 1 to 32 events.');
113
- const detailTypes = new Set<string>();
114
- let schemaVersions: number[] | undefined;
115
- for (const event of raw.events as unknown[]) {
116
- if (
117
- !exactKeys(event, ['detailType', 'schemaVersions']) ||
118
- typeof event.detailType !== 'string' ||
119
- !/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(event.detailType) ||
120
- event.detailType === 'DataLifecycleChanged' || detailTypes.has(event.detailType)
121
- ) throw subscriptionError('source ' + source + ' requires unique literal detail types other than DataLifecycleChanged.');
122
- const declared: unknown = event.schemaVersions;
123
- if (
124
- !Array.isArray(declared) || declared.length < 1 || declared.length > 8 ||
125
- declared.some((version) => typeof version !== 'number' ||
126
- !Number.isSafeInteger(version) || version < 1) ||
127
- new Set(declared).size !== declared.length
128
- ) throw subscriptionError('source ' + source + ' requires 1 to 8 unique schemaVersions of at least 1.');
129
- const versions = (declared as number[]).slice().sort((left, right) => left - right);
130
- // One rule filters detail type and schema version independently, so
131
- // every event of one source shares one version set to stay exact.
132
- if (schemaVersions && schemaVersions.join(',') !== versions.join(','))
133
- throw subscriptionError('source ' + source + ' must declare the same schemaVersions for every event.');
134
- schemaVersions = versions;
135
- detailTypes.add(event.detailType);
136
- }
137
- const ruleName = '${pascalName}' + source.split('-').map((part) =>
138
- part.charAt(0).toUpperCase() + part.slice(1)).join('') + 'SubscribedEventsRule';
139
- if (!schemaVersions || ruleNames.has(ruleName))
140
- throw subscriptionError('sources must derive unique rule identities.');
141
- ruleNames.add(ruleName);
142
- subscriptions.push({
143
- detailTypes: [...detailTypes].sort(),
144
- ruleName,
145
- schemaVersions,
146
- source,
147
- });
148
- }
149
- return subscriptions.sort((left, right) =>
150
- left.source < right.source ? -1 : left.source > right.source ? 1 : 0);
151
- }
152
- `,
153
- 'infra/route-function-materialization.ts': `type RouteFunctionArgs = {
154
- ebkRouteMaterialization?: unknown;
155
- handler: string;
156
- environment?: unknown;
157
- link?: unknown;
158
- permissions?: unknown;
159
- } & Record<string, any>;
160
-
161
- type OutputFactory = (value: any) => {
162
- apply(callback: (value: any) => any): unknown;
163
- };
164
-
165
- type RouteRegistrar<Result> = (
166
- rawRoute: string,
167
- handler: string,
168
- args?: Record<string, any>,
169
- ) => Result;
170
-
171
- export function createVpcRouteFunctionMaterializer(input: {
172
- directHandlers: readonly string[];
173
- foundationVpc?: unknown;
174
- output: OutputFactory;
175
- }) {
176
- const directHandlerLimit = 2;
177
- const compositionDirectHandlerLimit = 64;
178
- const routeFunctionLimit = 23;
179
- if (
180
- !Array.isArray(input.directHandlers) ||
181
- input.directHandlers.length !== directHandlerLimit ||
182
- input.directHandlers.some(
183
- (handler) =>
184
- typeof handler !== 'string' ||
185
- handler.length === 0 ||
186
- handler.length > 256,
187
- ) ||
188
- new Set(input.directHandlers).size !== input.directHandlers.length
189
- ) {
190
- throw new Error(
191
- 'Direct API routes require the exact bounded unique handler inventory.',
192
- );
193
- }
194
- const directHandlers = new Set(input.directHandlers);
195
- const compositionDirectHandlers = new Set<string>();
196
- const routeFunctions = new Map<string, RouteFunctionArgs>();
197
- const materializedRouteFunctions = new Set<string>();
198
-
199
- const transform = (args: any): void => {
200
- if (
201
- typeof args !== 'object' ||
202
- args === null ||
203
- Array.isArray(args) ||
204
- typeof args.handler !== 'string' ||
205
- args.handler.length === 0
206
- ) {
207
- throw new Error(
208
- 'API route handler transforms require one literal handler path.',
209
- );
210
- }
211
- const routeFunction = routeFunctions.get(args.handler);
212
- if (!routeFunction) {
213
- if (directHandlers.has(args.handler)) {
214
- if (args.ebkRouteMaterialization !== undefined) {
215
- throw new Error(
216
- 'Built-in direct API route materialization authority is ambiguous.',
217
- );
218
- }
219
- return;
220
- }
221
- if (
222
- args.ebkRouteMaterialization === 'direct' &&
223
- !compositionDirectHandlers.has(args.handler) &&
224
- compositionDirectHandlers.size < compositionDirectHandlerLimit
225
- ) {
226
- delete args.ebkRouteMaterialization;
227
- compositionDirectHandlers.add(args.handler);
228
- return;
229
- }
230
- throw new Error(
231
- 'API route handler lacks registered materialization authority.',
232
- );
233
- }
234
- if (
235
- args.ebkRouteMaterialization !== undefined ||
236
- routeFunction.handler !== args.handler ||
237
- materializedRouteFunctions.has(args.handler)
238
- ) {
239
- throw new Error(
240
- 'VPC API route handler materialization authority is ambiguous.',
241
- );
242
- }
243
-
244
- // SST 4.17.1 resolves the complete FunctionArgs definition before it
245
- // calls this transform. Passing imported Foundation Outputs as that
246
- // definition can therefore defer the route component itself during
247
- // refresh. Keep the definition literal until here, then reproduce
248
- // functionBuilder's route-over-default merge exactly.
249
- const defaultEnvironment = args.environment;
250
- const defaultLink = args.link;
251
- const defaultPermissions = args.permissions;
252
- Object.assign(args, routeFunction);
253
- args.environment = input
254
- .output([defaultEnvironment, routeFunction.environment])
255
- .apply(([defaults, route]: [any, any]) => ({
256
- ...(defaults ?? {}),
257
- ...(route ?? {}),
258
- }));
259
- args.link = input
260
- .output([defaultLink, routeFunction.link])
261
- .apply(([defaults, route]: [any, any]) => [
262
- ...(defaults ?? []),
263
- ...(route ?? []),
264
- ]);
265
- args.permissions = input
266
- .output([defaultPermissions, routeFunction.permissions])
267
- .apply(([defaults, route]: [any, any]) => [
268
- ...(defaults ?? []),
269
- ...(route ?? []),
270
- ]);
271
- materializedRouteFunctions.add(args.handler);
272
- };
273
-
274
- const route = <Result>(
275
- rawRoute: string,
276
- handler: RouteFunctionArgs,
277
- args: Record<string, any> | undefined,
278
- register: RouteRegistrar<Result>,
279
- ): Result => {
280
- const handlerPath = handler.handler;
281
- if (
282
- typeof rawRoute !== 'string' ||
283
- rawRoute.length === 0 ||
284
- rawRoute.length > 512 ||
285
- typeof handlerPath !== 'string' ||
286
- handlerPath.length === 0 ||
287
- handlerPath.length > 256 ||
288
- typeof register !== 'function' ||
289
- directHandlers.has(handlerPath) ||
290
- routeFunctions.has(handlerPath) ||
291
- routeFunctions.size >= routeFunctionLimit
292
- ) {
293
- throw new Error(
294
- 'VPC API routes require one bounded unique literal handler registration.',
295
- );
296
- }
297
- routeFunctions.set(handlerPath, {
298
- ...handler,
299
- handler: handlerPath,
300
- ...(input.foundationVpc === undefined ? {} : { vpc: input.foundationVpc }),
301
- });
302
- try {
303
- return register(rawRoute, handlerPath, args);
304
- } catch (error) {
305
- routeFunctions.delete(handlerPath);
306
- throw error;
307
- }
308
- };
309
-
310
- return Object.freeze({ route, transform });
311
- }
312
- `,
313
- 'infra/next-build-authority.ts': `import {
314
- chmodSync,
315
- existsSync,
316
- lstatSync,
317
- readdirSync,
318
- realpathSync,
319
- unlinkSync,
320
- } from 'node:fs';
321
- import { join, relative, resolve } from 'node:path';
322
-
323
- const maximumEntries = 65_536;
324
- const maximumDepth = 64;
325
- const maximumFinderMetadataFiles = 256;
326
- const maximumFinderMetadataBytes = 1_048_576n;
327
-
328
- // SST 4.17.1 awaits FunctionArgs.hook.postbuild after Runtime.Build has
329
- // materialized the exact directory that its Lambda zipper consumes. Finder
330
- // metadata removed only from OpenNext's earlier output can be recreated or
331
- // copied through package-local node_modules before that boundary. Sanitize the
332
- // final derived bundle here so the bytes reviewed by the infrastructure plan
333
- // are the bytes SST packages.
334
- export function removeFinderMetadataFromBuiltFunction(rootPath: string): number {
335
- const root = resolve(rootPath);
336
- const rootIdentity = lstatSync(root, { bigint: true });
337
- if (
338
- !rootIdentity.isDirectory() ||
339
- rootIdentity.isSymbolicLink() ||
340
- realpathSync(root) !== root
341
- ) {
342
- throw new Error('The built Function root has an invalid identity.');
343
- }
344
-
345
- const pendingDirectories = [{ depth: 0, path: root }];
346
- let observedEntries = 0;
347
- let removedFinderMetadata = 0;
348
- while (pendingDirectories.length > 0) {
349
- const current = pendingDirectories.pop();
350
- if (!current) break;
351
- if (current.depth > maximumDepth) {
352
- throw new Error('The built Function tree exceeds its depth bound.');
353
- }
354
- for (const entry of readdirSync(current.path, { withFileTypes: true }).sort(
355
- (left, right) =>
356
- left.name < right.name ? -1 : left.name > right.name ? 1 : 0,
357
- )) {
358
- observedEntries += 1;
359
- if (observedEntries > maximumEntries) {
360
- throw new Error('The built Function tree exceeds its entry bound.');
361
- }
362
- const entryPath = join(current.path, entry.name);
363
- const identity = lstatSync(entryPath, { bigint: true });
364
- if (entry.name === '.DS_Store') {
365
- removedFinderMetadata += 1;
366
- if (
367
- removedFinderMetadata > maximumFinderMetadataFiles ||
368
- !identity.isFile() ||
369
- identity.isSymbolicLink() ||
370
- identity.nlink !== 1n ||
371
- identity.size > maximumFinderMetadataBytes
372
- ) {
373
- throw new Error(
374
- 'The built Function Finder metadata has an invalid identity.',
375
- );
376
- }
377
- unlinkSync(entryPath);
378
- if (existsSync(entryPath)) {
379
- throw new Error(
380
- 'The built Function Finder metadata was not removed.',
381
- );
382
- }
383
- continue;
384
- }
385
- if (identity.isDirectory() && !identity.isSymbolicLink()) {
386
- const confined = relative(root, entryPath);
387
- if (
388
- confined === '..' ||
389
- confined.startsWith('../') ||
390
- resolve(root, confined) !== entryPath
391
- ) {
392
- throw new Error('The built Function entry escapes its root.');
393
- }
394
- pendingDirectories.push({ depth: current.depth + 1, path: entryPath });
395
- }
396
- }
397
- // Finder can recreate its metadata in the interval between this hook and
398
- // SST's asynchronous glob/archive pass. On macOS, close that exact race by
399
- // removing only the owner's write bit from each completed derived
400
- // directory. The generated build wrapper restores it before the next
401
- // OpenNext build. Group/other permission bits remain unchanged.
402
- if (process.platform === 'darwin') {
403
- const currentIdentity = lstatSync(current.path, { bigint: true });
404
- if (
405
- !currentIdentity.isDirectory() ||
406
- currentIdentity.isSymbolicLink()
407
- ) {
408
- throw new Error('The built Function directory changed identity.');
409
- }
410
- chmodSync(
411
- current.path,
412
- Number((currentIdentity.mode & 0o7_777n) & ~0o200n),
413
- );
414
- if ((lstatSync(current.path, { bigint: true }).mode & 0o200n) !== 0n) {
415
- throw new Error('The built Function directory was not sealed.');
416
- }
417
- if (existsSync(join(current.path, '.DS_Store'))) {
418
- throw new Error(
419
- 'The built Function Finder metadata raced its final seal.',
420
- );
421
- }
422
- }
423
- }
424
- return removedFinderMetadata;
425
- }
426
- `,
427
- 'infra/deployment-receipt.ts': `export interface SuccessfulDeploymentReceiptExpectation {
428
- account: string;
429
- project: string;
430
- region: string;
431
- sourceCommit: string;
432
- stage: 'development' | 'staging' | 'production';
433
- }
434
-
435
- export function validateSuccessfulDeploymentReceipt(
436
- value: unknown,
437
- expected: SuccessfulDeploymentReceiptExpectation,
438
- ) {
439
- const receipt = value as {
440
- account?: unknown;
441
- authority?: unknown;
442
- children?: Array<{
443
- outcome?: unknown;
444
- project?: unknown;
445
- target?: unknown;
446
- }>;
447
- kind?: unknown;
448
- migrations?: Record<string, unknown>;
449
- outcome?: unknown;
450
- profile?: unknown;
451
- region?: unknown;
452
- schemaVersion?: unknown;
453
- smoke?: Record<string, unknown>;
454
- source?: { clean?: unknown; commit?: unknown };
455
- stage?: unknown;
456
- };
457
- const deploymentChildren = Array.isArray(receipt?.children)
458
- ? receipt.children.filter(
459
- ({ outcome, project, target }) =>
460
- outcome === 'succeeded' &&
461
- project === expected.project &&
462
- target === 'deploy',
463
- )
464
- : [];
465
- if (
466
- receipt?.kind !== 'ebk-deployment-receipt' ||
467
- receipt.schemaVersion !== 1 ||
468
- receipt.outcome !== 'succeeded' ||
469
- !['local', 'github'].includes(String(receipt.authority)) ||
470
- !['starter', 'production-isolated', 'fully-isolated'].includes(
471
- String(receipt.profile),
472
- ) ||
473
- receipt.account !== expected.account ||
474
- receipt.region !== expected.region ||
475
- receipt.stage !== expected.stage ||
476
- receipt.source?.clean !== true ||
477
- receipt.source.commit !== expected.sourceCommit ||
478
- !Array.isArray(receipt.children) ||
479
- receipt.children.some(({ outcome }) => outcome !== 'succeeded') ||
480
- deploymentChildren.length !== 1 ||
481
- receipt.migrations?.[expected.project] !== 'completed-by-deploy-target' ||
482
- receipt.smoke?.[expected.project] !== 'passed'
483
- ) {
484
- throw new Error(
485
- 'Protected performance load requires one successful exact-source native deployment receipt.',
486
- );
487
- }
488
- return Object.freeze(receipt);
489
- }
490
- `,
491
- 'infra/product.ts': `import {
492
- createManagedLogGroupContract,
493
- createRouterOriginProofInjection,
494
- resolveObservabilityPolicy,
495
- ${sql ? ' provisionDatabaseBindings,\n' : ''}\
496
- } from '@empire-builder-kit/nx/foundation';
497
- import * as random from '@pulumi/random';
498
- import { createHash } from 'node:crypto';
499
- import { readFileSync } from 'node:fs';
500
- import {
501
- ${identifierPrefix}CleanupRecordExport,
502
- ${identifierPrefix}DatabaseHealth,
503
- ${identifierPrefix}DecideRecordExport,
504
- ${identifierPrefix}DecideRecordDeletion,
505
- ${identifierPrefix}DeliverRecordExport,
506
- ${identifierPrefix}DeleteRecord,
507
- ${identifierPrefix}ExecuteRecordExport,
508
- ${identifierPrefix}ExpireRecordHold,
509
- ${identifierPrefix}GetRecord,
510
- ${identifierPrefix}Health,
511
- ${identifierPrefix}IssueRecordDelegation,
512
- ${identifierPrefix}IssueRecordHold,
513
- ${identifierPrefix}MachineAuthorizationProof,
514
- ${identifierPrefix}ProtectedExample,
515
- ${identifierPrefix}PublishCreated,
516
- ${identifierPrefix}PutRecord,
517
- ${identifierPrefix}DecideRetentionApproval,
518
- ${identifierPrefix}ReleaseRecordHold,
519
- ${identifierPrefix}RequestRecordExport,
520
- ${identifierPrefix}RequestRecordDeletion,
521
- ${identifierPrefix}RequestRetentionApproval,
522
- ${identifierPrefix}ReviewRecordHold,
523
- ${identifierPrefix}RevokeRecordDelegation,
524
- ${identifierPrefix}UseRecordDelegation,
525
- } from '../api/contracts/protected.js';
526
- import lifecycleConsumers from '../data/lifecycle-consumers.json';
527
- import observabilityPolicy from '../../../ebk.observability.json';
528
- import contractDependencies from '../contracts/dependencies.json';
529
- import eventSubscriptions from '../contracts/event-subscriptions.json';
530
- import { EventContractSchema } from '../contracts/events.js';
531
- import {
532
- crossSliceEventSubscriptions,
533
- sameSliceEventDetailTypes,
534
- } from './event-subscriptions.js';
535
- ${sql ? "import databaseBindings from '../database/bindings.json';\n" : ''}\
536
- ${sql ? "import { createSqlOutboxInfrastructure } from './sql-outbox.js';\n" : ''}\
537
- ${"import { createKeyValueInfrastructure } from './key-value.js';\n"}\
538
- ${"import { createKeyValueRetentionInfrastructure } from './key-value-retention.js';\n"}\
539
- import localConfiguration from '../configuration/local-values.json';
540
- import backgroundWorkPolicy from '../operations/background-work.json';
541
- import { backgroundWorkSchedules } from './background-work.js';
542
- import { ConfigurationDeclarations } from '../configuration/declarations.js';
543
- import { assertAsyncAdapterDeploymentReady } from '../async/recovery-adapters.js';
544
- import {
545
- getFoundationInfrastructure,
546
- ${sql ? ' registerProductMigration,\n' : ''}\
547
- registerProductRetention,
548
- } from './foundation.js';
549
- import { createVpcRouteFunctionMaterializer } from './route-function-materialization.js';
550
- import { removeFinderMetadataFromBuiltFunction } from './next-build-authority.js';
551
- import {
552
- createStandardSliceNativeRuntimeAuthority,
553
- } from './native-runtime-authority/index.js';
554
- ${sql
555
- ? `import {
556
- standardSliceDatabaseTaskFamily,
557
- } from './native-runtime-authority/effective-intent.js';
558
- `
559
- : ''}\
560
- import { createStandardSliceSecretLinks } from './personal-secrets.js';
561
- import { create${pascalName}PerformanceCostControls } from './performance-cost-controls.js';
562
- import {
563
- createStandardSliceMachineAuthorization,
564
- standardSliceMachineClientProvisionerPermissions,
565
- type MachineCredentialGeneration,
566
- } from './authorization.js';
567
- import { createStandardDataExportStore } from './data-export.js';
568
- import { create${pascalName}Reliability } from './reliability.js';
569
- ${sql ? "import { resolveStandardContainerImage } from './container-images.js';\n" : ''}\
570
- import {
571
- defineEventConsumerAlarms,
572
- } from '@empire-builder-kit/runtime/observability';
573
- import { validateSuccessfulDeploymentReceipt } from './deployment-receipt.js';
574
- // <ebk:composition-imports:start>
4
+ function renderProductInfrastructureFiles(name, pascal, capabilities) {
5
+ const buildCommand = JSON.stringify(`node -e "process.exitCode=require('@empire-builder-kit/nx/slice-scripts').buildSliceWeb()"`);
6
+ const devCommand = JSON.stringify(`node -e "require('@empire-builder-kit/nx/slice-scripts').runNativeWebCommand('${name}').then(code=>process.exitCode=code)"`);
7
+ const sql = capabilities.includes('postgres');
8
+ return {
9
+ 'infra/index.ts': `export { product as app } from './product.js';\n`,
10
+ 'infra/product.ts': `import { foundationSsmPath, isFoundationStage, productSliceRegistrationPath, resolveFoundationStages } from '@empire-builder-kit/nx/foundation';
11
+ import { sliceDataTable, sliceUserPoolClient, sliceWebAssetsBucket, sliceWebUrl } from '@empire-builder-kit/nx/slice-infra';
12
+ ${sql ? "import { sliceDatabase } from './database.js';\n" : ''}// <ebk:composition-imports:start>
575
13
  // <ebk:composition-imports:end>
576
14
 
577
- const observability = resolveObservabilityPolicy({
578
- policy: observabilityPolicy,
579
- stage: $app.stage,
580
- productionProfile: process.env.EBK_PRODUCTION_FOUNDATION_PROFILE,
581
- local: $dev,
582
- });
583
-
584
- function protectedPerformanceDeploymentAuthority(input: {
585
- enabled: string;
586
- releaseSourceCommit: string;
587
- stage: string;
588
- }) {
589
- if (input.enabled !== 'true' && input.enabled !== 'false') {
590
- throw new Error(
591
- 'EBK_PERFORMANCE_LOAD_ENABLED must equal true or false.',
592
- );
593
- }
594
- if (input.enabled === 'false') return undefined;
595
- if (!${JSON.stringify(protectedRuntimeStages)}.includes(input.stage)) {
596
- throw new Error(
597
- 'Protected performance load requires one active rehearsal or production stage.',
598
- );
599
- }
600
- const stage = input.stage as 'development' | 'production' | 'staging';
601
- const accountId = process.env.AWS_EXPECTED_ACCOUNT_ID?.trim() ?? '';
602
- const region = process.env.AWS_REGION?.trim() ?? '';
603
- if (
604
- !/^[0-9]{12}$/.test(accountId) ||
605
- !/^(?:(?:af|ap|ca|cn|eu|il|me|mx|sa|us)(?:-(?:gov|iso|isob|isoe|isof))?|eusc-[a-z]{2})-[a-z]+-\\d$/.test(
606
- region,
607
- )
608
- ) {
609
- throw new Error(
610
- 'Protected performance load AWS target is absent or malformed.',
611
- );
612
- }
613
- const candidateBytes = readFileSync(
614
- new URL(
615
- '../../../.ebk/evidence/release-candidate/packages/${name}/candidate.json',
616
- import.meta.url,
617
- ),
618
- );
619
- const candidate = JSON.parse(candidateBytes.toString('utf8')) as {
620
- kind?: unknown;
621
- schemaVersion?: unknown;
622
- slice?: unknown;
623
- sourceCommit?: unknown;
15
+ export function product() {
16
+ const stages = resolveFoundationStages({ consumerStage: $app.stage, foundationStage: process.env.EBK_FOUNDATION_STAGE });
17
+ const read = (key: Parameters<typeof foundationSsmPath>[1]) =>
18
+ aws.ssm.getParameterOutput({ name: foundationSsmPath(stages.foundationStage, key) }).value;
19
+ const router = sst.aws.Router.get('FoundationRouter', read('routerDistributionId'));
20
+ const userPool = sst.aws.CognitoUserPool.get('FoundationIdentity', read('identityUserPoolId'));
21
+ const authClient = userPool.addClient('${pascal}WebAuthClient', sliceUserPoolClient());
22
+ const tablePlan = sliceDataTable('${name}', $app.stage);
23
+ const table = new aws.dynamodb.Table('${pascal}KeyValue', tablePlan.args, tablePlan.options);
24
+ const environment = {
25
+ EBK_STAGE: $app.stage,
26
+ AUTH_CLIENT_ID: authClient.id,
27
+ AUTH_USER_POOL_ID: userPool.id,
28
+ EBK_SOURCE_COMMIT: process.env.EBK_SOURCE_COMMIT ?? '',
29
+ EBK_LOCAL_SOURCE_TREE: process.env.EBK_LOCAL_SOURCE_TREE ?? '',
30
+ EBK_KEY_VALUE_TABLE: table.name,
31
+ EVENT_BUS_NAME: read('eventBusName'),
624
32
  };
625
- if (
626
- candidate.kind !== 'ebk-release-candidate' ||
627
- candidate.schemaVersion !== 1 ||
628
- candidate.slice !== '${name}' ||
629
- candidate.sourceCommit !== input.releaseSourceCommit ||
630
- !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(input.releaseSourceCommit)
631
- ) {
632
- throw new Error(
633
- 'Protected performance load requires the exact deployed release candidate.',
634
- );
635
- }
636
- const deploymentReceiptBytes = readFileSync(
637
- new URL(
638
- '../../../.ebk/evidence/deployment/latest.json',
639
- import.meta.url,
640
- ),
641
- );
642
- validateSuccessfulDeploymentReceipt(
643
- JSON.parse(deploymentReceiptBytes.toString('utf8')),
644
- {
645
- account: accountId,
646
- project: '${name}',
647
- region,
648
- sourceCommit: input.releaseSourceCommit,
649
- stage,
650
- },
651
- );
652
- const deploymentReceiptDigest = createHash('sha256')
653
- .update(deploymentReceiptBytes)
654
- .digest('hex');
655
- return Object.freeze({
656
- candidateDigest: createHash('sha256')
657
- .update(candidateBytes)
658
- .digest('hex'),
659
- releaseId: 'release-' + deploymentReceiptDigest.slice(0, 24),
660
- releaseMaterialDigest: deploymentReceiptDigest,
661
- target: Object.freeze({
662
- accountFingerprint:
663
- 'sha256:' +
664
- createHash('sha256').update(accountId, 'utf8').digest('hex'),
665
- region,
666
- slice: '${name}',
667
- stage,
668
- }),
669
- });
670
- }
671
-
672
- function managedLogGroup(
673
- logicalName: string,
674
- component: string,
675
- alertTopicArn: any,
676
- resource?: string,
677
- ) {
678
- const contract = managedLogContract(component, resource);
679
- const logGroup = new aws.cloudwatch.LogGroup(logicalName, {
680
- logGroupClass: contract.logGroupClass,
681
- name: contract.name,
682
- retentionInDays: contract.retentionInDays,
683
- tags: contract.tags,
33
+ const api = new sst.aws.ApiGatewayV2('${pascal}Api');
34
+ const authorizer = api.addAuthorizer({
35
+ name: 'FunctionAccess',
36
+ jwt: { issuer: $interpolate\`https://cognito-idp.\${aws.getRegionOutput({}).name}.amazonaws.com/\${userPool.id}\`, audiences: [authClient.id] },
684
37
  });
685
- const dataProtection = managedLogDataProtection(
686
- logicalName,
687
- contract,
688
- logGroup.name,
689
- [logGroup],
690
- alertTopicArn,
691
- );
692
- return { contract, dataProtection, logGroup };
693
- }
694
-
695
- function managedLogContract(component: string, resource?: string) {
696
- return createManagedLogGroupContract({
697
- component,
698
- retentionInDays: observability.protectedRetentionDays,
699
- ...(resource ? { resource } : {}),
700
- slice: '${name}',
701
- stage: $app.stage,
702
- workspace: '${workspace}',
703
- });
704
- }
705
-
706
- function operationalAlarmDescription(input: {
707
- businessSymptom: string;
708
- id: string;
709
- runbook: string;
710
- }) {
711
- return JSON.stringify({
712
- businessSymptom: input.businessSymptom,
713
- id: input.id,
714
- owner: '${(0, built_in_plan_alarm_identity_js_1.sliceAlarmOwnership)(name).owner}',
715
- route: '${(0, built_in_plan_alarm_identity_js_1.sliceAlarmOwnership)(name).route}',
716
- runbook: input.runbook,
717
- schemaVersion: 1,
718
- slice: '${name}',
719
- });
720
- }
721
-
722
- // sst.aws.Queue has no name member: QueueName dimensions read the physical
723
- // aws.sqs.Queue name through nodes (nodes.queue.id is the queue URL).
724
- function physicalQueueName<Q extends { nodes: { queue: { name: unknown } } }>(
725
- queue: Q,
726
- ): Q['nodes']['queue']['name'] {
727
- return queue.nodes.queue.name;
728
- }
729
-
730
- function managedLogDataProtection(
731
- logicalName: string,
732
- contract: ReturnType<typeof createManagedLogGroupContract>,
733
- logGroupName: any,
734
- dependsOn: any[],
735
- alertTopicArn: any,
736
- ) {
737
- const policy = new aws.cloudwatch.LogDataProtectionPolicy(
738
- logicalName + 'DataProtection',
739
- {
740
- logGroupName,
741
- policyDocument: JSON.stringify(contract.dataProtectionPolicy),
742
- },
743
- { dependsOn },
744
- );
745
- const alarm = new aws.cloudwatch.MetricAlarm(
746
- logicalName + 'DataProtectionFindings',
747
- {
748
- alarmActions: [alertTopicArn],
749
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'data-protection-findings', ' ')}),
750
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
751
- dimensions: { LogGroupName: logGroupName },
752
- evaluationPeriods: 1,
753
- metricName: 'LogEventsWithFindings',
754
- namespace: 'AWS/Logs',
755
- period: 300,
756
- statistic: 'Sum',
757
- threshold: 1,
758
- treatMissingData: 'notBreaching',
759
- },
760
- { dependsOn: [policy] },
761
- );
762
- return { alarm, policy };
763
- }
764
-
765
- function lambdaLogging(logGroupName: any, functionName?: any) {
766
- return {
767
- logging: { format: 'json' as const, logGroup: logGroupName },
768
- transform: {
769
- function(args: Record<string, any>): undefined {
770
- if (functionName) args.name = functionName;
771
- args.environment = $output(args.environment ?? {}).apply(
772
- (environment: Record<string, any>) => ({
773
- ...environment,
774
- variables: $output(environment.variables ?? {}).apply(
775
- (variables: Record<string, any>) => ({
776
- ...variables,
777
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
778
- String(observability.routineSuccessSampleRate),
779
- }),
780
- ),
781
- }),
782
- );
783
- args.loggingConfig = {
784
- applicationLogLevel: 'TRACE',
785
- logFormat: 'JSON',
786
- logGroup: logGroupName,
787
- systemLogLevel: observability.systemLogLevel,
788
- };
789
- },
790
- },
38
+ const functionAccess = () => {
39
+ return { authorizationType: 'JWT', authorizerId: authorizer.id };
791
40
  };
792
- }
793
-
794
- export function product() {
795
- const backgroundSchedules = backgroundWorkSchedules(
796
- backgroundWorkPolicy,
797
- $dev ? 'development' : $app.stage,
798
- );
799
- const asyncAdaptersConfigured = assertAsyncAdapterDeploymentReady();
800
- // Declared cross-Slice subscriptions fail closed before any resource registers.
801
- const crossSliceSubscriptions = crossSliceEventSubscriptions(
802
- eventSubscriptions,
803
- contractDependencies,
804
- );
805
- const secretLinks = createStandardSliceSecretLinks();
806
- const performanceHmacLogicalName =
807
- 'GeneratedPerformanceLoadHmacKeys';
808
- const secretLinksFor = (
809
- resource: string,
810
- excludeLogicalNames: readonly string[] = [],
811
- ) =>
812
- secretLinks.linksForWorkload('${name}.' + resource, {
813
- excludeLogicalNames,
814
- });
815
- const secretLinksForWorkloads = (...resources: readonly string[]) => [
816
- ...new Set(resources.flatMap((resource) => secretLinksFor(resource))),
817
- ];
818
- // Workload generators compose multi-role secret bindings through this seam.
819
- void secretLinksForWorkloads;
820
- const devPortInput = $dev ? (process.env.EBK_DEV_PORT ?? '3000') : '3000';
821
- if (!/^\\d+$/.test(devPortInput)) {
822
- throw new Error('EBK_DEV_PORT must be an integer from 1024 through 65535.');
823
- }
824
- const devPort = Number(devPortInput);
825
- if (!Number.isSafeInteger(devPort) || devPort < 1024 || devPort > 65535) {
826
- throw new Error('EBK_DEV_PORT must be an integer from 1024 through 65535.');
827
- }
828
- const protectedStage = ${JSON.stringify(protectedRuntimeStages)}.includes(
829
- $app.stage,
830
- );
831
- const sourceCommit =
832
- process.env.EBK_SOURCE_COMMIT ?? (protectedStage ? '' : 'unresolved');
833
- const releaseSourceCommit =
834
- process.env.EBK_RELEASE_SOURCE_COMMIT ?? sourceCommit;
835
- ${sql
836
- ? ` const exactDevelopmentRetirement =
837
- $app.stage === 'development' &&
838
- Object.values(databaseBindings).some((binding) =>
839
- binding.provisioned.includes('retirement_rehearsal'),
840
- );
841
- `
842
- : ''}\
843
- if (
844
- protectedStage &&
845
- (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(sourceCommit) ||
846
- !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(releaseSourceCommit))
847
- ) {
848
- throw new Error(
849
- 'Protected infrastructure requires exact deployment and release source Git object IDs.',
850
- );
851
- }
852
- $transform(
853
- aws.lambda.Invocation,
854
- (args: any, _opts: any, logicalName: string) => {
855
- if (logicalName !== '${pascalName}WebRevalidationSeed') return;
856
- const triggers = args.triggers;
857
- if (
858
- !triggers ||
859
- typeof triggers !== 'object' ||
860
- Array.isArray(triggers) ||
861
- Object.keys(triggers).length !== 1 ||
862
- typeof triggers.version !== 'string'
863
- ) {
864
- throw new Error(
865
- 'Pinned SST Next revalidation seed does not expose one exact version trigger.',
866
- );
867
- }
868
- // SST 4.17.1 uses Date.now() here, which makes every preview propose a
869
- // replacement even when the immutable application source is unchanged.
870
- // Re-seed exactly once per released source instead.
871
- args.triggers = { version: releaseSourceCommit };
872
- },
873
- );
874
- ${''}\
875
- ${sql
876
- ? ` const databaseMigrationContainer = resolveStandardContainerImage({
877
- artifactId: '${name}.job.database-migration',
878
- local: {
879
- context: '../..',
880
- dockerfile: 'packages/${name}/migration/Dockerfile',
881
- },
882
- sourceCommit: releaseSourceCommit,
883
- stage: $app.stage,
884
- });
885
- const databaseRetirementContainer = resolveStandardContainerImage({
886
- artifactId: '${name}.job.database-retirement',
887
- exactDevelopment: exactDevelopmentRetirement,
888
- local: {
889
- context: '../..',
890
- dockerfile: 'packages/${name}/migration/Dockerfile',
891
- },
892
- sourceCommit: releaseSourceCommit,
893
- stage: $app.stage,
894
- });
895
- `
896
- : ''}\
897
- const performanceDeploymentAuthority = protectedStage
898
- ? protectedPerformanceDeploymentAuthority({
899
- enabled: process.env.EBK_PERFORMANCE_LOAD_ENABLED ?? 'false',
900
- releaseSourceCommit,
901
- stage: $app.stage,
902
- })
903
- : undefined;
904
- const foundation = getFoundationInfrastructure();
905
- ${` const keyValue = createKeyValueInfrastructure({
906
- eventBusArn: foundation.discovery.eventBusArn,
907
- eventBusName: foundation.discovery.eventBusName,
908
- alertTopicArn: foundation.discovery.alertTopicArn,
909
- outbox: backgroundSchedules.outbox,
910
- managedLogGroup,
911
- lambdaLogging,
912
- });
913
- `}\
914
- // Domain delivery is the key-value stream plus scheduled reconciliation; the
915
- // async/outbox-relay Function drains only the isolated performance sink.
916
- // Observation only: alarms never pause, drop, or retry an event intent.
917
- const keyValueStreamDeliveryErrorAlarm = new aws.cloudwatch.MetricAlarm(
918
- '${pascalName}KeyValueStreamDeliveryErrors',
919
- {
920
- alarmActions: [foundation.discovery.alertTopicArn],
921
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'key-value-stream-delivery-errors', ' ')}),
922
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
923
- dimensions: { FunctionName: keyValue.dispatcher.name },
924
- evaluationPeriods: 1,
925
- metricName: 'Errors',
926
- name: '${name}-' + $app.stage + '-key-value-stream-delivery-errors',
927
- namespace: 'AWS/Lambda',
928
- period: 300,
929
- statistic: 'Sum',
930
- threshold: 1,
931
- treatMissingData: 'notBreaching',
932
- },
933
- );
934
- const keyValueStreamIteratorAgeAlarm = new aws.cloudwatch.MetricAlarm(
935
- '${pascalName}KeyValueStreamIteratorAge',
936
- {
937
- alarmActions: [foundation.discovery.alertTopicArn],
938
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'key-value-stream-iterator-age', ' ')}),
939
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
940
- dimensions: { FunctionName: keyValue.dispatcher.name },
941
- evaluationPeriods: 1,
942
- metricName: 'IteratorAge',
943
- name: '${name}-' + $app.stage + '-key-value-stream-iterator-age',
944
- namespace: 'AWS/Lambda',
945
- period: 300,
946
- statistic: 'Maximum',
947
- threshold: 600_000,
948
- treatMissingData: 'notBreaching',
949
- },
950
- );
951
- const keyValueReconciliationErrorAlarm = new aws.cloudwatch.MetricAlarm(
952
- '${pascalName}KeyValueReconciliationErrors',
953
- {
954
- alarmActions: [foundation.discovery.alertTopicArn],
955
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'key-value-reconciliation-errors', ' ')}),
956
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
957
- dimensions: { FunctionName: keyValue.reconciler.name },
958
- evaluationPeriods: 1,
959
- metricName: 'Errors',
960
- name: '${name}-' + $app.stage + '-key-value-reconciliation-errors',
961
- namespace: 'AWS/Lambda',
962
- period: 300,
963
- statistic: 'Sum',
964
- threshold: 1,
965
- treatMissingData: 'notBreaching',
966
- },
967
- );
968
- // Reconciliation gauges are bounded per-run samples (one page per shard),
969
- // so hourly periods cover the default and any sub-hourly reconciliation
970
- // cadence. A slower configured cadence leaves empty periods, so these alarms
971
- // can miss a backlog (see each registration's expectedFalseNegativeRisk).
972
- const outboxBacklogAlarm = new aws.cloudwatch.MetricAlarm(
973
- '${pascalName}OutboxBacklog',
974
- {
975
- alarmActions: [foundation.discovery.alertTopicArn],
976
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'outbox-backlog', ' ')}),
977
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
978
- dimensions: { Slice: '${name}', Stage: $app.stage },
979
- evaluationPeriods: 2,
980
- metricName: 'OutboxBacklog',
981
- name: '${name}-' + $app.stage + '-outbox-backlog',
982
- namespace: 'EBK/Async',
983
- period: 3600,
984
- statistic: 'Maximum',
985
- threshold: 1,
986
- treatMissingData: 'notBreaching',
987
- },
988
- );
989
- const eventIntentRejectedAlarm = new aws.cloudwatch.MetricAlarm(
990
- '${pascalName}EventIntentRejected',
991
- {
992
- alarmActions: [foundation.discovery.alertTopicArn],
993
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'event-intent-rejected', ' ')}),
994
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
995
- dimensions: { Slice: '${name}', Stage: $app.stage },
996
- evaluationPeriods: 1,
997
- metricName: 'EventReconciliationRejected',
998
- name: '${name}-' + $app.stage + '-event-intent-rejected',
999
- namespace: 'EBK/Async',
1000
- period: 3600,
1001
- statistic: 'Maximum',
1002
- threshold: 1,
1003
- treatMissingData: 'notBreaching',
1004
- },
1005
- );
1006
- const eventDeliveryAttemptsAlarm = new aws.cloudwatch.MetricAlarm(
1007
- '${pascalName}EventDeliveryAttempts',
1008
- {
1009
- alarmActions: [foundation.discovery.alertTopicArn],
1010
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'event-delivery-attempts', ' ')}),
1011
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
1012
- dimensions: { Slice: '${name}', Stage: $app.stage },
1013
- evaluationPeriods: 1,
1014
- metricName: 'EventDeliveryMaxAttempts',
1015
- name: '${name}-' + $app.stage + '-event-delivery-attempts',
1016
- namespace: 'EBK/Async',
1017
- period: 3600,
1018
- statistic: 'Maximum',
1019
- threshold: 10,
1020
- treatMissingData: 'notBreaching',
1021
- },
1022
- );
1023
- const nativeAuthority = createStandardSliceNativeRuntimeAuthority({
1024
- ${sql
1025
- ? ` clusterId: foundation.discovery.clusterId,
1026
- clusterResourceId: foundation.database.clusterResourceId,
1027
- masterSecretArn: foundation.database.masterSecretArn,
1028
- `
1029
- : ''}\
1030
- eventBusArn: foundation.discovery.eventBusArn,
1031
- identityUserPoolArn: foundation.discovery.identityUserPoolArn,
1032
- });
1033
- const runtimeResourceNames = nativeAuthority.resourceNames;
1034
- $transform(aws.dynamodb.Table, (args: any, _opts: any, logicalName: string) => {
1035
- if (logicalName === '${pascalName}WebRevalidationTable') {
1036
- args.name = runtimeResourceNames.webRevalidationTable;
1037
- }
1038
- });
1039
- $transform(aws.sqs.Queue, (args: any, _opts: any, logicalName: string) => {
1040
- if (logicalName === '${pascalName}WebRevalidationEventsQueue') {
1041
- args.name = runtimeResourceNames.webRevalidationQueue;
1042
- }
1043
- });
1044
- const performanceCostControls = create${pascalName}PerformanceCostControls({
1045
- accountCostPolicyDigest: foundation.discovery.accountCostPolicyDigest,
1046
- accountMonthlyMaximumUsd:
1047
- foundation.discovery.accountMonthlyMaximumUsd,
1048
- alertTopicArn: foundation.discovery.alertTopicArn,
1049
- workspace: '${workspace}',
1050
- });
1051
- ${sql
1052
- ? ` const databaseProvisions = provisionDatabaseBindings(foundation, {
1053
- bindings: databaseBindings,
1054
- slice: '${name}',
1055
- });
1056
- const databaseProvision = databaseProvisions.bindings.primary;
1057
- const { db: database } = databaseProvision;
1058
- `
1059
- : ''}\
1060
- const authClient = foundation.userPool.addClient('${pascalName}WebAuthClient', {
1061
- transform: {
1062
- client: {
1063
- explicitAuthFlows: [
1064
- 'ALLOW_USER_PASSWORD_AUTH',
1065
- 'ALLOW_REFRESH_TOKEN_AUTH',
1066
- ],
1067
- preventUserExistenceErrors: 'ENABLED',
1068
- },
1069
- },
1070
- });
1071
- const machineClientProvisionerLogs = managedLogGroup(
1072
- '${pascalName}MachineClientProvisionerLogs',
1073
- 'machine-client-provisioner',
1074
- foundation.discovery.alertTopicArn,
1075
- );
1076
- const machineClientProvisioner = new sst.aws.Function(
1077
- '${pascalName}MachineClientProvisioner',
1078
- {
1079
- dev: false,
1080
- permissions: standardSliceMachineClientProvisionerPermissions({
1081
- userPoolArn: foundation.discovery.identityUserPoolArn,
1082
- }),
1083
- environment: {
1084
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1085
- String(observability.routineSuccessSampleRate),
1086
- EBK_SLICE: '${name}',
1087
- EBK_STAGE: $app.stage,
1088
- EBK_WORKSPACE: '${workspace}',
1089
- },
1090
- handler: 'authorization/machine-client-provisioner.handler',
1091
- link: secretLinksFor('machine-client-provisioner'),
1092
- timeout: '2 minutes',
1093
- ...lambdaLogging(machineClientProvisionerLogs.logGroup.name),
1094
- },
1095
- );
1096
- const machineAuthorization = createStandardSliceMachineAuthorization({
1097
- credentialGeneration:
1098
- (process.env.EBK_MACHINE_CREDENTIAL_GENERATION ??
1099
- 'blue-1') as MachineCredentialGeneration,
1100
- provisionerFunctionArn: machineClientProvisioner.arn,
1101
- retirePreviousGeneration:
1102
- process.env.EBK_MACHINE_RETIRE_PREVIOUS_GENERATION === 'true',
1103
- tokenEndpoint: foundation.discovery.identityTokenEndpoint,
1104
- userPoolId: foundation.userPool.id,
1105
- });
1106
- const dataExportStore = createStandardDataExportStore({
1107
- bucketName: runtimeResourceNames.dataExportBucket,
1108
- keyAliasName: runtimeResourceNames.dataExportKeyAlias,
1109
- });
1110
-
1111
- const apiHealthLogs = managedLogGroup(
1112
- '${pascalName}ApiHealthLogs',
1113
- 'api-health',
1114
- foundation.discovery.alertTopicArn,
1115
- );
1116
- const protectedApiLogs = managedLogGroup(
1117
- '${pascalName}ProtectedApiLogs',
1118
- 'api-protected',
1119
- foundation.discovery.alertTopicArn,
1120
- );
1121
- const machineAuthorizationProofLogs = managedLogGroup(
1122
- '${pascalName}MachineAuthorizationProofLogs',
1123
- 'machine-authorization-proof',
1124
- foundation.discovery.alertTopicArn,
1125
- );
1126
- const machineAuthorizationProofTargetLogs = managedLogGroup(
1127
- '${pascalName}MachineAuthorizationProofTargetLogs',
1128
- 'machine-authorization-proof-target',
1129
- foundation.discovery.alertTopicArn,
1130
- );
1131
- const delegationLogs = managedLogGroup(
1132
- '${pascalName}DelegationLogs',
1133
- 'authorization-delegations',
1134
- foundation.discovery.alertTopicArn,
1135
- );
1136
- const dataRightsLogs = managedLogGroup(
1137
- '${pascalName}DataRightsLogs',
1138
- 'data-rights',
1139
- foundation.discovery.alertTopicArn,
1140
- );
1141
- const dataRetentionReviewLogs = managedLogGroup(
1142
- '${pascalName}DataRetentionReviewLogs',
1143
- 'data-retention-review',
1144
- foundation.discovery.alertTopicArn,
1145
- );
1146
- const dataExportCleanupLogs = managedLogGroup(
1147
- '${pascalName}DataExportCleanupLogs',
1148
- 'job-data-export-cleanup',
1149
- foundation.discovery.alertTopicArn,
1150
- );
1151
- const databaseHealthLogs = managedLogGroup(
1152
- '${pascalName}DatabaseHealthLogs',
1153
- 'database-health',
1154
- foundation.discovery.alertTopicArn,
1155
- );
1156
- const databaseRecordsLogs = managedLogGroup(
1157
- '${pascalName}DatabaseRecordsLogs',
1158
- 'database-records',
1159
- foundation.discovery.alertTopicArn,
1160
- );
1161
- const eventPublisherLogs = managedLogGroup(
1162
- '${pascalName}EventPublisherLogs',
1163
- 'event-publisher',
1164
- foundation.discovery.alertTopicArn,
1165
- );
1166
- const eventConsumerLogs = managedLogGroup(
1167
- '${pascalName}EventConsumerLogs',
1168
- 'event-consumer',
1169
- foundation.discovery.alertTopicArn,
1170
- );
1171
- const asyncOutboxRelayLogs = managedLogGroup(
1172
- '${pascalName}AsyncOutboxRelayLogs',
1173
- 'async-outbox-relay',
1174
- foundation.discovery.alertTopicArn,
1175
- );
1176
- const asyncInboxCleanupLogs = managedLogGroup(
1177
- '${pascalName}AsyncInboxCleanupLogs',
1178
- 'async-inbox-cleanup',
1179
- foundation.discovery.alertTopicArn,
1180
- );
1181
- const asyncProviderWorkerLogs = asyncAdaptersConfigured || observability.retainDormantComponentLogs ? managedLogGroup(
1182
- '${pascalName}AsyncProviderWorkerLogs',
1183
- 'async-provider-worker',
1184
- foundation.discovery.alertTopicArn,
1185
- ) : undefined;
1186
- const asyncScheduleTargetLogs = managedLogGroup(
1187
- '${pascalName}AsyncScheduleTargetLogs',
1188
- 'async-schedule-target',
1189
- foundation.discovery.alertTopicArn,
1190
- );
1191
- const asyncWebhookIngressLogs = asyncAdaptersConfigured || observability.retainDormantComponentLogs ? managedLogGroup(
1192
- '${pascalName}AsyncWebhookIngressLogs',
1193
- 'async-webhook-ingress',
1194
- foundation.discovery.alertTopicArn,
1195
- ) : undefined;
1196
- const asyncWorkflowTaskLogs = managedLogGroup(
1197
- '${pascalName}AsyncWorkflowTaskLogs',
1198
- 'async-workflow-task',
1199
- foundation.discovery.alertTopicArn,
1200
- );
1201
- const nextServerLogs = managedLogGroup(
1202
- '${pascalName}NextServerLogs',
1203
- 'next-server',
1204
- foundation.discovery.alertTopicArn,
1205
- );
1206
- const nextImageOptimizerLogs = managedLogGroup(
1207
- '${pascalName}NextImageOptimizerLogs',
1208
- 'next-image-optimizer',
1209
- foundation.discovery.alertTopicArn,
1210
- );
1211
- const nextRevalidationSeederLogs = managedLogGroup(
1212
- '${pascalName}NextRevalidationSeederLogs',
1213
- 'next-revalidation-seeder',
1214
- foundation.discovery.alertTopicArn,
1215
- );
1216
- const nextRevalidationSubscriberLogs = managedLogGroup(
1217
- '${pascalName}NextRevalidationSubscriberLogs',
1218
- 'next-revalidation-subscriber',
1219
- foundation.discovery.alertTopicArn,
1220
- );
1221
-
1222
- const vpcRouteFunctionMaterializer =
1223
- createVpcRouteFunctionMaterializer({
1224
- directHandlers: [
1225
- 'api/health.handler',
1226
- 'async/webhook-ingress.handler',
1227
- ],
1228
- ${''}\
1229
- output: $output,
1230
- });
1231
- const api = new sst.aws.ApiGatewayV2('${pascalName}Api', {
1232
- ${network ? ' ...(performanceDeploymentAuthority ? { vpc: foundation.vpc } : {}),\n' : ''}\
1233
- transform: {
1234
- route: {
1235
- handler: vpcRouteFunctionMaterializer.transform,
1236
- },
1237
- },
1238
- });
1239
- const routeInVpc = (
1240
- rawRoute: string,
1241
- handler: { handler: string } & Record<string, any>,
1242
- args?: Record<string, any>,
1243
- ) =>
1244
- vpcRouteFunctionMaterializer.route(
1245
- rawRoute,
1246
- handler,
1247
- args,
1248
- (registeredRoute, registeredHandler, registeredArgs) =>
1249
- api.route(registeredRoute, registeredHandler, registeredArgs),
1250
- );
1251
- const performanceIngress = performanceDeploymentAuthority
1252
- ? (() => {
1253
- const originProof = new random.RandomPassword(
1254
- '${pascalName}PerformanceRouterOriginProof',
1255
- {
1256
- keepers: { contract: 'ebk-performance-router-origin-proof-v1' },
1257
- length: 43,
1258
- lower: true,
1259
- numeric: true,
1260
- special: false,
1261
- upper: true,
1262
- },
1263
- );
1264
- const router = new sst.aws.Router('${pascalName}PerformanceRouter', {
1265
- edge: {
1266
- viewerRequest: {
1267
- injection: originProof.result.apply(
1268
- (proof: string) =>
1269
- createRouterOriginProofInjection('${name}', proof),
1270
- ),
1271
- },
1272
- },
1273
- });
1274
- return { api, originProof: originProof.result, router };
1275
- })()
1276
- : undefined;
1277
- const performanceDeploymentBinding =
1278
- performanceDeploymentAuthority && performanceIngress
1279
- ? {
1280
- ...performanceDeploymentAuthority,
1281
- target: {
1282
- ...performanceDeploymentAuthority.target,
1283
- origin: performanceIngress.router.url,
1284
- },
1285
- }
1286
- : undefined;
1287
- api.route(${identifierPrefix}Health.method + ' ' + ${identifierPrefix}Health.path, {
1288
- permissions: nativeAuthority.permissions('api-health'),
1289
- environment: {
1290
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1291
- String(observability.routineSuccessSampleRate),
1292
- EBK_SOURCE_COMMIT: releaseSourceCommit,
1293
- EBK_STAGE: $app.stage,
1294
- },
41
+ void functionAccess;
42
+ api.route('GET /health', {
1295
43
  handler: 'api/health.handler',
1296
- link: secretLinksFor('api-health'),
1297
- ...lambdaLogging(apiHealthLogs.logGroup.name),
1298
- });
1299
- routeInVpc(
1300
- ${identifierPrefix}MachineAuthorizationProof.method +
1301
- ' ' +
1302
- ${identifierPrefix}MachineAuthorizationProof.path,
1303
- {
1304
- permissions: nativeAuthority.permissions('api-machine-authorization-proof'),
1305
- environment: {
1306
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1307
- String(observability.routineSuccessSampleRate),
1308
- ${' ...keyValue.environment,\n'}\
1309
- AUTH_CLIENT_ID: authClient.id,
1310
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1311
- machineAuthorization.acceptedClientIdsJson,
1312
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1313
- AUTH_USER_POOL_ID: foundation.userPool.id,
1314
- EBK_STAGE: $app.stage,
1315
- },
1316
- handler: 'api/machine-authorization.handler',
1317
- link: [
1318
- ${'keyValue.link'},
1319
- ...secretLinksFor('api-machine-authorization-proof'),
1320
- ],
1321
- ...lambdaLogging(machineAuthorizationProofTargetLogs.logGroup.name),
1322
- },
1323
- );
1324
- for (const route of [
1325
- {
1326
- handler: 'api/delegations.issueHandler',
1327
- operation: ${identifierPrefix}IssueRecordDelegation,
1328
- },
1329
- {
1330
- handler: 'api/delegations.useHandler',
1331
- operation: ${identifierPrefix}UseRecordDelegation,
1332
- },
1333
- {
1334
- handler: 'api/delegations.revokeHandler',
1335
- operation: ${identifierPrefix}RevokeRecordDelegation,
1336
- },
1337
- ]) {
1338
- routeInVpc(route.operation.method + ' ' + route.operation.path, {
1339
- permissions: nativeAuthority.permissions('api-delegations'),
1340
- environment: {
1341
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1342
- String(observability.routineSuccessSampleRate),
1343
- ${' ...keyValue.environment,\n'}\
1344
- AUTH_CLIENT_ID: authClient.id,
1345
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1346
- machineAuthorization.acceptedClientIdsJson,
1347
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1348
- AUTH_USER_POOL_ID: foundation.userPool.id,
1349
- EBK_STAGE: $app.stage,
1350
- },
1351
- handler: route.handler,
1352
- link: [${'keyValue.link'}, ...secretLinksFor('api-delegations')],
1353
- ...lambdaLogging(delegationLogs.logGroup.name),
1354
- });
1355
- }
1356
- for (const route of [
1357
- {
1358
- handler: 'api/data-rights.requestExportHandler',
1359
- operation: ${identifierPrefix}RequestRecordExport,
1360
- },
1361
- {
1362
- handler: 'api/data-rights.decideExportHandler',
1363
- operation: ${identifierPrefix}DecideRecordExport,
1364
- },
1365
- {
1366
- handler: 'api/data-rights.executeExportHandler',
1367
- operation: ${identifierPrefix}ExecuteRecordExport,
1368
- },
1369
- {
1370
- handler: 'api/data-rights.deliverExportHandler',
1371
- operation: ${identifierPrefix}DeliverRecordExport,
1372
- },
1373
- {
1374
- handler: 'api/data-rights.cleanupExportHandler',
1375
- operation: ${identifierPrefix}CleanupRecordExport,
1376
- },
1377
- {
1378
- handler: 'api/data-rights.issueHoldHandler',
1379
- operation: ${identifierPrefix}IssueRecordHold,
1380
- },
1381
- {
1382
- handler: 'api/data-rights.reviewHoldHandler',
1383
- operation: ${identifierPrefix}ReviewRecordHold,
1384
- },
1385
- {
1386
- handler: 'api/data-rights.releaseHoldHandler',
1387
- operation: ${identifierPrefix}ReleaseRecordHold,
1388
- },
1389
- {
1390
- handler: 'api/data-rights.expireHoldHandler',
1391
- operation: ${identifierPrefix}ExpireRecordHold,
1392
- },
1393
- ]) {
1394
- routeInVpc(route.operation.method + ' ' + route.operation.path, {
1395
- permissions: nativeAuthority.permissions('api-data-rights'),
1396
- environment: {
1397
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1398
- String(observability.routineSuccessSampleRate),
1399
- ${' ...keyValue.environment,\n'}\
1400
- AUTH_CLIENT_ID: authClient.id,
1401
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1402
- machineAuthorization.acceptedClientIdsJson,
1403
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1404
- AUTH_USER_POOL_ID: foundation.userPool.id,
1405
- DATA_EXPORT_BUCKET_NAME: dataExportStore.bucket.bucket,
1406
- DATA_EXPORT_KMS_KEY_ARN: dataExportStore.encryptionKey.arn,
1407
- EBK_STAGE: $app.stage,
1408
- EVENT_BUS_NAME: foundation.discovery.eventBusName,
1409
- },
1410
- handler: route.handler,
1411
- link: [
1412
- ${'keyValue.link'},
1413
- foundation.eventBus,
1414
- ...secretLinksFor('api-data-rights'),
1415
- ],
1416
- ...lambdaLogging(dataRightsLogs.logGroup.name),
1417
- });
1418
- }
1419
- for (const route of [
1420
- {
1421
- handler: 'api/data-retention.requestRetentionApprovalHandler',
1422
- operation: ${identifierPrefix}RequestRetentionApproval,
1423
- },
1424
- {
1425
- handler: 'api/data-retention.decideRetentionApprovalHandler',
1426
- operation: ${identifierPrefix}DecideRetentionApproval,
1427
- },
1428
- ]) {
1429
- routeInVpc(route.operation.method + ' ' + route.operation.path, {
1430
- permissions: nativeAuthority.permissions('api-database-records'),
1431
- environment: {
1432
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1433
- String(observability.routineSuccessSampleRate),
1434
- ${' ...keyValue.environment,\n'}\
1435
- AUTH_CLIENT_ID: authClient.id,
1436
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1437
- machineAuthorization.acceptedClientIdsJson,
1438
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1439
- AUTH_USER_POOL_ID: foundation.userPool.id,
1440
- EBK_STAGE: $app.stage,
1441
- },
1442
- handler: route.handler,
1443
- link: [${'keyValue.link'}, ...secretLinksFor('api-database-records')],
1444
- ...lambdaLogging(dataRetentionReviewLogs.logGroup.name),
1445
- });
1446
- }
1447
- routeInVpc(
1448
- ${identifierPrefix}ProtectedExample.method +
1449
- ' ' +
1450
- ${identifierPrefix}ProtectedExample.path,
1451
- {
1452
- permissions: nativeAuthority.permissions('api-protected'),
1453
- environment: {
1454
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1455
- String(observability.routineSuccessSampleRate),
1456
- ${' ...keyValue.environment,\n'}\
1457
- AUTH_CLIENT_ID: authClient.id,
1458
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1459
- machineAuthorization.acceptedClientIdsJson,
1460
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1461
- AUTH_USER_POOL_ID: foundation.userPool.id,
1462
- EBK_STAGE: $app.stage,
1463
- },
1464
- handler: 'api/protected.handler',
1465
- link: [${'keyValue.link'}, ...secretLinksFor('api-protected')],
1466
- ...lambdaLogging(protectedApiLogs.logGroup.name),
1467
- },
1468
- );
1469
- routeInVpc(
1470
- ${identifierPrefix}DatabaseHealth.method +
1471
- ' ' +
1472
- ${identifierPrefix}DatabaseHealth.path,
1473
- {
1474
- permissions: nativeAuthority.permissions('api-database-health'),
1475
44
  environment: {
1476
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1477
- String(observability.routineSuccessSampleRate),
1478
- ${' ...keyValue.environment,\n'}\
1479
- AUTH_CLIENT_ID: authClient.id,
1480
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1481
- machineAuthorization.acceptedClientIdsJson,
1482
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1483
- AUTH_USER_POOL_ID: foundation.userPool.id,
45
+ EBK_SOURCE_COMMIT: environment.EBK_SOURCE_COMMIT || 'unresolved',
1484
46
  EBK_STAGE: $app.stage,
1485
47
  },
1486
- handler: 'database/runtime-health.handler',
1487
- link: [${'keyValue.link'}, ...secretLinksFor('api-database-health')],
1488
- ...lambdaLogging(databaseHealthLogs.logGroup.name),
1489
- },
1490
- );
1491
- for (const route of [
1492
- {
1493
- handler: 'database/deletions.deleteHandler',
1494
- operation: ${identifierPrefix}DeleteRecord,
1495
- },
1496
- {
1497
- handler: 'database/records.getHandler',
1498
- operation: ${identifierPrefix}GetRecord,
1499
- },
1500
- {
1501
- handler: 'database/records.putHandler',
1502
- operation: ${identifierPrefix}PutRecord,
1503
- },
1504
- ]) {
1505
- routeInVpc(route.operation.method + ' ' + route.operation.path, {
1506
- permissions: nativeAuthority.permissions('api-database-records'),
1507
- environment: {
1508
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1509
- String(observability.routineSuccessSampleRate),
1510
- ${' ...keyValue.environment,\n'}\
1511
- AUTH_CLIENT_ID: authClient.id,
1512
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1513
- machineAuthorization.acceptedClientIdsJson,
1514
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1515
- AUTH_USER_POOL_ID: foundation.userPool.id,
1516
- EBK_STAGE: $app.stage,
1517
- EVENT_BUS_NAME: foundation.discovery.eventBusName,
1518
- },
1519
- handler: route.handler,
1520
- link: [
1521
- ${'keyValue.link'},
1522
- foundation.eventBus,
1523
- ...secretLinksFor('api-database-records'),
1524
- ],
1525
- ...lambdaLogging(databaseRecordsLogs.logGroup.name),
48
+ });
49
+ api.route('GET /protected', { handler: 'api/protected.handler', environment: {
50
+ EBK_STAGE: $app.stage, EBK_FUNCTION_AUTHENTICATION: 'signed-in',
51
+ } }, { transform: { route: functionAccess() } });
52
+ if (!$dev && isFoundationStage(stages.consumerStage)) {
53
+ router.route('/${name}/api/functions/', api.url, {
54
+ rewrite: { regex: '^/${name}/api/(.*)$', to: '/$1' },
1526
55
  });
1527
56
  }
1528
- for (const route of [
1529
- {
1530
- handler: 'database/deletions.requestDeletionHandler',
1531
- operation: ${identifierPrefix}RequestRecordDeletion,
1532
- },
1533
- {
1534
- handler: 'database/deletions.decideDeletionHandler',
1535
- operation: ${identifierPrefix}DecideRecordDeletion,
1536
- },
1537
- ]) {
1538
- routeInVpc(route.operation.method + ' ' + route.operation.path, {
1539
- permissions: nativeAuthority.permissions('api-database-records'),
1540
- environment: {
1541
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1542
- String(observability.routineSuccessSampleRate),
1543
- ${' ...keyValue.environment,\n'}\
1544
- AUTH_CLIENT_ID: authClient.id,
1545
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1546
- machineAuthorization.acceptedClientIdsJson,
1547
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1548
- AUTH_USER_POOL_ID: foundation.userPool.id,
1549
- EBK_STAGE: $app.stage,
1550
- },
1551
- handler: route.handler,
1552
- link: [${'keyValue.link'}, ...secretLinksFor('api-database-records')],
1553
- ...lambdaLogging(databaseRecordsLogs.logGroup.name),
57
+ let cluster: ReturnType<typeof sst.aws.Cluster.get>;
58
+ const workloadCluster = () => {
59
+ return cluster ??= sst.aws.Cluster.get('FoundationCluster', {
60
+ id: read('clusterId'), vpc: sst.aws.Vpc.get('FoundationVpc', read('vpcId')),
1554
61
  });
1555
- }
1556
- routeInVpc(
1557
- ${identifierPrefix}PublishCreated.method +
1558
- ' ' +
1559
- ${identifierPrefix}PublishCreated.path,
1560
- {
1561
- permissions: nativeAuthority.permissions('api-publish-created'),
1562
- environment: {
1563
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1564
- String(observability.routineSuccessSampleRate),
1565
- ${' ...keyValue.environment,\n'}\
1566
- AUTH_CLIENT_ID: authClient.id,
1567
- AUTH_MACHINE_ACCEPTED_CLIENT_IDS:
1568
- machineAuthorization.acceptedClientIdsJson,
1569
- AUTH_MACHINE_CLIENT_ID: machineAuthorization.clientId,
1570
- AUTH_USER_POOL_ID: foundation.userPool.id,
1571
- EBK_STAGE: $app.stage,
1572
- EVENT_BUS_NAME: foundation.discovery.eventBusName,
1573
- },
1574
- handler: 'api/publish-created.handler',
1575
- link: [
1576
- ${'keyValue.link'},
1577
- foundation.eventBus,
1578
- ...secretLinksFor('api-publish-created'),
1579
- ],
1580
- ...lambdaLogging(eventPublisherLogs.logGroup.name),
1581
- },
1582
- );
1583
- const machineAuthorizationProof = new sst.aws.Function(
1584
- '${pascalName}MachineAuthorizationProof',
1585
- {
1586
- permissions: machineAuthorization.proof.permissions,
1587
- environment: {
1588
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1589
- String(observability.routineSuccessSampleRate),
1590
- ...machineAuthorization.proof.environment,
1591
- AUTH_MACHINE_PROBE_URL:
1592
- $interpolate\`\${api.url}\${${identifierPrefix}MachineAuthorizationProof.path}\`,
1593
- EBK_STAGE: $app.stage,
1594
- },
1595
- handler: 'authorization/machine-authorization-proof.handler',
1596
- link: secretLinksFor('machine-authorization-proof'),
1597
- ...lambdaLogging(machineAuthorizationProofLogs.logGroup.name),
1598
- },
1599
- );
1600
- const dataExportCleanup = new sst.aws.Function(
1601
- '${pascalName}DataExportCleanup',
1602
- {
1603
- permissions: dataExportStore.cleanupPermissions,
1604
- environment: {
1605
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1606
- String(observability.routineSuccessSampleRate),
1607
- ${' ...keyValue.environment,\n'}\
1608
- DATA_EXPORT_BUCKET_NAME: dataExportStore.bucket.bucket,
1609
- DATA_EXPORT_KMS_KEY_ARN: dataExportStore.encryptionKey.arn,
1610
- EBK_STAGE: $app.stage,
1611
- EBK_WORKLOAD_IDENTITY: '${name}:data-export-cleanup',
1612
- },
1613
- handler: 'jobs/data-export-cleanup.handler',
1614
- link: [
1615
- ${'keyValue.link'},
1616
- ...secretLinksFor('data-export-cleanup'),
1617
- ],
1618
- ...lambdaLogging(dataExportCleanupLogs.logGroup.name),
1619
- timeout: '5 minutes',
1620
- ${''}\
1621
- },
1622
- );
1623
- const dataExportCleanupRule = new aws.cloudwatch.EventRule(
1624
- '${pascalName}DataExportCleanupSchedule',
1625
- {
1626
- name: runtimeResourceNames.dataExportCleanupRule,
1627
- description:
1628
- 'Hourly authoritative cleanup of expired confidential export versions.',
1629
- ...backgroundSchedules.exportCleanup,
1630
- tags: {
1631
- 'ebk:management': 'standard-data-export',
1632
- 'ebk:slice': '${name}',
1633
- 'sst:stage': $app.stage,
1634
- },
1635
- },
1636
- );
1637
- const dataExportCleanupPermission = new aws.lambda.Permission(
1638
- '${pascalName}DataExportCleanupPermission',
1639
- {
1640
- action: 'lambda:InvokeFunction',
1641
- function: dataExportCleanup.arn,
1642
- principal: 'events.amazonaws.com',
1643
- sourceArn: dataExportCleanupRule.arn,
1644
- },
1645
- );
1646
- const dataExportCleanupTarget = new aws.cloudwatch.EventTarget(
1647
- '${pascalName}DataExportCleanupTarget',
1648
- {
1649
- arn: dataExportCleanup.arn,
1650
- retryPolicy: {
1651
- maximumEventAgeInSeconds: 3_600,
1652
- maximumRetryAttempts: 185,
1653
- },
1654
- rule: dataExportCleanupRule.name,
1655
- targetId: 'DataExportCleanup',
1656
- },
1657
- { dependsOn: [dataExportCleanupPermission] },
1658
- );
1659
- const dataExportCleanupInvocation =
1660
- new aws.lambda.FunctionEventInvokeConfig(
1661
- '${pascalName}DataExportCleanupInvocation',
1662
- {
1663
- functionName: dataExportCleanup.arn,
1664
- maximumEventAgeInSeconds: 3_600,
1665
- maximumRetryAttempts: 2,
1666
- },
1667
- );
62
+ };
63
+ void workloadCluster;
64
+ ${sql ? ' const database = sliceDatabase(workloadCluster);\n' : ''}
1668
65
  // <ebk:function-registrations:start>
1669
66
  // <ebk:function-registrations:end>
1670
-
1671
- const eventDlq = new sst.aws.Queue('${pascalName}EventDlq', {
1672
- transform: {
1673
- queue: {
1674
- name: runtimeResourceNames.eventDlq,
1675
- messageRetentionSeconds: 14 * 24 * 60 * 60,
1676
- },
1677
- },
1678
- });
1679
- const eventQueue = new sst.aws.Queue('${pascalName}EventQueue', {
1680
- dlq: { queue: eventDlq.arn, retry: 5 },
1681
- transform: {
1682
- queue: {
1683
- name: runtimeResourceNames.eventQueue,
1684
- messageRetentionSeconds: 4 * 24 * 60 * 60,
1685
- visibilityTimeoutSeconds: 120,
1686
- },
1687
- },
1688
- });
1689
- const asyncRecoveryLedger = new aws.dynamodb.Table(
1690
- '${pascalName}AsyncRecoveryLedger',
1691
- {
1692
- attributes: [{ name: 'report_digest', type: 'S' }],
1693
- billingMode: 'PAY_PER_REQUEST',
1694
- hashKey: 'report_digest',
1695
- name: runtimeResourceNames.asyncRecoveryLedger,
1696
- pointInTimeRecovery: { enabled: true },
1697
- tags: {
1698
- 'ebk:async-recovery-ledger': 'true',
1699
- 'ebk:slice': '${name}',
1700
- 'ebk:stage': $app.stage,
1701
- },
1702
- ttl: {
1703
- attributeName: 'expires_at_epoch_seconds',
1704
- enabled: true,
1705
- },
1706
- },
1707
- );
1708
- eventQueue.subscribe({
1709
- environment: {
1710
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
1711
- String(observability.routineSuccessSampleRate),
1712
- ${' ...keyValue.environment,\n'}\
1713
- EBK_STAGE: $app.stage,
1714
- EBK_WORKLOAD_IDENTITY: '${name}:event-consumer',
1715
- },
1716
- handler: 'api/event-consumer.handler',
1717
- link: [${'keyValue.link'}, ...secretLinksFor('event-consumer')],
1718
- permissions: nativeAuthority.permissions('event-consumer'),
1719
- ...lambdaLogging(eventConsumerLogs.logGroup.name),
1720
- timeout: '1 minute',
1721
- ${''}\
1722
- }, {
1723
- batch: { partialResponses: true },
1724
- });
1725
- foundation.eventBus.subscribeQueue(
1726
- '${pascalName}CreatedEventRule',
1727
- eventQueue,
1728
- {
1729
- pattern: {
1730
- detail: { meta: { stage: [$app.stage] } },
1731
- detailType: sameSliceEventDetailTypes(EventContractSchema),
1732
- source: ['${name}'],
1733
- },
1734
- },
1735
- );
1736
- foundation.eventBus.subscribeQueue(
1737
- '${pascalName}DataLifecycleChangedRule',
1738
- eventQueue,
1739
- {
1740
- pattern: {
1741
- detail: { meta: { stage: [$app.stage] } },
1742
- detailType: ['DataLifecycleChanged'],
1743
- source: [...lifecycleConsumers.acceptedSources],
1744
- },
1745
- },
1746
- );
1747
- // One rule per declared foreign source: EventBridge ORs values within a
1748
- // field and ANDs fields, so a merged rule would cross-match sources and types.
1749
- for (const subscription of crossSliceSubscriptions) {
1750
- foundation.eventBus.subscribeQueue(
1751
- subscription.ruleName,
1752
- eventQueue,
1753
- {
1754
- pattern: {
1755
- detail: {
1756
- meta: {
1757
- schemaVersion: [...subscription.schemaVersions],
1758
- stage: [$app.stage],
1759
- },
1760
- },
1761
- detailType: [...subscription.detailTypes],
1762
- source: [subscription.source],
1763
- },
1764
- },
1765
- );
1766
- }
1767
-
1768
- const eventConsumerAlarmDefinition = defineEventConsumerAlarms({
1769
- consumer: '${pascalName}Created',
1770
- dlqName: 'event-dlq',
1771
- queueName: 'event-queue',
1772
- slice: '${name}',
1773
- stage: $app.stage,
1774
- }).alarms.find(({ severity }) => severity === 'critical');
1775
- if (!eventConsumerAlarmDefinition) {
1776
- throw new Error('Generated event-consumer DLQ alarm definition is missing.');
1777
- }
1778
- const dlqAlarm = new aws.cloudwatch.MetricAlarm('${pascalName}EventDlqDepth', {
1779
- alarmActions: [foundation.discovery.alertTopicArn],
1780
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'event-dlq-depth', ' ')}),
1781
- name: '${name}-' + $app.stage + '-event-dlq-depth',
1782
- comparisonOperator: eventConsumerAlarmDefinition.comparisonOperator,
1783
- dimensions: { QueueName: physicalQueueName(eventDlq) },
1784
- evaluationPeriods: eventConsumerAlarmDefinition.evaluationPeriods,
1785
- metricName: eventConsumerAlarmDefinition.metricName,
1786
- namespace: eventConsumerAlarmDefinition.namespace,
1787
- period: 300,
1788
- statistic: 'Maximum',
1789
- threshold: eventConsumerAlarmDefinition.threshold,
1790
- treatMissingData: 'notBreaching',
1791
- });
1792
- const asyncTargetDlq = new sst.aws.Queue(
1793
- '${pascalName}AsyncTargetDlq',
1794
- {
1795
- transform: {
1796
- queue: {
1797
- name: runtimeResourceNames.asyncTargetDlq,
1798
- messageRetentionSeconds: 14 * 24 * 60 * 60,
1799
- tags: {
1800
- 'ebk:async-recovery-source': 'async-target-dlq',
1801
- 'ebk:slice': '${name}',
1802
- 'ebk:stage': $app.stage,
1803
- },
1804
- },
1805
- },
1806
- },
1807
- );
1808
- const providerDlq = new sst.aws.Queue('${pascalName}ProviderDlq', {
1809
- transform: {
1810
- queue: {
1811
- name: runtimeResourceNames.providerDlq,
1812
- messageRetentionSeconds: 14 * 24 * 60 * 60,
1813
- tags: {
1814
- 'ebk:async-recovery-source': 'provider-dlq',
1815
- 'ebk:slice': '${name}',
1816
- 'ebk:stage': $app.stage,
1817
- },
1818
- },
1819
- },
1820
- });
1821
- const providerQueue = new sst.aws.Queue('${pascalName}ProviderQueue', {
1822
- dlq: { queue: providerDlq.arn, retry: 5 },
1823
- transform: {
1824
- queue: {
1825
- name: runtimeResourceNames.providerQueue,
1826
- messageRetentionSeconds: 4 * 24 * 60 * 60,
1827
- tags: {
1828
- 'ebk:async-recovery-destination': 'provider-queue',
1829
- 'ebk:slice': '${name}',
1830
- 'ebk:stage': $app.stage,
1831
- },
1832
- visibilityTimeoutSeconds: 120,
1833
- },
1834
- },
1835
- });
1836
- const reliability = create${pascalName}Reliability({
1837
- alertTopicArn: foundation.discovery.alertTopicArn,
1838
- alertTopicName: foundation.discovery.alertTopicArn.apply(
1839
- (alertTopicArn: string) => alertTopicArn.split(':').at(-1) ?? '',
1840
- ),
1841
- apiId: api.nodes.api.id,
1842
- ${' databaseTableName: keyValue.table.name,\n'}\
1843
- functionName: dataExportCleanup.name,
1844
- providerQueueName: physicalQueueName(providerQueue),
1845
- });
1846
- const providerDlqAlarm = new aws.cloudwatch.MetricAlarm(
1847
- '${pascalName}ProviderDlqDepth',
1848
- {
1849
- alarmActions: [foundation.discovery.alertTopicArn],
1850
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'provider-dlq-depth', ' ')}),
1851
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
1852
- dimensions: { QueueName: physicalQueueName(providerDlq) },
1853
- evaluationPeriods: 1,
1854
- metricName: 'ApproximateNumberOfMessagesVisible',
1855
- name: '${name}-' + $app.stage + '-provider-dlq-depth',
1856
- namespace: 'AWS/SQS',
1857
- period: 300,
1858
- statistic: 'Maximum',
1859
- threshold: 1,
1860
- treatMissingData: 'notBreaching',
1861
- },
1862
- );
1863
- const asyncTargetDlqAlarm = new aws.cloudwatch.MetricAlarm(
1864
- '${pascalName}AsyncTargetDlqDepth',
1865
- {
1866
- alarmActions: [foundation.discovery.alertTopicArn],
1867
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'async-target-dlq-depth', ' ')}),
1868
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
1869
- dimensions: { QueueName: physicalQueueName(asyncTargetDlq) },
1870
- evaluationPeriods: 1,
1871
- metricName: 'ApproximateNumberOfMessagesVisible',
1872
- name: '${name}-' + $app.stage + '-async-target-dlq-depth',
1873
- namespace: 'AWS/SQS',
1874
- period: 300,
1875
- statistic: 'Maximum',
1876
- threshold: 1,
1877
- treatMissingData: 'notBreaching',
1878
- },
1879
- );
1880
- const runtimeConfiguration = protectedStage && !$dev
1881
- ? (() => {
1882
- const monitorRole = nativeAuthority.createAppConfigMonitorRole(
1883
- '${pascalName}ConfigurationMonitorRole',
1884
- );
1885
- const application = new aws.appconfig.Application(
1886
- '${pascalName}ConfigurationApplication',
1887
- {
1888
- description: '${name} Slice-owned runtime configuration.',
1889
- name: 'ebk-${name}-' + $app.stage,
1890
- tags: {
1891
- 'ebk:slice': '${name}',
1892
- 'ebk:stage': $app.stage,
1893
- },
1894
- },
1895
- );
1896
- const environment = new aws.appconfig.Environment(
1897
- '${pascalName}ConfigurationEnvironment',
1898
- {
1899
- applicationId: application.id,
1900
- description:
1901
- '${name} ' + $app.stage + ' runtime configuration.',
1902
- monitors: [
1903
- reliability.apiFastBurn,
1904
- asyncTargetDlqAlarm,
1905
- dlqAlarm,
1906
- providerDlqAlarm,
1907
- reliability.providerDeadline,
1908
- ].map((alarm) => ({
1909
- alarmArn: alarm.arn,
1910
- alarmRoleArn: monitorRole.arn,
1911
- })),
1912
- name: $app.stage,
1913
- tags: {
1914
- 'ebk:slice': '${name}',
1915
- 'ebk:stage': $app.stage,
1916
- },
1917
- },
1918
- );
1919
- const profile = new aws.appconfig.ConfigurationProfile(
1920
- '${pascalName}ConfigurationProfile',
1921
- {
1922
- applicationId: application.id,
1923
- locationUri: 'hosted',
1924
- name: 'runtime',
1925
- tags: {
1926
- 'ebk:slice': '${name}',
1927
- 'ebk:stage': $app.stage,
1928
- },
1929
- type: 'AWS.Freeform',
1930
- validators: [{
1931
- content: JSON.stringify({
1932
- additionalProperties: false,
1933
- properties: {
1934
- schemaVersion: { const: 1 },
1935
- values: {
1936
- additionalProperties: false,
1937
- properties: Object.fromEntries(
1938
- ConfigurationDeclarations.map((declaration) => [
1939
- declaration.key,
1940
- declaration.validation.type === 'number'
1941
- ? {
1942
- ...(declaration.validation.integer
1943
- ? { type: 'integer' }
1944
- : { type: 'number' }),
1945
- ...(declaration.validation.maximum === undefined
1946
- ? {}
1947
- : {
1948
- maximum:
1949
- declaration.validation.maximum,
1950
- }),
1951
- ...(declaration.validation.minimum === undefined
1952
- ? {}
1953
- : {
1954
- minimum:
1955
- declaration.validation.minimum,
1956
- }),
1957
- }
1958
- : declaration.validation,
1959
- ]),
1960
- ),
1961
- required: ConfigurationDeclarations.map(
1962
- ({ key }) => key,
1963
- ),
1964
- type: 'object',
1965
- },
1966
- },
1967
- required: ['schemaVersion', 'values'],
1968
- type: 'object',
1969
- }),
1970
- type: 'JSON_SCHEMA',
1971
- }],
1972
- },
1973
- );
1974
- const version = new aws.appconfig.HostedConfigurationVersion(
1975
- '${pascalName}ConfigurationVersion',
1976
- {
1977
- applicationId: application.id,
1978
- configurationProfileId: profile.configurationProfileId,
1979
- content: JSON.stringify(localConfiguration),
1980
- contentType: 'application/json',
1981
- description:
1982
- '${name} immutable generated default configuration.',
1983
- },
1984
- );
1985
- const deploymentStrategy =
1986
- new aws.appconfig.DeploymentStrategy(
1987
- '${pascalName}ConfigurationDeploymentStrategy',
1988
- {
1989
- deploymentDurationInMinutes: 10,
1990
- description:
1991
- '${name} bounded linear runtime configuration rollout.',
1992
- finalBakeTimeInMinutes: 10,
1993
- growthFactor: 10,
1994
- growthType: 'LINEAR',
1995
- name:
1996
- 'ebk-${name}-bounded-linear-' + $app.stage,
1997
- replicateTo: 'NONE',
1998
- tags: {
1999
- 'ebk:slice': '${name}',
2000
- 'ebk:stage': $app.stage,
2001
- },
2002
- },
2003
- );
2004
- const deployment = new aws.appconfig.Deployment(
2005
- '${pascalName}ConfigurationDeployment',
2006
- {
2007
- applicationId: application.id,
2008
- configurationProfileId: profile.configurationProfileId,
2009
- configurationVersion: version.versionNumber.apply(String),
2010
- deploymentStrategyId: deploymentStrategy.id,
2011
- description:
2012
- '${name} generated default configuration deployment.',
2013
- environmentId: environment.environmentId,
2014
- },
2015
- );
2016
- return {
2017
- application,
2018
- deployment,
2019
- deploymentStrategy,
2020
- environment,
2021
- profile,
2022
- version,
2023
- };
2024
- })()
2025
- : undefined;
2026
- const configurationApplication = runtimeConfiguration?.application;
2027
- const configurationDeployment = runtimeConfiguration?.deployment;
2028
- const configurationDeploymentStrategy =
2029
- runtimeConfiguration?.deploymentStrategy;
2030
- const configurationEnvironment = runtimeConfiguration?.environment;
2031
- const configurationProfile = runtimeConfiguration?.profile;
2032
- const configurationVersion = runtimeConfiguration?.version;
2033
- const runtimeConfigurationEnvironment = runtimeConfiguration
2034
- ? {
2035
- EBK_APPCONFIG_APPLICATION_ID:
2036
- runtimeConfiguration.application.id,
2037
- EBK_APPCONFIG_ENVIRONMENT_ID:
2038
- runtimeConfiguration.environment.environmentId,
2039
- EBK_APPCONFIG_PROFILE_ID:
2040
- runtimeConfiguration.profile.configurationProfileId,
2041
- }
2042
- : {};
2043
67
  // <ebk:workload-registrations:start>
2044
68
  // <ebk:workload-registrations:end>
2045
69
 
2046
- if (asyncAdaptersConfigured) {
2047
- if (!asyncProviderWorkerLogs || !asyncWebhookIngressLogs) {
2048
- throw new Error('Configured async adapters require their protected log groups.');
2049
- }
2050
- providerQueue.subscribe(
2051
- {
2052
- environment: {
2053
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2054
- String(observability.routineSuccessSampleRate),
2055
- ${' ...keyValue.environment,\n'}\
2056
- EBK_STAGE: $app.stage,
2057
- EBK_WORKLOAD_IDENTITY: '${name}:async-provider-worker',
2058
- EBK_WORKSPACE: '${workspace}',
2059
- ...runtimeConfigurationEnvironment,
2060
- },
2061
- handler: 'async/provider-worker.handler',
2062
- link: [
2063
- ${'keyValue.link'},
2064
- providerQueue,
2065
- ...secretLinksFor('async-provider-worker'),
2066
- ],
2067
- permissions: nativeAuthority.permissions('async-provider-worker'),
2068
- ...lambdaLogging(asyncProviderWorkerLogs.logGroup.name),
2069
- timeout: '1 minute',
2070
- ${''}\
2071
- },
2072
- {
2073
- batch: { partialResponses: true },
2074
- },
2075
- configurationDeployment
2076
- ? { dependsOn: [configurationDeployment] }
2077
- : {},
2078
- );
2079
- api.route('POST /${name}/webhooks/provider', {
2080
- permissions: nativeAuthority.permissions('async-webhook-ingress'),
2081
- environment: {
2082
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2083
- String(observability.routineSuccessSampleRate),
2084
- EBK_ASYNC_LEDGER_TABLE: asyncRecoveryLedger.name,
2085
- EBK_STAGE: $app.stage,
2086
- EBK_WORKLOAD_IDENTITY: '${name}:async-webhook-ingress',
2087
- EBK_WORKSPACE: '${workspace}',
2088
- },
2089
- handler: 'async/webhook-ingress.handler',
2090
- link: [
2091
- providerQueue,
2092
- ...secretLinksFor('async-webhook-ingress'),
2093
- ],
2094
- ...lambdaLogging(asyncWebhookIngressLogs.logGroup.name),
2095
- timeout: '10 seconds',
2096
- });
2097
- }
2098
- const asyncOutboxRelay = new sst.aws.Function(
2099
- '${pascalName}AsyncOutboxRelay',
2100
- {
2101
- permissions: nativeAuthority.permissions('async-outbox-relay'),
2102
- environment: {
2103
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2104
- String(observability.routineSuccessSampleRate),
2105
- ${' ...keyValue.environment,\n'}\
2106
- ${''}\
2107
- EBK_STAGE: $app.stage,
2108
- EBK_WORKLOAD_IDENTITY: '${name}:async-outbox-relay',
2109
- EBK_WORKSPACE: '${workspace}',
2110
- EVENT_BUS_NAME: foundation.discovery.eventBusName,
2111
- },
2112
- handler: 'async/outbox-relay.handler',
2113
- link: [
2114
- ${'keyValue.link'},
2115
- foundation.eventBus,
2116
- ...secretLinksFor('async-outbox-relay'),
2117
- ],
2118
- ...lambdaLogging(asyncOutboxRelayLogs.logGroup.name),
2119
- timeout: '1 minute',
2120
- ${''}\
2121
- },
2122
- );
2123
- ${sql
2124
- ? ` const sqlOutbox = createSqlOutboxInfrastructure({
2125
- workspace: '${workspace}',
2126
- database, eventBus: foundation.eventBus, eventBusName: foundation.discovery.eventBusName,
2127
- secretLinks: secretLinksFor('async-outbox-relay'),
2128
- vpc: foundation.vpc, schedule: backgroundSchedules.sqlOutboxRecovery,
2129
- alertTopicArn: foundation.discovery.alertTopicArn,
2130
- managedLogGroup, lambdaLogging,
2131
- ${''}\
2132
- });
2133
- const sqlOutboxRelayErrorAlarm = new aws.cloudwatch.MetricAlarm(
2134
- '${pascalName}SqlOutboxRelayErrors',
2135
- {
2136
- alarmActions: [foundation.discovery.alertTopicArn],
2137
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'sql-outbox-relay-errors', ' ')}),
2138
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
2139
- dimensions: { FunctionName: sqlOutbox.relay.name },
2140
- evaluationPeriods: 1,
2141
- metricName: 'Errors',
2142
- name: '${name}-' + $app.stage + '-sql-outbox-relay-errors',
2143
- namespace: 'AWS/Lambda',
2144
- period: 300,
2145
- statistic: 'Sum',
2146
- threshold: 1,
2147
- treatMissingData: 'notBreaching',
2148
- },
2149
- );
2150
- // The relay counts every unpublished intent; Minimum ignores healthy
2151
- // in-flight batches and alarms only when no run in an hour drained it.
2152
- const sqlOutboxBacklogAlarm = new aws.cloudwatch.MetricAlarm(
2153
- '${pascalName}SqlOutboxBacklog',
2154
- {
2155
- alarmActions: [foundation.discovery.alertTopicArn],
2156
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'sql-outbox-backlog', ' ')}),
2157
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
2158
- dimensions: { Slice: '${name}', Stage: $app.stage },
2159
- evaluationPeriods: 2,
2160
- metricName: 'SqlOutboxBacklog',
2161
- name: '${name}-' + $app.stage + '-sql-outbox-backlog',
2162
- namespace: 'EBK/Async',
2163
- period: 3600,
2164
- statistic: 'Minimum',
2165
- threshold: 1,
2166
- treatMissingData: 'notBreaching',
2167
- },
2168
- );
2169
- const sqlOutboxAttemptsAlarm = new aws.cloudwatch.MetricAlarm(
2170
- '${pascalName}SqlOutboxAttempts',
2171
- {
2172
- alarmActions: [foundation.discovery.alertTopicArn],
2173
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'sql-outbox-attempts', ' ')}),
2174
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
2175
- dimensions: { Slice: '${name}', Stage: $app.stage },
2176
- evaluationPeriods: 1,
2177
- metricName: 'SqlOutboxMaxAttempts',
2178
- name: '${name}-' + $app.stage + '-sql-outbox-attempts',
2179
- namespace: 'EBK/Async',
2180
- period: 3600,
2181
- statistic: 'Maximum',
2182
- threshold: 10,
2183
- treatMissingData: 'notBreaching',
2184
- },
2185
- );
2186
- `
2187
- : ''}\
2188
- const asyncInboxCleanup = new sst.aws.Function(
2189
- '${pascalName}AsyncInboxCleanup',
2190
- {
2191
- permissions: nativeAuthority.permissions('async-inbox-cleanup'),
2192
- environment: {
2193
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2194
- String(observability.routineSuccessSampleRate),
2195
- ${' ...keyValue.environment,\n'}\
2196
- EBK_STAGE: $app.stage,
2197
- EBK_WORKLOAD_IDENTITY: '${name}:async-inbox-cleanup',
2198
- EBK_WORKSPACE: '${workspace}',
2199
- },
2200
- handler: 'async/inbox-cleanup.handler',
2201
- link: [
2202
- ${'keyValue.link'},
2203
- ...secretLinksFor('async-inbox-cleanup'),
2204
- ],
2205
- ...lambdaLogging(asyncInboxCleanupLogs.logGroup.name),
2206
- timeout: '5 minutes',
2207
- ${''}\
2208
- },
2209
- );
2210
- const asyncScheduleTarget = new sst.aws.Function(
2211
- '${pascalName}AsyncScheduleTarget',
2212
- {
2213
- permissions: nativeAuthority.permissions('async-schedule-target'),
2214
- environment: {
2215
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2216
- String(observability.routineSuccessSampleRate),
2217
- EBK_STAGE: $app.stage,
2218
- EBK_WORKLOAD_IDENTITY: '${name}:async-schedule-target',
2219
- EBK_WORKSPACE: '${workspace}',
2220
- },
2221
- handler: 'async/schedule-target.handler',
2222
- link: [providerQueue, ...secretLinksFor('async-schedule-target')],
2223
- ...lambdaLogging(asyncScheduleTargetLogs.logGroup.name),
2224
- timeout: '30 seconds',
2225
- },
2226
- );
2227
- const asyncWorkflowTask = new sst.aws.Function(
2228
- '${pascalName}AsyncWorkflowTask',
2229
- {
2230
- permissions: nativeAuthority.permissions('async-workflow-task'),
2231
- environment: {
2232
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2233
- String(observability.routineSuccessSampleRate),
2234
- EBK_ASYNC_LEDGER_TABLE: asyncRecoveryLedger.name,
2235
- EBK_STAGE: $app.stage,
2236
- EBK_WORKLOAD_IDENTITY: '${name}:async-workflow-task',
2237
- EBK_WORKSPACE: '${workspace}',
2238
- },
2239
- handler: 'async/workflow-task.handler',
2240
- link: secretLinksFor('async-workflow-task'),
2241
- ...lambdaLogging(
2242
- asyncWorkflowTaskLogs.logGroup.name,
2243
- runtimeResourceNames.workflowTaskFunction,
2244
- ),
2245
- timeout: '15 minutes',
2246
- },
2247
- );
2248
- const providerReconciliationRule = new aws.cloudwatch.EventRule(
2249
- '${pascalName}ProviderReconciliationSchedule',
2250
- {
2251
- description:
2252
- 'Versioned provider reconciliation schedule activated only with configured adapters.',
2253
- scheduleExpression: 'rate(15 minutes)',
2254
- state: asyncAdaptersConfigured ? 'ENABLED' : 'DISABLED',
2255
- tags: {
2256
- 'ebk:slice': '${name}',
2257
- 'ebk:stage': $app.stage,
2258
- },
2259
- },
2260
- );
2261
- const outboxRelayRule = new aws.cloudwatch.EventRule(
2262
- '${pascalName}OutboxRelaySchedule',
2263
- {
2264
- description:
2265
- 'Durable DynamoDB outbox relay; cadence and pause are independent of SQL capacity.',
2266
- ...backgroundSchedules.outbox,
2267
- tags: {
2268
- 'ebk:slice': '${name}',
2269
- 'ebk:stage': $app.stage,
2270
- },
2271
- },
2272
- );
2273
- const inboxCleanupRule = new aws.cloudwatch.EventRule(
2274
- '${pascalName}AsyncInboxCleanupSchedule',
2275
- {
2276
- description:
2277
- 'Bounded cleanup of expired async inbox idempotency records.',
2278
- ...backgroundSchedules.inboxCleanup,
2279
- tags: {
2280
- 'ebk:slice': '${name}',
2281
- 'ebk:stage': $app.stage,
2282
- },
2283
- },
2284
- );
2285
- const providerReconciliationPermission = new aws.lambda.Permission(
2286
- '${pascalName}ProviderReconciliationPermission',
2287
- {
2288
- action: 'lambda:InvokeFunction',
2289
- function: asyncScheduleTarget.arn,
2290
- principal: 'events.amazonaws.com',
2291
- sourceArn: providerReconciliationRule.arn,
2292
- },
2293
- );
2294
- const outboxRelayPermission = new aws.lambda.Permission(
2295
- '${pascalName}OutboxRelayPermission',
2296
- {
2297
- action: 'lambda:InvokeFunction',
2298
- function: asyncOutboxRelay.arn,
2299
- principal: 'events.amazonaws.com',
2300
- sourceArn: outboxRelayRule.arn,
2301
- },
2302
- );
2303
- const inboxCleanupPermission = new aws.lambda.Permission(
2304
- '${pascalName}AsyncInboxCleanupPermission',
2305
- {
2306
- action: 'lambda:InvokeFunction',
2307
- function: asyncInboxCleanup.arn,
2308
- principal: 'events.amazonaws.com',
2309
- sourceArn: inboxCleanupRule.arn,
2310
- },
2311
- );
2312
- const asyncTargetDlqPolicy = new aws.sqs.QueuePolicy(
2313
- '${pascalName}AsyncTargetDlqPolicy',
2314
- {
2315
- policy: aws.iam.getPolicyDocumentOutput({
2316
- statements: [{
2317
- actions: ['sqs:SendMessage'],
2318
- conditions: [{
2319
- test: 'ArnEquals',
2320
- values: [
2321
- inboxCleanupRule.arn,
2322
- providerReconciliationRule.arn,
2323
- outboxRelayRule.arn,
2324
- ],
2325
- variable: 'aws:SourceArn',
2326
- }],
2327
- principals: [{
2328
- identifiers: ['events.amazonaws.com'],
2329
- type: 'Service',
2330
- }],
2331
- resources: [asyncTargetDlq.arn],
2332
- }],
2333
- }).json,
2334
- queueUrl: asyncTargetDlq.url,
2335
- },
2336
- );
2337
- const providerReconciliationTarget = new aws.cloudwatch.EventTarget(
2338
- '${pascalName}ProviderReconciliationTarget',
2339
- {
2340
- arn: asyncScheduleTarget.arn,
2341
- deadLetterConfig: { arn: asyncTargetDlq.arn },
2342
- retryPolicy: {
2343
- maximumEventAgeInSeconds: 900,
2344
- maximumRetryAttempts: 2,
2345
- },
2346
- rule: providerReconciliationRule.name,
2347
- targetId: 'ProviderReconciliation',
2348
- },
2349
- {
2350
- dependsOn: [
2351
- asyncTargetDlqPolicy,
2352
- providerReconciliationPermission,
2353
- ],
2354
- },
2355
- );
2356
- const outboxRelayTarget = new aws.cloudwatch.EventTarget(
2357
- '${pascalName}OutboxRelayTarget',
2358
- {
2359
- arn: asyncOutboxRelay.arn,
2360
- deadLetterConfig: { arn: asyncTargetDlq.arn },
2361
- retryPolicy: {
2362
- maximumEventAgeInSeconds: 300,
2363
- maximumRetryAttempts: 2,
2364
- },
2365
- rule: outboxRelayRule.name,
2366
- targetId: 'OutboxRelay',
2367
- },
2368
- { dependsOn: [asyncTargetDlqPolicy, outboxRelayPermission] },
2369
- );
2370
- const inboxCleanupTarget = new aws.cloudwatch.EventTarget(
2371
- '${pascalName}AsyncInboxCleanupTarget',
2372
- {
2373
- arn: asyncInboxCleanup.arn,
2374
- deadLetterConfig: { arn: asyncTargetDlq.arn },
2375
- retryPolicy: {
2376
- maximumEventAgeInSeconds: 3600,
2377
- maximumRetryAttempts: 2,
2378
- },
2379
- rule: inboxCleanupRule.name,
2380
- targetId: 'AsyncInboxCleanup',
2381
- },
2382
- { dependsOn: [asyncTargetDlqPolicy, inboxCleanupPermission] },
2383
- );
2384
- let recordExportWorkflow: any;
2385
- if (!$dev && asyncAdaptersConfigured) {
2386
- const recordExportWorkflowRole = nativeAuthority.createStepFunctionsRole(
2387
- '${pascalName}RecordExportWorkflowRole',
2388
- 'async-workflow-orchestration',
70
+ const port = process.env.EBK_DEV_PORT ?? '3000';
71
+ const webAssetsBucket = aws
72
+ .getCallerIdentityOutput({})
73
+ .accountId.apply((accountId: string) =>
74
+ sliceWebAssetsBucket('${name}', $app.stage, accountId),
2389
75
  );
2390
- recordExportWorkflow = new aws.sfn.StateMachine(
2391
- '${pascalName}RecordExportWorkflow',
2392
- {
2393
- definition: $jsonStringify({
2394
- Comment: 'Versioned record export with cooperative cancellation and compensation.',
2395
- StartAt: 'RequireVersionOne',
2396
- TimeoutSeconds: 86_400,
2397
- States: {
2398
- RequireVersionOne: {
2399
- Choices: [{
2400
- Next: 'CreateExport',
2401
- NumericEquals: 1,
2402
- Variable: '$.workflowVersion',
2403
- }],
2404
- Default: 'UnsupportedVersion',
2405
- Type: 'Choice',
2406
- },
2407
- CreateExport: {
2408
- Catch: [
2409
- {
2410
- ErrorEquals: ['WorkflowEffectReconciliationRequired'],
2411
- Next: 'ReconciliationRequired',
2412
- ResultPath: '$.failure',
2413
- },
2414
- {
2415
- ErrorEquals: ['WorkflowEffectNotStartedError'],
2416
- Next: 'RetryExhaustedBeforeEffect',
2417
- ResultPath: '$.failure',
2418
- },
2419
- {
2420
- ErrorEquals: ['States.ALL'],
2421
- Next: 'CompensateAfterFailure',
2422
- ResultPath: '$.failure',
2423
- },
2424
- ],
2425
- Next: 'PostCreateCancellationBoundary',
2426
- Parameters: {
2427
- action: 'execute',
2428
- 'executionId.$': '$$.Execution.Id',
2429
- 'input.$': '$',
2430
- stepId: 'create-export',
2431
- workflowVersion: 1,
2432
- },
2433
- Resource: asyncWorkflowTask.arn,
2434
- Retry: [{
2435
- BackoffRate: 2,
2436
- ErrorEquals: ['WorkflowEffectNotStartedError'],
2437
- IntervalSeconds: 2,
2438
- MaxAttempts: 2,
2439
- }],
2440
- ResultPath: '$.createExport',
2441
- TimeoutSeconds: 900,
2442
- Type: 'Task',
2443
- },
2444
- PostCreateCancellationBoundary: {
2445
- Choices: [{
2446
- And: [
2447
- {
2448
- BooleanEquals: true,
2449
- Variable: '$.createExport.cancellationRequested',
2450
- },
2451
- {
2452
- BooleanEquals: true,
2453
- Variable: '$.createExport.sideEffectCommitted',
2454
- },
2455
- ],
2456
- Next: 'CompensateAfterCancellation',
2457
- }, {
2458
- BooleanEquals: true,
2459
- Next: 'Cancelled',
2460
- Variable: '$.createExport.cancellationRequested',
2461
- }],
2462
- Default: 'Completed',
2463
- Type: 'Choice',
2464
- },
2465
- CompensateAfterCancellation: {
2466
- Parameters: {
2467
- action: 'compensate',
2468
- 'executionId.$': '$$.Execution.Id',
2469
- 'input.$': '$',
2470
- stepId: 'remove-export',
2471
- workflowVersion: 1,
2472
- },
2473
- Resource: asyncWorkflowTask.arn,
2474
- Retry: [{
2475
- BackoffRate: 2,
2476
- ErrorEquals: ['States.TaskFailed'],
2477
- IntervalSeconds: 2,
2478
- MaxAttempts: 2,
2479
- }],
2480
- TimeoutSeconds: 300,
2481
- Type: 'Task',
2482
- Next: 'Cancelled',
2483
- },
2484
- CompensateAfterFailure: {
2485
- Parameters: {
2486
- action: 'compensate',
2487
- 'executionId.$': '$$.Execution.Id',
2488
- 'input.$': '$',
2489
- stepId: 'remove-export',
2490
- workflowVersion: 1,
2491
- },
2492
- Resource: asyncWorkflowTask.arn,
2493
- Retry: [{
2494
- BackoffRate: 2,
2495
- ErrorEquals: ['States.TaskFailed'],
2496
- IntervalSeconds: 2,
2497
- MaxAttempts: 2,
2498
- }],
2499
- TimeoutSeconds: 300,
2500
- Type: 'Task',
2501
- Next: 'FailedAfterCompensation',
2502
- },
2503
- Cancelled: { Type: 'Succeed' },
2504
- Completed: { Type: 'Succeed' },
2505
- FailedAfterCompensation: {
2506
- Cause: 'The record export failed and compensation completed.',
2507
- Error: 'RecordExportFailed',
2508
- Type: 'Fail',
2509
- },
2510
- ReconciliationRequired: {
2511
- Cause:
2512
- 'The workflow effect outcome is ambiguous and requires operator reconciliation.',
2513
- Error: 'WorkflowEffectReconciliationRequired',
2514
- Type: 'Fail',
2515
- },
2516
- RetryExhaustedBeforeEffect: {
2517
- Cause:
2518
- 'The workflow adapter proved no effect began, but its retry budget was exhausted.',
2519
- Error: 'WorkflowEffectNotStartedError',
2520
- Type: 'Fail',
2521
- },
2522
- UnsupportedVersion: {
2523
- Cause: 'No exact deployed workflow definition exists.',
2524
- Error: 'WorkflowVersionUnsupported',
2525
- Type: 'Fail',
2526
- },
2527
- },
2528
- }),
2529
- name:
2530
- 'ebk-${recordExportWorkflowName}-' +
2531
- $app.stage +
2532
- '-record-export-v1',
2533
- roleArn: recordExportWorkflowRole.arn,
2534
- tags: {
2535
- 'ebk:slice': '${name}',
2536
- 'ebk:stage': $app.stage,
2537
- 'ebk:workflow-version': '1',
2538
- },
2539
- type: 'STANDARD',
2540
- },
2541
- );
2542
- }
2543
-
2544
- const webServerLogging = lambdaLogging(nextServerLogs.logGroup.name);
2545
- const web = new sst.aws.Nextjs('${pascalName}Web', {
2546
- buildCommand: 'node ../tools/ebk-next-build-environment.mjs',
2547
- invalidation: { wait: true },
76
+ const web = new sst.aws.Nextjs('${pascal}Web', {
77
+ path: 'web',
78
+ router: { instance: router, path: '/${name}' },
79
+ buildCommand: ${buildCommand},
2548
80
  dev: {
2549
- command: 'node tools/ebk-next-dev.mjs',
2550
- directory: '.',
2551
- title: '${pascalName} web',
2552
- url: \`http://127.0.0.1:\${devPort}/${name}\`,
81
+ command: ${devCommand},
82
+ directory: '.', url: 'http://127.0.0.1:' + port + '/${name}',
2553
83
  },
2554
- environment: {
2555
- EBK_OBSERVABILITY_SUCCESS_SAMPLE_RATE:
2556
- String(observability.routineSuccessSampleRate),
2557
- ${' ...keyValue.environment,\n'}\
2558
- AUTH_CLIENT_ID: authClient.id,
2559
- AUTH_USER_POOL_ID: foundation.userPool.id,
2560
- EBK_SOURCE_COMMIT: releaseSourceCommit,
2561
- EBK_STAGE: $app.stage,
2562
- EBK_FLEET_ORIGIN: process.env.EBK_FLEET_ORIGIN ?? '',
2563
- EBK_PERFORMANCE_ACCOUNT_FINGERPRINT:
2564
- performanceDeploymentBinding?.target.accountFingerprint ?? '',
2565
- EBK_PERFORMANCE_CANDIDATE_DIGEST:
2566
- performanceDeploymentBinding?.candidateDigest ?? '',
2567
- EBK_PERFORMANCE_LOAD_ENABLED:
2568
- performanceDeploymentBinding ? 'true' : 'false',
2569
- EBK_PERFORMANCE_ORIGIN:
2570
- performanceDeploymentBinding?.target.origin ?? '',
2571
- EBK_PERFORMANCE_REGION:
2572
- performanceDeploymentBinding?.target.region ?? '',
2573
- EBK_PERFORMANCE_RELEASE_ID:
2574
- performanceDeploymentBinding?.releaseId ?? '',
2575
- EBK_PERFORMANCE_RELEASE_MATERIAL_DIGEST:
2576
- performanceDeploymentBinding?.releaseMaterialDigest ?? '',
2577
- EBK_PERFORMANCE_SLICE:
2578
- performanceDeploymentBinding?.target.slice ?? '',
2579
- EBK_SECURE_COOKIES: process.env.EBK_SECURE_COOKIES ?? '',
2580
- EVENT_BUS_NAME: foundation.discovery.eventBusName,
2581
- ...runtimeConfigurationEnvironment,
2582
- NEXT_PUBLIC_API_URL: api.url,
2583
- },
2584
- link: [keyValue.link, ${sql ? 'database, foundation.eventBus, ' : ''}foundation.userPool],
2585
- path: 'web',
2586
- router: { instance: foundation.router, path: '/${name}' },
2587
84
  transform: {
2588
85
  assets: {
2589
86
  transform: {
2590
87
  bucket: {
2591
- bucket: runtimeResourceNames.webAssetsBucket,
88
+ bucket: webAssetsBucket,
2592
89
  },
2593
90
  },
2594
91
  },
2595
- imageOptimizer: {
2596
- permissions: nativeAuthority.permissions('web-image-optimizer'),
2597
- hook: {
2598
- async postbuild(directory: string) {
2599
- removeFinderMetadataFromBuiltFunction(directory);
2600
- },
2601
- },
2602
- link: secretLinksFor('web-image-optimizer'),
2603
- ...lambdaLogging(nextImageOptimizerLogs.logGroup.name),
2604
- },
2605
- revalidationEventsSubscriber: {
2606
- permissions: nativeAuthority.permissions('web-revalidation-subscriber'),
2607
- link: secretLinksFor('web-revalidation-subscriber'),
2608
- ...lambdaLogging(nextRevalidationSubscriberLogs.logGroup.name),
2609
- },
2610
- revalidationSeeder: {
2611
- permissions: nativeAuthority.permissions('web-revalidation-seeder'),
2612
- link: secretLinksFor('web-revalidation-seeder'),
2613
- ...lambdaLogging(nextRevalidationSeederLogs.logGroup.name),
2614
- },
2615
- server(args: Record<string, unknown>) {
2616
- args.permissions = $resolve({
2617
- inherited: args.permissions,
2618
- additional: nativeAuthority.permissions('web-server'),
2619
- }).apply(({ inherited, additional }) => [
2620
- ...((inherited ?? []) as unknown[]),
2621
- ...additional,
2622
- ]);
2623
- args.hook = {
2624
- async postbuild(directory: string) {
2625
- removeFinderMetadataFromBuiltFunction(directory);
2626
- },
2627
- };
2628
- // SST applies this transform to both its dev runtime and deployed
2629
- // server. Preserve native/site links; secret links are additive.
2630
- args.link = $output(args.link ?? []).apply((links: unknown[]) => [
2631
- ...links,
2632
- ...secretLinksFor(
2633
- 'web-server',
2634
- performanceDeploymentBinding
2635
- ? []
2636
- : [performanceHmacLogicalName],
2637
- ),
2638
- ]);
2639
- Object.assign(args, webServerLogging);
2640
- args.transform = {
2641
- ...webServerLogging.transform,
2642
- ...($dev ? { role: { tags: { 'ebk:dev-runtime': 'web' } } } : {}),
2643
- };
2644
- },
2645
- },
2646
- ${sql ? ' vpc: foundation.vpc,\n' : ''}\
2647
- }, configurationDeployment
2648
- ? { dependsOn: [configurationDeployment] }
2649
- : {});
2650
- if (performanceIngress) {
2651
- for (const path of [
2652
- '/${name}/__ebk/performance/api-lambda',
2653
- '/${name}/__ebk/performance/async-worker',
2654
- '/${name}/__ebk/performance/async-worker/cleanup',
2655
- '/${name}/__ebk/performance/database',
2656
- '/${name}/__ebk/performance/database/cleanup',
2657
- ]) {
2658
- performanceIngress.router.route(path, web.url, {
2659
- connectionAttempts: 1,
2660
- connectionTimeout: '3 seconds',
2661
- readTimeout: '30 seconds',
2662
- });
2663
- }
2664
- }
2665
-
2666
- const migrationControls: Record<string, any> = {};
2667
- ${` Object.assign(migrationControls, createKeyValueRetentionInfrastructure({
2668
- keyValue, workspace: '${workspace}', eventBusArn: foundation.discovery.eventBusArn,
2669
- alertTopicArn: foundation.discovery.alertTopicArn, schedule: backgroundSchedules.retention,
2670
- scheduleName: runtimeResourceNames.dataRetentionMaintenanceRule,
2671
- managedLogGroup, lambdaLogging, register: registerProductRetention,
2672
- }));
2673
- `}\
2674
- ${sql
2675
- ? ` if (!$dev) {
2676
- const region = aws.getRegionOutput({}).name;
2677
- const taskArguments = (task: any) => ({
2678
- Cluster: task.cluster,
2679
- LaunchType: 'FARGATE',
2680
- NetworkConfiguration: {
2681
- AwsvpcConfiguration: {
2682
- AssignPublicIp: task.assignPublicIp.apply(
2683
- (value: boolean) => value ? 'ENABLED' : 'DISABLED',
2684
- ),
2685
- SecurityGroups: task.securityGroups,
2686
- Subnets: task.subnets,
2687
- },
2688
- },
2689
- TaskDefinition: task.taskDefinition,
2690
- });
2691
- const lifecycleEnvironment = (task: any, callback: boolean) =>
2692
- task.containers.apply((containers: string[]) => ({
2693
- ContainerOverrides: containers.map((containerName) => ({
2694
- Environment: [
2695
- {
2696
- Name: 'EBK_DATABASE_LIFECYCLE_CORRELATION_ID',
2697
- Value:
2698
- '{% $states.context.Execution.Input.databaseLifecycleCorrelationId %}',
2699
- },
2700
- ...(callback
2701
- ? [
2702
- {
2703
- Name: 'EBK_CANDIDATE_IDENTITY',
2704
- Value:
2705
- '{% $states.context.Execution.Input.candidateIdentity %}',
2706
- },
2707
- {
2708
- Name: 'EBK_EXECUTION_DATABASE_IDENTIFIER',
2709
- Value:
2710
- '{% $states.context.Execution.Input.databaseIdentifier %}',
2711
- },
2712
- {
2713
- Name: 'EBK_EXECUTION_SLICE',
2714
- Value: '{% $states.context.Execution.Input.slice %}',
2715
- },
2716
- {
2717
- Name: 'EBK_EXECUTION_STAGE',
2718
- Value: '{% $states.context.Execution.Input.stage %}',
2719
- },
2720
- {
2721
- Name: 'EBK_REGISTRATION_DIGEST',
2722
- Value:
2723
- '{% $states.context.Execution.Input.registrationDigest %}',
2724
- },
2725
- {
2726
- Name: 'EBK_SOURCE_COMMIT',
2727
- Value:
2728
- '{% $states.context.Execution.Input.sourceCommit %}',
2729
- },
2730
- {
2731
- Name: 'EBK_STEP_FUNCTIONS_TASK_TOKEN',
2732
- Value: '{% $states.context.Task.Token %}',
2733
- },
2734
- ]
2735
- : []),
2736
- ],
2737
- Name: containerName,
2738
- })),
2739
- }));
2740
- const createRawStateMachine = (
2741
- logicalName: string,
2742
- definition: unknown,
2743
- logGroup: any,
2744
- roleResource: string,
2745
- ) => {
2746
- const role = nativeAuthority.createStepFunctionsRole(
2747
- logicalName + 'Role',
2748
- roleResource,
2749
- );
2750
- return new aws.sfn.StateMachine(logicalName, {
2751
- definition: $jsonStringify(definition),
2752
- loggingConfiguration: {
2753
- includeExecutionData: false,
2754
- level: 'ERROR',
2755
- logDestination: $interpolate\`\${logGroup.arn}:*\`,
2756
- },
2757
- roleArn: role.arn,
2758
- type: 'STANDARD',
2759
- });
2760
- };
2761
-
2762
- ${''}\
2763
- for (const [databaseIdentifier, target] of Object.entries(
2764
- databaseProvisions.databases,
2765
- )) {
2766
- if (!target.readwriteSecretArn || !target.readonlySecretArn) {
2767
- throw new Error(
2768
- 'Deployed database target ' + databaseIdentifier +
2769
- ' is missing its generated credential references.',
2770
- );
2771
- }
2772
- const bootstrapLogContract = managedLogContract(
2773
- 'database-bootstrap',
2774
- databaseIdentifier,
2775
- );
2776
- const migrationLogContract = managedLogContract(
2777
- 'database-migration',
2778
- databaseIdentifier,
2779
- );
2780
- const retirementLogContract = managedLogContract(
2781
- 'database-retirement',
2782
- databaseIdentifier,
2783
- );
2784
- const bootstrapTask = new sst.aws.Task(
2785
- target.resourceName + 'BootstrapTask',
2786
- {
2787
- permissions: nativeAuthority.permissions(
2788
- 'database-' + databaseIdentifier + '-bootstrap-task',
2789
- ),
2790
- cluster: foundation.cluster,
2791
- command: ['node', 'jobs/bootstrap-database.mjs'],
2792
- environment: {
2793
- ...databaseMigrationContainer.environment,
2794
- AWS_REGION: region,
2795
- EBK_BOOTSTRAP_ID:
2796
- $app.name + ':' + $app.stage + ':' + databaseIdentifier,
2797
- EBK_DATABASE_HOST: foundation.database.clusterEndpoint,
2798
- EBK_DATABASE_MIGRATOR_ROLE: target.migratorRole,
2799
- EBK_DATABASE_NAME: target.databaseName,
2800
- EBK_DATABASE_PORT:
2801
- $interpolate\`\${foundation.database.port}\`,
2802
- EBK_DATABASE_READONLY_ROLE: target.readonlyRole,
2803
- EBK_DATABASE_READWRITE_ROLE: target.readwriteRole,
2804
- EBK_DATABASE_ROTATION_TOKEN: target.rotationToken ?? '',
2805
- EBK_MASTER_SECRET_ARN: foundation.database.masterSecretArn,
2806
- EBK_READONLY_SECRET_ARN: target.readonlySecretArn,
2807
- EBK_READWRITE_SECRET_ARN: target.readwriteSecretArn,
2808
- EBK_RDS_CA_BUNDLE: '/app/rds-global-bundle.pem',
2809
- EBK_RUNTIME_DATABASE_HOST: foundation.database.host,
2810
- EBK_STAGE: $app.stage,
2811
- EBK_WORKSPACE: '${workspace}',
2812
- },
2813
- image: databaseMigrationContainer.image,
2814
- link: secretLinksFor(
2815
- 'database-' + databaseIdentifier + '-bootstrap-task',
2816
- ),
2817
- logging: {
2818
- name: bootstrapLogContract.name,
2819
- retention: '1 month',
2820
- },
2821
- transform: {
2822
- logGroup: {
2823
- logGroupClass: bootstrapLogContract.logGroupClass,
2824
- retentionInDays: bootstrapLogContract.retentionInDays,
2825
- tags: bootstrapLogContract.tags,
2826
- },
2827
- taskDefinition: {
2828
- family: standardSliceDatabaseTaskFamily(
2829
- $app.stage,
2830
- databaseIdentifier,
2831
- 'bootstrap',
2832
- ),
2833
- },
2834
- },
2835
- },
2836
- );
2837
- const bootstrapLogDataProtection = managedLogDataProtection(
2838
- target.resourceName + 'BootstrapLog',
2839
- bootstrapLogContract,
2840
- bootstrapLogContract.name,
2841
- [bootstrapTask.nodes.taskDefinition],
2842
- foundation.discovery.alertTopicArn,
2843
- );
2844
- const migrationTask = new sst.aws.Task(
2845
- target.resourceName + 'MigrationTask',
2846
- {
2847
- permissions: nativeAuthority.permissions(
2848
- 'database-' + databaseIdentifier + '-migration-task',
2849
- ),
2850
- cluster: foundation.cluster,
2851
- environment: {
2852
- ...databaseMigrationContainer.environment,
2853
- AWS_REGION: region,
2854
- EBK_DATABASE_HOST: foundation.database.clusterEndpoint,
2855
- EBK_DATABASE_NAME: target.databaseName,
2856
- EBK_DATABASE_PORT:
2857
- $interpolate\`\${foundation.database.port}\`,
2858
- EBK_DATABASE_READWRITE_ROLE: target.readwriteRole,
2859
- EBK_DATABASE_USERNAME: target.migratorRole,
2860
- EBK_MIGRATION_ID:
2861
- $app.name + ':' + $app.stage + ':' + databaseIdentifier,
2862
- EBK_RDS_CA_BUNDLE: '/app/rds-global-bundle.pem',
2863
- EBK_STAGE: $app.stage,
2864
- EBK_WORKSPACE: '${workspace}',
2865
- },
2866
- image: databaseMigrationContainer.image,
2867
- link: secretLinksFor(
2868
- 'database-' + databaseIdentifier + '-migration-task',
2869
- ),
2870
- logging: {
2871
- name: migrationLogContract.name,
2872
- retention: '1 month',
2873
- },
2874
- transform: {
2875
- logGroup: {
2876
- logGroupClass: migrationLogContract.logGroupClass,
2877
- retentionInDays: migrationLogContract.retentionInDays,
2878
- tags: migrationLogContract.tags,
2879
- },
2880
- taskDefinition: {
2881
- family: standardSliceDatabaseTaskFamily(
2882
- $app.stage,
2883
- databaseIdentifier,
2884
- 'migration',
2885
- ),
2886
- },
2887
- },
2888
- },
2889
- );
2890
- const migrationLogDataProtection = managedLogDataProtection(
2891
- target.resourceName + 'MigrationLog',
2892
- migrationLogContract,
2893
- migrationLogContract.name,
2894
- [migrationTask.nodes.taskDefinition],
2895
- foundation.discovery.alertTopicArn,
2896
- );
2897
- const migrationWorkflowLogs = managedLogGroup(
2898
- target.resourceName + 'MigrationWorkflowLogs',
2899
- 'database-migration-orchestration',
2900
- foundation.discovery.alertTopicArn,
2901
- databaseIdentifier,
2902
- );
2903
- const stateMachine = createRawStateMachine(
2904
- target.resourceName + 'Migration',
2905
- {
2906
- StartAt: 'BootstrapDatabase',
2907
- States: {
2908
- BootstrapDatabase: {
2909
- Arguments: {
2910
- ...taskArguments(bootstrapTask),
2911
- Overrides: lifecycleEnvironment(bootstrapTask, false),
2912
- },
2913
- Next: 'RunDatabaseMigration',
2914
- QueryLanguage: 'JSONata',
2915
- Resource: 'arn:aws:states:::ecs:runTask.sync',
2916
- // The first bootstrap of a Slice runs minutes after its execution
2917
- // role is created; ECR can still answer "not found" to the fresh
2918
- // role and the task never starts (EBK-INT-2026-072). Bootstrap is
2919
- // idempotent, so a bounded retry is safe.
2920
- Retry: [
2921
- {
2922
- BackoffRate: 2,
2923
- ErrorEquals: ['States.TaskFailed'],
2924
- IntervalSeconds: 30,
2925
- MaxAttempts: 3,
2926
- },
2927
- ],
2928
- TimeoutSeconds: 2700,
2929
- Type: 'Task',
2930
- },
2931
- DatabaseMigrationSucceeded: {
2932
- QueryLanguage: 'JSONata',
2933
- Type: 'Succeed',
2934
- },
2935
- RunDatabaseMigration: {
2936
- Arguments: {
2937
- ...taskArguments(migrationTask),
2938
- Overrides: lifecycleEnvironment(migrationTask, false),
2939
- },
2940
- Next: 'DatabaseMigrationSucceeded',
2941
- QueryLanguage: 'JSONata',
2942
- Resource: 'arn:aws:states:::ecs:runTask.sync',
2943
- TimeoutSeconds: 2700,
2944
- Type: 'Task',
2945
- },
2946
- },
2947
- },
2948
- migrationWorkflowLogs.logGroup,
2949
- 'database-' + databaseIdentifier + '-migration-orchestration',
2950
- );
2951
- const registration = registerProductMigration(
2952
- target.resourceName + 'MigrationRegistration',
2953
- databaseIdentifier,
2954
- stateMachine.arn,
2955
- );
2956
- const retirementTask =
2957
- $app.stage === 'development' &&
2958
- databaseIdentifier === 'retirement_rehearsal'
2959
- ? new sst.aws.Task(target.resourceName + 'RetirementTask', {
2960
- permissions: nativeAuthority.permissions(
2961
- 'database-' + databaseIdentifier + '-retirement-task',
2962
- ),
2963
- cluster: foundation.cluster,
2964
- command: ['node', 'jobs/retire-database.mjs'],
2965
- environment: {
2966
- ...databaseRetirementContainer.environment,
2967
- AWS_REGION: region,
2968
- EBK_DATABASE_HOST: foundation.database.clusterEndpoint,
2969
- EBK_DATABASE_IDENTIFIER: databaseIdentifier,
2970
- EBK_DATABASE_MIGRATOR_ROLE: target.migratorRole,
2971
- EBK_DATABASE_NAME: target.databaseName,
2972
- EBK_DATABASE_PORT:
2973
- $interpolate\`\${foundation.database.port}\`,
2974
- EBK_DATABASE_READONLY_ROLE: target.readonlyRole,
2975
- EBK_DATABASE_READWRITE_ROLE: target.readwriteRole,
2976
- EBK_MASTER_SECRET_ARN: foundation.database.masterSecretArn,
2977
- EBK_RDS_CA_BUNDLE: '/app/rds-global-bundle.pem',
2978
- EBK_READONLY_SECRET_ARN: target.readonlySecretArn,
2979
- EBK_READWRITE_SECRET_ARN: target.readwriteSecretArn,
2980
- EBK_RETIREMENT_ID:
2981
- $app.name + ':' + $app.stage + ':' + databaseIdentifier,
2982
- EBK_RETAINED_SIBLINGS: $jsonStringify(
2983
- Object.entries(databaseProvisions.databases)
2984
- .filter(([identifier]) => identifier !== databaseIdentifier)
2985
- .sort(([left], [right]) =>
2986
- left < right ? -1 : left > right ? 1 : 0,
2987
- )
2988
- .map(([identifier, sibling]) => ({
2989
- databaseIdentifier: identifier,
2990
- databaseName: sibling.databaseName,
2991
- migratorRole: sibling.migratorRole,
2992
- readonlyRole: sibling.readonlyRole,
2993
- readonlySecretArn: sibling.readonlySecretArn,
2994
- readwriteRole: sibling.readwriteRole,
2995
- readwriteSecretArn: sibling.readwriteSecretArn,
2996
- })),
2997
- ),
2998
- EBK_SLICE: '${name}',
2999
- EBK_STAGE: $app.stage,
3000
- EBK_WORKSPACE: '${workspace}',
3001
- },
3002
- image: databaseRetirementContainer.image,
3003
- link: secretLinksFor(
3004
- 'database-' + databaseIdentifier + '-retirement-task',
3005
- ),
3006
- logging: {
3007
- name: retirementLogContract.name,
3008
- retention: '1 month',
3009
- },
92
+ ...($dev
93
+ ? {
94
+ server: {
3010
95
  transform: {
3011
- logGroup: {
3012
- logGroupClass: retirementLogContract.logGroupClass,
3013
- retentionInDays: retirementLogContract.retentionInDays,
3014
- tags: retirementLogContract.tags,
3015
- },
3016
- taskDefinition: {
3017
- family: standardSliceDatabaseTaskFamily(
3018
- $app.stage,
3019
- databaseIdentifier,
3020
- 'retirement',
3021
- ),
3022
- },
3023
- },
3024
- })
3025
- : undefined;
3026
- const retirementLogDataProtection = retirementTask
3027
- ? managedLogDataProtection(
3028
- target.resourceName + 'RetirementLog',
3029
- retirementLogContract,
3030
- retirementLogContract.name,
3031
- [retirementTask.nodes.taskDefinition],
3032
- foundation.discovery.alertTopicArn,
3033
- )
3034
- : undefined;
3035
- let retirementControl;
3036
- if (retirementTask) {
3037
- const retirementWorkflowLogs = managedLogGroup(
3038
- target.resourceName + 'RetirementWorkflowLogs',
3039
- 'database-retirement-orchestration',
3040
- foundation.discovery.alertTopicArn,
3041
- databaseIdentifier,
3042
- );
3043
- const retirementStateMachine = createRawStateMachine(
3044
- target.resourceName + 'MigrationRetirement',
3045
- {
3046
- StartAt: 'RetireDatabase',
3047
- States: {
3048
- DatabaseRetirementSucceeded: {
3049
- QueryLanguage: 'JSONata',
3050
- Type: 'Succeed',
3051
- },
3052
- RetireDatabase: {
3053
- Arguments: {
3054
- ...taskArguments(retirementTask),
3055
- Overrides: lifecycleEnvironment(retirementTask, true),
3056
- },
3057
- Next: 'DatabaseRetirementSucceeded',
3058
- QueryLanguage: 'JSONata',
3059
- Resource: 'arn:aws:states:::ecs:runTask.waitForTaskToken',
3060
- Retry: [
3061
- {
3062
- BackoffRate: 2,
3063
- ErrorEquals: [
3064
- 'ECS.AmazonECSException',
3065
- 'ECS.ECSException',
3066
- ],
3067
- IntervalSeconds: 10,
3068
- MaxAttempts: 2,
3069
- },
3070
- ],
3071
- TimeoutSeconds: 2700,
3072
- Type: 'Task',
96
+ role: { tags: { 'ebk:dev-runtime': 'web' } },
3073
97
  },
3074
98
  },
3075
- },
3076
- retirementWorkflowLogs.logGroup,
3077
- 'database-' + databaseIdentifier + '-retirement-orchestration',
3078
- );
3079
- retirementControl = {
3080
- retirementWorkflowLogs,
3081
- retirementStateMachine,
3082
- retirementTask,
3083
- };
3084
- }
3085
- migrationControls[databaseIdentifier] = {
3086
- bootstrapLogDataProtection,
3087
- bootstrapTask,
3088
- migrationLogDataProtection,
3089
- migrationTask,
3090
- migrationWorkflowLogs,
3091
- registration,
3092
- retirementLogDataProtection,
3093
- ...(retirementControl ?? {}),
3094
- stateMachine,
3095
- };
3096
- }
3097
- }
3098
-
3099
- `
3100
- : ''}\
3101
- const outboxRelayAlarm = new aws.cloudwatch.MetricAlarm(
3102
- '${pascalName}OutboxRelayErrors',
3103
- {
3104
- alarmActions: [foundation.discovery.alertTopicArn],
3105
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'outbox-relay-errors', ' ')}),
3106
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3107
- dimensions: { FunctionName: asyncOutboxRelay.name },
3108
- evaluationPeriods: 1,
3109
- metricName: 'Errors',
3110
- name: '${name}-' + $app.stage + '-outbox-relay-errors',
3111
- namespace: 'AWS/Lambda',
3112
- period: 300,
3113
- statistic: 'Sum',
3114
- threshold: 1,
3115
- treatMissingData: 'notBreaching',
3116
- },
3117
- );
3118
- const inboxCleanupErrorAlarm = new aws.cloudwatch.MetricAlarm(
3119
- '${pascalName}InboxCleanupErrors',
3120
- {
3121
- alarmActions: [foundation.discovery.alertTopicArn],
3122
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'inbox-cleanup-errors', ' ')}),
3123
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3124
- dimensions: { FunctionName: asyncInboxCleanup.name },
3125
- evaluationPeriods: 1,
3126
- metricName: 'Errors',
3127
- name: '${name}-' + $app.stage + '-inbox-cleanup-errors',
3128
- namespace: 'AWS/Lambda',
3129
- period: 300,
3130
- statistic: 'Sum',
3131
- threshold: 1,
3132
- treatMissingData: 'notBreaching',
99
+ }
100
+ : {}),
3133
101
  },
3134
- );
3135
- const dataExportCleanupErrorAlarm = new aws.cloudwatch.MetricAlarm(
3136
- '${pascalName}DataExportCleanupErrors',
3137
- {
3138
- alarmActions: [foundation.discovery.alertTopicArn],
3139
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'data-export-cleanup-failure', ' ')}),
3140
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3141
- dimensions: { FunctionName: dataExportCleanup.name },
3142
- evaluationPeriods: 1,
3143
- metricName: 'Errors',
3144
- name: '${name}-' + $app.stage + '-data-export-cleanup-failure',
3145
- namespace: 'AWS/Lambda',
3146
- period: 300,
3147
- statistic: 'Sum',
3148
- threshold: 1,
3149
- treatMissingData: 'notBreaching',
3150
- },
3151
- );
3152
- const dataExportCleanupInvocationAlarm =
3153
- new aws.cloudwatch.MetricAlarm(
3154
- '${pascalName}DataExportCleanupInvocationMissing',
3155
- {
3156
- alarmActions: [foundation.discovery.alertTopicArn],
3157
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'data-export-cleanup-invocation-missing', ' ')}),
3158
- comparisonOperator: 'LessThanThreshold',
3159
- dimensions: { FunctionName: dataExportCleanup.name },
3160
- evaluationPeriods: 2,
3161
- metricName: 'Invocations',
3162
- name:
3163
- '${name}-' +
3164
- $app.stage +
3165
- '-data-export-cleanup-invocation-missing',
3166
- namespace: 'AWS/Lambda',
3167
- period: 3600,
3168
- statistic: 'Sum',
3169
- threshold: 1,
3170
- treatMissingData: 'breaching',
3171
- },
3172
- );
3173
- const inboxCleanupBacklogAlarm = new aws.cloudwatch.MetricAlarm(
3174
- '${pascalName}InboxCleanupBacklog',
3175
- {
3176
- alarmActions: [foundation.discovery.alertTopicArn],
3177
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'inbox-cleanup-backlog', ' ')}),
3178
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3179
- dimensions: {
3180
- Component: 'inbox-cleanup',
3181
- Feature: 'async-work',
3182
- Operation: 'inbox-cleanup',
3183
- Slice: '${name}',
3184
- Stage: $app.stage,
3185
- },
3186
- evaluationPeriods: 2,
3187
- metricName: 'InboxCleanupBacklog',
3188
- name: '${name}-' + $app.stage + '-inbox-cleanup-backlog',
3189
- namespace: 'EBK/Async',
3190
- period: 3600,
3191
- statistic: 'Maximum',
3192
- threshold: 1,
3193
- treatMissingData: 'notBreaching',
3194
- },
3195
- );
3196
- const dataExportCleanupDeadlineAlarm =
3197
- new aws.cloudwatch.MetricAlarm(
3198
- '${pascalName}DataExportCleanupDeadline',
3199
- {
3200
- alarmActions: [foundation.discovery.alertTopicArn],
3201
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'data-export-cleanup-deadline', ' ')}),
3202
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3203
- dimensions: {
3204
- Component: 'data-export-cleanup',
3205
- Feature: 'data-lifecycle',
3206
- Operation: 'expiry-cleanup',
3207
- Slice: '${name}',
3208
- Stage: $app.stage,
3209
- },
3210
- evaluationPeriods: 1,
3211
- metricName: 'DataExportCleanupDeadlineBreaches',
3212
- name:
3213
- '${name}-' +
3214
- $app.stage +
3215
- '-data-export-cleanup-deadline',
3216
- namespace: 'EBK/DataLifecycle',
3217
- period: 3600,
3218
- statistic: 'Maximum',
3219
- threshold: 1,
3220
- treatMissingData: 'notBreaching',
3221
- },
3222
- );
3223
- const performanceLoadCleanupBacklogAlarm =
3224
- new aws.cloudwatch.MetricAlarm(
3225
- '${pascalName}PerformanceLoadCleanupBacklog',
3226
- {
3227
- alarmActions: [foundation.discovery.alertTopicArn],
3228
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'performance-load-cleanup-backlog', ' ')}),
3229
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3230
- dimensions: {
3231
- Component: 'performance-load-cleanup',
3232
- Feature: 'performance',
3233
- Operation: 'expiry-cleanup',
3234
- Slice: '${name}',
3235
- Stage: $app.stage,
3236
- },
3237
- evaluationPeriods: 2,
3238
- metricName: 'PerformanceLoadCleanupBacklog',
3239
- name:
3240
- '${name}-' +
3241
- $app.stage +
3242
- '-performance-load-cleanup-backlog',
3243
- namespace: 'EBK/Performance',
3244
- period: 3600,
3245
- statistic: 'Maximum',
3246
- threshold: 1,
3247
- treatMissingData: 'notBreaching',
3248
- },
3249
- );
3250
- const performanceLoadCleanupDeadlineAlarm =
3251
- new aws.cloudwatch.MetricAlarm(
3252
- '${pascalName}PerformanceLoadCleanupDeadline',
3253
- {
3254
- alarmActions: [foundation.discovery.alertTopicArn],
3255
- alarmDescription: operationalAlarmDescription(${(0, built_in_plan_alarm_identity_js_1.renderSliceAlarmDescriptionInput)(name, 'performance-load-cleanup-deadline', ' ')}),
3256
- comparisonOperator: 'GreaterThanOrEqualToThreshold',
3257
- dimensions: {
3258
- Component: 'performance-load-cleanup',
3259
- Feature: 'performance',
3260
- Operation: 'expiry-cleanup',
3261
- Slice: '${name}',
3262
- Stage: $app.stage,
3263
- },
3264
- evaluationPeriods: 1,
3265
- metricName: 'PerformanceLoadCleanupDeadlineBreaches',
3266
- name:
3267
- '${name}-' +
3268
- $app.stage +
3269
- '-performance-load-cleanup-deadline',
3270
- namespace: 'EBK/Performance',
3271
- period: 3600,
3272
- statistic: 'Maximum',
3273
- threshold: 1,
3274
- treatMissingData: 'notBreaching',
3275
- },
3276
- );
3277
- const dashboard = observability.dashboards === 'slice'
3278
- ? new aws.cloudwatch.Dashboard('${pascalName}Dashboard', {
3279
- dashboardName: '${name}-' + $app.stage,
3280
- dashboardBody: $resolve({
3281
- table: keyValue.table.name,
3282
- dispatcher: keyValue.dispatcher.name,
3283
- reconciler: keyValue.reconciler.name,
3284
- providerQueue: physicalQueueName(providerQueue),
3285
- providerDlq: physicalQueueName(providerDlq),
3286
- }).apply(({ table, dispatcher, reconciler, providerQueue, providerDlq }) => JSON.stringify({
3287
- widgets: [
3288
- {
3289
- type: 'metric', x: 0, y: 0, width: 12, height: 6,
3290
- properties: {
3291
- title: '${pascalName} delivery errors and throttles',
3292
- region: process.env.AWS_REGION ?? 'us-east-1',
3293
- period: 300, stat: 'Sum',
3294
- metrics: [
3295
- ['AWS/Lambda', 'Errors', 'FunctionName', dispatcher],
3296
- ['.', 'Throttles', '.', '.'],
3297
- ['.', 'Errors', '.', reconciler],
3298
- ['.', 'Throttles', '.', '.'],
3299
- ],
3300
- },
3301
- },
3302
- {
3303
- type: 'metric', x: 12, y: 0, width: 12, height: 6,
3304
- properties: {
3305
- title: '${pascalName} durable storage capacity',
3306
- region: process.env.AWS_REGION ?? 'us-east-1',
3307
- period: 300, stat: 'Sum',
3308
- metrics: [
3309
- ['AWS/DynamoDB', 'ConsumedReadCapacityUnits', 'TableName', table],
3310
- ['.', 'ConsumedWriteCapacityUnits', '.', '.'],
3311
- ['.', 'ThrottledRequests', '.', '.', 'Operation', 'PutItem'],
3312
- ],
3313
- },
3314
- },
3315
- {
3316
- type: 'metric', x: 0, y: 6, width: 24, height: 6,
3317
- properties: {
3318
- title: '${pascalName} provider backlog and dead letters',
3319
- region: process.env.AWS_REGION ?? 'us-east-1',
3320
- period: 300, stat: 'Maximum',
3321
- metrics: [
3322
- ['AWS/SQS', 'ApproximateNumberOfMessagesVisible', 'QueueName', providerQueue],
3323
- ['.', '.', '.', providerDlq],
3324
- ['.', 'ApproximateAgeOfOldestMessage', '.', providerQueue],
3325
- ],
3326
- },
3327
- },
3328
- ],
3329
- })),
3330
- }) : undefined;
102
+ ${sql ? " link: [database], vpc: sst.aws.Vpc.get('WebDatabaseVpc', read('vpcId')),\n" : ''} permissions: [{
103
+ actions: ['dynamodb:GetItem','dynamodb:PutItem','dynamodb:UpdateItem','dynamodb:DeleteItem','dynamodb:ConditionCheckItem','dynamodb:Query'],
104
+ resources: [table.arn],
105
+ }],
106
+ environment: { ...environment, EBK_FLEET_ORIGIN: process.env.EBK_FLEET_ORIGIN ?? '', EBK_SECURE_COOKIES: process.env.EBK_SECURE_COOKIES ?? '', NEXT_PUBLIC_API_URL: api.url },
107
+ });
108
+ const registration = new aws.ssm.Parameter('${pascal}ProductSliceRegistration', {
109
+ name: productSliceRegistrationPath(stages.foundationStage, stages.consumerStage, '${name}'),
110
+ type: 'String', value: JSON.stringify({ consumerStage: stages.consumerStage, foundationStage: stages.foundationStage, name: '${name}', registrationVersion: 1, foundationContract: '^2.0.0' }),
111
+ });
3331
112
  return {
3332
- api,
3333
- asyncInboxCleanup,
3334
- dataExportCleanupDeadlineAlarm,
3335
- dataExportCleanupErrorAlarm,
3336
- dataExportCleanupInvocationAlarm,
3337
- inboxCleanupErrorAlarm,
3338
- inboxCleanupBacklogAlarm,
3339
- inboxCleanupRule,
3340
- inboxCleanupTarget,
3341
- performanceLoadCleanupBacklogAlarm,
3342
- performanceLoadCleanupDeadlineAlarm,
3343
- asyncOutboxRelay,
3344
- ${sql ? ' sqlOutbox,\n sqlOutboxAttemptsAlarm,\n sqlOutboxBacklogAlarm,\n sqlOutboxRelayErrorAlarm,\n' : ''}\
3345
- asyncRecoveryLedger,
3346
- asyncScheduleTarget,
3347
- asyncTargetDlq,
3348
- asyncTargetDlqAlarm,
3349
- asyncTargetDlqPolicy,
3350
- asyncWorkflowTask,
3351
- authClient,
3352
- configurationApplication,
3353
- configurationDeployment,
3354
- configurationDeploymentStrategy,
3355
- configurationEnvironment,
3356
- configurationProfile,
3357
- configurationVersion,
3358
- dashboard,
3359
- dataExportCleanup,
3360
- dataExportCleanupInvocation,
3361
- dataExportCleanupRule,
3362
- dataExportCleanupTarget,
3363
- dataExportStore,
3364
- ${sql ? ' database,\n' : ''}\
3365
- ${' keyValue,\n'}\
3366
- dlqAlarm,
3367
- eventDlq,
3368
- eventQueue,
3369
- machineClientProvisioner,
3370
- migrationControls,
3371
- eventDeliveryAttemptsAlarm,
3372
- eventIntentRejectedAlarm,
3373
- keyValueReconciliationErrorAlarm,
3374
- keyValueStreamDeliveryErrorAlarm,
3375
- keyValueStreamIteratorAgeAlarm,
3376
- outboxBacklogAlarm,
3377
- outboxRelayAlarm,
3378
- outboxRelayRule,
3379
- outboxRelayTarget,
3380
- performanceCostControls,
3381
- performanceEndpoint: performanceIngress?.router.url,
3382
- providerDlq,
3383
- providerDlqAlarm,
3384
- providerQueue,
3385
- reliability,
3386
- providerReconciliationRule,
3387
- providerReconciliationTarget,
3388
- recordExportWorkflow,
3389
- machineAuthorization,
3390
- machineAuthorizationProof,
3391
- web,
113
+ apiId: api.nodes.api.id, apiUrl: api.url, authClientId: authClient.id, authUserPoolId: userPool.id,
3392
114
  // <ebk:composition-outputs:start>
3393
115
  // <ebk:composition-outputs:end>
116
+ name: '${name}', stage: $app.stage, registration: registration.name,
117
+ webUrl: $dev ? web.url : read('routerUrl').apply((origin: string) => sliceWebUrl('${name}', origin)),
3394
118
  };
3395
119
  }
3396
120
  `,
3397
121
  };
3398
- Object.assign(files, (0, built_in_plan_key_value_retention_infrastructure_js_1.renderKeyValueRetentionInfrastructureFiles)(name, pascalName));
3399
- return files;
3400
122
  }
3401
123
  //# sourceMappingURL=built-in-plan-infrastructure-files.js.map