@aws/nx-plugin 1.0.0-rc.32 → 1.0.0-rc.34

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 (277) hide show
  1. package/LICENSE-THIRD-PARTY +75 -86
  2. package/generators.json +27 -0
  3. package/package.json +10 -10
  4. package/src/connection/generator.js +12 -1
  5. package/src/connection/generator.js.map +1 -1
  6. package/src/connection/supported-connections.d.ts +10 -1
  7. package/src/connection/supported-connections.js +13 -0
  8. package/src/connection/supported-connections.js.map +1 -1
  9. package/src/infra/app/__snapshots__/generator.spec.ts.snap +21 -21
  10. package/src/infra/app/files/app/src/main.ts.template +1 -1
  11. package/src/infra/app/files/app/src/stages/application-stage.ts.template +1 -1
  12. package/src/infra/app/generator.js +3 -1
  13. package/src/infra/app/generator.js.map +1 -1
  14. package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +12 -12
  15. package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +74 -10
  16. package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +22 -4
  17. package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +53 -8
  18. package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +32 -4
  19. package/src/open-api/ts-client/__snapshots__/generator.fast-api-gaps.spec.ts.snap +736 -0
  20. package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +86 -11
  21. package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +21 -3
  22. package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +2 -2
  23. package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +6 -6
  24. package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +2 -2
  25. package/src/open-api/ts-client/__snapshots__/generator.spec-compliance.spec.ts.snap +1883 -0
  26. package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +4 -4
  27. package/src/open-api/ts-client/files/client.gen.ts.template +196 -13
  28. package/src/open-api/ts-client/files/types.gen.ts.template +2 -0
  29. package/src/open-api/ts-client/generator.js +27 -2
  30. package/src/open-api/ts-client/generator.js.map +1 -1
  31. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +2 -2
  32. package/src/open-api/ts-hooks/generator.js +5 -1
  33. package/src/open-api/ts-hooks/generator.js.map +1 -1
  34. package/src/open-api/utils/codegen-data/languages.js +6 -0
  35. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  36. package/src/open-api/utils/codegen-data/types.d.ts +16 -1
  37. package/src/open-api/utils/codegen-data/types.js.map +1 -1
  38. package/src/open-api/utils/codegen-data.js +71 -0
  39. package/src/open-api/utils/codegen-data.js.map +1 -1
  40. package/src/open-api/utils/normalise.js +53 -8
  41. package/src/open-api/utils/normalise.js.map +1 -1
  42. package/src/open-api/utils/parser.js +48 -15
  43. package/src/open-api/utils/parser.js.map +1 -1
  44. package/src/preset/__snapshots__/generator.spec.ts.snap +5 -3
  45. package/src/preset/generator.d.ts +1 -1
  46. package/src/preset/generator.js +5 -2
  47. package/src/preset/generator.js.map +1 -1
  48. package/src/preset/schema.d.js.map +1 -1
  49. package/src/preset/schema.d.ts +2 -0
  50. package/src/preset/schema.json +6 -0
  51. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
  52. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
  53. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +89 -3
  54. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  55. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
  56. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  57. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +91 -5
  58. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +2038 -0
  59. package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +104 -0
  60. package/src/py/rdb/agent-connection/generator.d.ts +10 -0
  61. package/src/py/rdb/agent-connection/generator.js +46 -0
  62. package/src/py/rdb/agent-connection/generator.js.map +1 -0
  63. package/src/py/rdb/agent-connection/schema.d.js +8 -0
  64. package/src/py/rdb/agent-connection/schema.d.js.map +1 -0
  65. package/src/py/rdb/agent-connection/schema.d.ts +15 -0
  66. package/src/py/rdb/agent-connection/schema.json +27 -0
  67. package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +44 -0
  68. package/src/py/rdb/fast-api-connection/files/__apiModuleName__/dependencies/__rdbNameSnake__.py.template +14 -0
  69. package/src/py/rdb/fast-api-connection/generator.d.ts +10 -0
  70. package/src/py/rdb/fast-api-connection/generator.js +54 -0
  71. package/src/py/rdb/fast-api-connection/generator.js.map +1 -0
  72. package/src/py/rdb/fast-api-connection/schema.d.js +8 -0
  73. package/src/py/rdb/fast-api-connection/schema.d.js.map +1 -0
  74. package/src/py/rdb/fast-api-connection/schema.d.ts +13 -0
  75. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  76. package/src/py/rdb/files/Dockerfile.create-db-user.template +10 -0
  77. package/src/py/rdb/files/Dockerfile.migration.template +10 -0
  78. package/src/py/rdb/files/__name__/__init__.py.template +3 -0
  79. package/src/py/rdb/files/__name__/connection.py.template +55 -0
  80. package/src/py/rdb/files/__name__/create_db_user_handler.py.template +97 -0
  81. package/src/py/rdb/files/__name__/migration_handler.py.template +36 -0
  82. package/src/py/rdb/files/__name__/models/__init__.py.template +3 -0
  83. package/src/py/rdb/files/__name__/models/example.py.template +8 -0
  84. package/src/py/rdb/files/__name__/utils.py.template +104 -0
  85. package/src/py/rdb/files/alembic.ini.template +38 -0
  86. package/src/py/rdb/files/config.json.template +14 -0
  87. package/src/py/rdb/files/migrations/env.py.template +80 -0
  88. package/src/py/rdb/files/migrations/script.py.mako.template +28 -0
  89. package/src/py/rdb/generator.d.ts +6 -0
  90. package/src/py/rdb/generator.js +263 -0
  91. package/src/py/rdb/generator.js.map +1 -0
  92. package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +101 -0
  93. package/src/py/rdb/mcp-server-connection/generator.d.ts +10 -0
  94. package/src/py/rdb/mcp-server-connection/generator.js +46 -0
  95. package/src/py/rdb/mcp-server-connection/generator.js.map +1 -0
  96. package/src/py/rdb/mcp-server-connection/schema.d.js +8 -0
  97. package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -0
  98. package/src/py/rdb/mcp-server-connection/schema.d.ts +15 -0
  99. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  100. package/src/py/rdb/schema.d.js +6 -0
  101. package/src/py/rdb/schema.d.js.map +1 -0
  102. package/src/py/rdb/schema.d.ts +16 -0
  103. package/src/py/rdb/schema.json +77 -0
  104. package/src/py/rdb/utils.d.ts +6 -0
  105. package/src/py/rdb/utils.js +16 -0
  106. package/src/py/rdb/utils.js.map +1 -0
  107. package/src/sdk/py.d.ts +2 -0
  108. package/src/sdk/py.js +1 -0
  109. package/src/sdk/py.js.map +1 -1
  110. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
  111. package/src/smithy/ts/api/files/handler.ts.template +2 -2
  112. package/src/smithy/ts/api/files/local-server.ts.template +2 -2
  113. package/src/smithy/ts/api/files/operations/echo.ts.template +2 -2
  114. package/src/smithy/ts/api/files/service.ts.template +3 -3
  115. package/src/smithy/ts/api/generator.js +3 -1
  116. package/src/smithy/ts/api/generator.js.map +1 -1
  117. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
  118. package/src/trpc/backend/files/src/client/index.ts.template +1 -1
  119. package/src/trpc/backend/files/src/handler.ts.template +1 -1
  120. package/src/trpc/backend/files/src/index.ts.template +5 -5
  121. package/src/trpc/backend/files/src/init.ts.template +1 -1
  122. package/src/trpc/backend/files/src/local-server.ts.template +1 -1
  123. package/src/trpc/backend/files/src/middleware/index.ts.template +7 -7
  124. package/src/trpc/backend/files/src/procedures/echo.ts.template +2 -2
  125. package/src/trpc/backend/files/src/router.ts.template +2 -2
  126. package/src/trpc/backend/files/src/schema/index.ts.template +1 -1
  127. package/src/trpc/backend/generator.js +3 -1
  128. package/src/trpc/backend/generator.js.map +1 -1
  129. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +89 -3
  130. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +2 -2
  131. package/src/ts/agent/a2a-connection/generator.js +3 -1
  132. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  133. package/src/ts/agent/files/a2a/index.ts.template +1 -1
  134. package/src/ts/agent/files/ag-ui/index.ts.template +1 -1
  135. package/src/ts/agent/files/http/client.ts.template +2 -2
  136. package/src/ts/agent/files/http/index.ts.template +2 -2
  137. package/src/ts/agent/files/http/router.ts.template +3 -3
  138. package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +2 -2
  139. package/src/ts/agent/gateway-connection/generator.js +3 -1
  140. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  141. package/src/ts/agent/generator.js +5 -2
  142. package/src/ts/agent/generator.js.map +1 -1
  143. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -2
  144. package/src/ts/agent/mcp-connection/generator.js +3 -1
  145. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  146. package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +3 -2
  147. package/src/ts/astro-docs/generator.js +2 -0
  148. package/src/ts/astro-docs/generator.js.map +1 -1
  149. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  150. package/src/ts/dynamodb/files/src/client.ts.template +5 -2
  151. package/src/ts/dynamodb/files/src/entities/example.ts.template +1 -1
  152. package/src/ts/dynamodb/files/src/entities/index.ts.template +1 -1
  153. package/src/ts/dynamodb/files/src/index.ts.template +2 -2
  154. package/src/ts/dynamodb/generator.js +3 -1
  155. package/src/ts/dynamodb/generator.js.map +1 -1
  156. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  157. package/src/ts/lib/generator.js +7 -1
  158. package/src/ts/lib/generator.js.map +1 -1
  159. package/src/ts/lib/ts-project-utils.js +19 -4
  160. package/src/ts/lib/ts-project-utils.js.map +1 -1
  161. package/src/ts/lib/types.d.ts +6 -0
  162. package/src/ts/lib/types.js.map +1 -1
  163. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +94 -8
  164. package/src/ts/mcp-server/generator.js +3 -2
  165. package/src/ts/mcp-server/generator.js.map +1 -1
  166. package/src/ts/nx-generator/files/local/generator.ts.template +2 -2
  167. package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +2 -2
  168. package/src/ts/nx-generator/generator.js +5 -2
  169. package/src/ts/nx-generator/generator.js.map +1 -1
  170. package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
  171. package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
  172. package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
  173. package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
  174. package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
  175. package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
  176. package/src/ts/nx-plugin/generator.js +3 -1
  177. package/src/ts/nx-plugin/generator.js.map +1 -1
  178. package/src/ts/nx-plugin/utils.js +7 -4
  179. package/src/ts/nx-plugin/utils.js.map +1 -1
  180. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +149 -177
  181. package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
  182. package/src/ts/rdb/files/src/index.ts.template +1 -1
  183. package/src/ts/rdb/files/src/migration-handler.ts.template +1 -1
  184. package/src/ts/rdb/files/src/prisma.ts.template +7 -4
  185. package/src/ts/rdb/generator.js +7 -4
  186. package/src/ts/rdb/generator.js.map +1 -1
  187. package/src/ts/rdb/schema.json +1 -1
  188. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +45 -45
  189. package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
  190. package/src/utils/agent-chat/agent-chat.js +3 -1
  191. package/src/utils/agent-chat/agent-chat.js.map +1 -1
  192. package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
  193. package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
  194. package/src/utils/agent-chat/files/http-py/chat.ts.template +2 -2
  195. package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
  196. package/src/utils/agent-connection/agent-connection.js +4 -1
  197. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  198. package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +2 -2
  199. package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +1 -1
  200. package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +2 -2
  201. package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +2 -2
  202. package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +1 -1
  203. package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +1 -1
  204. package/src/utils/agent-connection/files/core-strands/base/with-session-id-strands.ts.template +1 -1
  205. package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
  206. package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +1 -1
  207. package/src/utils/agent-core-constructs/agent-core-constructs.js +10 -3
  208. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  209. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +3 -3
  210. package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +4 -4
  211. package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +1 -1
  212. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +27 -0
  213. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +60 -1
  214. package/src/utils/api-constructs/api-constructs.js +8 -2
  215. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  216. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +8 -8
  217. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +8 -8
  218. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +3 -3
  219. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +32 -20
  220. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +1 -1
  221. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +4 -4
  222. package/src/utils/api-constructs/files/cdk/core/api/trpc/trpc-utils.ts.template +1 -1
  223. package/src/utils/ast.js +16 -0
  224. package/src/utils/ast.js.map +1 -1
  225. package/src/utils/commands.d.ts +1 -1
  226. package/src/utils/commands.js +4 -1
  227. package/src/utils/commands.js.map +1 -1
  228. package/src/utils/dynamodb-constructs/dynamodb-constructs.js +9 -2
  229. package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
  230. package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +3 -3
  231. package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +1 -1
  232. package/src/utils/files/common/constructs/src/core/index.ts.template +4 -4
  233. package/src/utils/files/common/constructs/src/index.ts.template +2 -2
  234. package/src/utils/files/common/infra-config/src/index.ts.template +3 -3
  235. package/src/utils/files/common/infra-config/src/resolve-stage.ts.template +2 -2
  236. package/src/utils/files/common/infra-config/src/stages.config.ts.template +1 -1
  237. package/src/utils/files/common/scripts/src/infra/infra-deploy.ts.template +1 -1
  238. package/src/utils/files/common/scripts/src/infra/infra-destroy.ts.template +1 -1
  239. package/src/utils/files/common/scripts/src/infra/stage-credentials/run.ts.template +3 -3
  240. package/src/utils/files/common/shadcn/src/index.ts.template +2 -2
  241. package/src/utils/function-constructs/files/cdk/app/lambda-functions/__nameKebabCase__.ts.template +1 -1
  242. package/src/utils/function-constructs/function-constructs.js +3 -1
  243. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  244. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +2 -2
  245. package/src/utils/identity-constructs/identity-constructs.js +5 -1
  246. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  247. package/src/utils/module-format.d.ts +28 -0
  248. package/src/utils/module-format.js +28 -0
  249. package/src/utils/module-format.js.map +1 -0
  250. package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +61 -17
  251. package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +68 -78
  252. package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +88 -8
  253. package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +5 -32
  254. package/src/utils/rdb-constructs/rdb-constructs.d.ts +11 -1
  255. package/src/utils/rdb-constructs/rdb-constructs.js +9 -2
  256. package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
  257. package/src/utils/shared-constructs.js +12 -22
  258. package/src/utils/shared-constructs.js.map +1 -1
  259. package/src/utils/shared-infra-config.js +3 -1
  260. package/src/utils/shared-infra-config.js.map +1 -1
  261. package/src/utils/shared-infra-scripts.js +3 -1
  262. package/src/utils/shared-infra-scripts.js.map +1 -1
  263. package/src/utils/shared-rdb-scripts.js +5 -1
  264. package/src/utils/shared-rdb-scripts.js.map +1 -1
  265. package/src/utils/shared-shadcn.js +3 -1
  266. package/src/utils/shared-shadcn.js.map +1 -1
  267. package/src/utils/test.d.ts +2 -0
  268. package/src/utils/test.js +7 -1
  269. package/src/utils/test.js.map +1 -1
  270. package/src/utils/versions.d.ts +73 -69
  271. package/src/utils/versions.js +71 -67
  272. package/src/utils/versions.js.map +1 -1
  273. package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +2 -2
  274. package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +2 -2
  275. package/src/utils/website-constructs/website-constructs.js +9 -2
  276. package/src/utils/website-constructs/website-constructs.js.map +1 -1
  277. package/src/utils/files/terraform/scripts/reset-runtime-config.ts.template +0 -25
@@ -359,14 +359,10 @@ import { CustomResource } from 'aws-cdk-lib';
359
359
  import { IConnectable, IVpc, Port, SubnetType } from 'aws-cdk-lib/aws-ec2';
360
360
  import { IGrantable, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
361
361
  import { Key } from 'aws-cdk-lib/aws-kms';
362
- import { Platform } from 'aws-cdk-lib/aws-ecr-assets';
363
362
  import {
364
363
  Architecture,
365
- Code,
366
- DockerImageCode,
367
- DockerImageFunction,
368
364
  Function,
369
- Runtime,
365
+ FunctionOptions,
370
366
  Tracing,
371
367
  } from 'aws-cdk-lib/aws-lambda';
372
368
  import {
@@ -482,16 +478,6 @@ export interface AuroraDatabaseProps extends _AuroraDatabaseProps {
482
478
  */
483
479
  readonly runtimeConfigKey: string;
484
480
 
485
- /**
486
- * Migration bundle used to create a migration handler Lambda.
487
- */
488
- readonly migrationBundleDir: string;
489
-
490
- /**
491
- * Bundle used to create or reconcile the application database user.
492
- */
493
- readonly createDbUserBundleDir: string;
494
-
495
481
  /**
496
482
  * Writer instance for the Aurora cluster.
497
483
  */
@@ -566,8 +552,6 @@ export abstract class AuroraDatabase extends Construct {
566
552
  adminUser,
567
553
  databaseName,
568
554
  runtimeConfigKey,
569
- migrationBundleDir,
570
- createDbUserBundleDir,
571
555
  vpcSubnets,
572
556
  writer,
573
557
  enableRdsProxy = true,
@@ -645,23 +629,23 @@ export abstract class AuroraDatabase extends Construct {
645
629
  this.proxy?.endpoint ?? this.cluster.clusterEndpoint.hostname;
646
630
  const databasePort = this.cluster.clusterEndpoint.port;
647
631
 
648
- const createDbUserHandler = new Function(this, 'CreateDbUserHandler', {
649
- code: Code.fromAsset(createDbUserBundleDir),
650
- handler: 'index.handler',
651
- runtime: Runtime.NODEJS_LATEST,
632
+ const commonProps: FunctionOptions = {
633
+ vpc,
652
634
  timeout: Duration.minutes(5),
653
635
  tracing: Tracing.ACTIVE,
654
- vpc,
636
+ architecture: Architecture.ARM_64,
637
+ };
638
+
639
+ const createDbUserHandler = this.createDbUserHandler({
640
+ ...commonProps,
655
641
  vpcSubnets: {
656
642
  subnetType: SubnetType.PRIVATE_WITH_EGRESS,
657
643
  },
658
- environment: {
659
- DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
660
- NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
661
- },
662
- architecture: Architecture.ARM_64,
663
644
  });
664
-
645
+ createDbUserHandler.addEnvironment(
646
+ 'DATABASE_SECRET_ARN',
647
+ this.cluster.secret!.secretArn,
648
+ );
665
649
  this.cluster.connections.allowDefaultPortFrom(
666
650
  createDbUserHandler,
667
651
  'Allow the create-db-user handler to connect to the database',
@@ -698,20 +682,14 @@ export abstract class AuroraDatabase extends Construct {
698
682
  region: Stack.of(this).region,
699
683
  });
700
684
 
701
- const migrationHandler = new DockerImageFunction(this, 'MigrationHandler', {
702
- code: DockerImageCode.fromImageAsset(migrationBundleDir, {
703
- platform: Platform.LINUX_ARM64,
704
- }),
685
+ const migrationHandler = this.createMigrationHandler({
686
+ ...commonProps,
705
687
  memorySize: 1024,
706
- timeout: Duration.minutes(5),
707
- tracing: Tracing.ACTIVE,
708
- vpc,
709
- environment: {
710
- DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
711
- },
712
- architecture: Architecture.ARM_64,
713
688
  });
714
-
689
+ migrationHandler.addEnvironment(
690
+ 'DATABASE_SECRET_ARN',
691
+ this.cluster.secret!.secretArn,
692
+ );
715
693
  this.cluster.connections.allowDefaultPortFrom(migrationHandler);
716
694
  this.grantSecretRead(migrationHandler);
717
695
 
@@ -731,6 +709,18 @@ export abstract class AuroraDatabase extends Construct {
731
709
  }
732
710
  }
733
711
 
712
+ /**
713
+ * Creates the Lambda handler used to create or reconcile the application database user.
714
+ */
715
+ protected abstract createDbUserHandler(baseProps: FunctionOptions): Function;
716
+
717
+ /**
718
+ * Creates the Lambda handler used to run database migrations.
719
+ */
720
+ protected abstract createMigrationHandler(
721
+ baseProps: FunctionOptions,
722
+ ): Function;
723
+
734
724
  public allowDefaultPortFrom(other: IConnectable, description?: string): void {
735
725
  if (this.proxy) {
736
726
  this.proxy.connections.allowFrom(
@@ -792,7 +782,7 @@ terraform {
792
782
  required_providers {
793
783
  aws = {
794
784
  source = "hashicorp/aws"
795
- version = "6.52.0"
785
+ version = "6.54.0"
796
786
  }
797
787
  null = {
798
788
  source = "hashicorp/null"
@@ -1239,27 +1229,6 @@ resource "aws_iam_role" "proxy" {
1239
1229
  })
1240
1230
  }
1241
1231
 
1242
- resource "aws_iam_role_policy" "proxy_secret_access" {
1243
- count = var.enable_rds_proxy ? 1 : 0
1244
- role = aws_iam_role.proxy[0].name
1245
-
1246
- policy = jsonencode({
1247
- Version = "2012-10-17"
1248
- Statement = [
1249
- {
1250
- Effect = "Allow"
1251
- Action = ["secretsmanager:GetSecretValue"]
1252
- Resource = [aws_secretsmanager_secret.credentials.arn]
1253
- },
1254
- {
1255
- Effect = "Allow"
1256
- Action = ["kms:Decrypt"]
1257
- Resource = [aws_kms_key.database.arn]
1258
- }
1259
- ]
1260
- })
1261
- }
1262
-
1263
1232
  resource "aws_security_group" "proxy" {
1264
1233
  #checkov:skip=CKV2_AWS_5:Security group is attached to aws_db_proxy.aurora; Checkov cannot resolve count-conditional cross-resource references
1265
1234
  count = var.enable_rds_proxy ? 1 : 0
@@ -1283,17 +1252,6 @@ resource "aws_db_proxy" "aurora" {
1283
1252
  vpc_subnet_ids = var.subnet_ids
1284
1253
  vpc_security_group_ids = [aws_security_group.proxy[0].id]
1285
1254
  require_tls = true
1286
-
1287
- auth {
1288
- auth_scheme = "SECRETS"
1289
- iam_auth = "REQUIRED"
1290
- secret_arn = aws_secretsmanager_secret.credentials.arn
1291
- }
1292
-
1293
- depends_on = [
1294
- aws_iam_role_policy.proxy_secret_access,
1295
- aws_secretsmanager_secret_version.credentials,
1296
- ]
1297
1255
  }
1298
1256
 
1299
1257
  resource "aws_db_proxy_default_target_group" "default" {
@@ -1476,6 +1434,11 @@ output "proxy_resource_id" {
1476
1434
  value = var.enable_rds_proxy ? split(":", aws_db_proxy.aurora[0].arn)[6] : null
1477
1435
  }
1478
1436
 
1437
+ output "connect_resource_id" {
1438
+ description = "Resource ID to use in IAM rds-db:connect policies for the application database user. Resolves to the RDS Proxy resource ID when the proxy is enabled (the default), or the Aurora cluster resource ID when it is disabled — connecting through the proxy and connecting directly to the cluster are different IAM permission boundaries."
1439
+ value = var.enable_rds_proxy ? split(":", aws_db_proxy.aurora[0].arn)[6] : aws_rds_cluster.database.cluster_resource_id
1440
+ }
1441
+
1479
1442
  output "cluster_endpoint" {
1480
1443
  description = "Writer endpoint of the Aurora cluster or proxy."
1481
1444
  value = var.enable_rds_proxy ? aws_db_proxy.aurora[0].endpoint : aws_rds_cluster.database.endpoint
@@ -1554,7 +1517,7 @@ exports[`ts#rdb generator > should generate terraform modules when iac is Terraf
1554
1517
  }
1555
1518
  aws = {
1556
1519
  source = "hashicorp/aws"
1557
- version = "6.52.0"
1520
+ version = "6.54.0"
1558
1521
  }
1559
1522
  null = {
1560
1523
  source = "hashicorp/null"
@@ -1666,12 +1629,13 @@ variable "tags" {
1666
1629
  default = {}
1667
1630
  }
1668
1631
 
1669
- variable "docker_image_tag" {
1632
+ variable "migration_docker_image_tag" {
1670
1633
  description = "Docker image tag for the migration handler. Defaults to the tag built by the Nx docker target."
1671
1634
  type = string
1672
1635
  default = "proj-db-migration:latest"
1673
1636
  }
1674
1637
 
1638
+
1675
1639
  variable "asset_bucket_name" {
1676
1640
  description = "Name of the shared asset S3 bucket used to stage the Lambda deployment zip. Instantiate the \`core/asset-bucket\` module once per deployment and pass its \`bucket_name\` output here."
1677
1641
  type = string
@@ -1820,7 +1784,7 @@ resource "aws_ecr_repository_policy" "migration_handler" {
1820
1784
  }
1821
1785
 
1822
1786
  data "external" "docker_digest" {
1823
- program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.docker_image_tag} --format '{{.Id}}')'\\"}' "]
1787
+ program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.migration_docker_image_tag} --format '{{.Id}}')'\\"}' "]
1824
1788
  }
1825
1789
 
1826
1790
  locals {
@@ -1832,20 +1796,20 @@ resource "null_resource" "docker_publish" {
1832
1796
  triggers = {
1833
1797
  docker_digest = data.external.docker_digest.result.digest
1834
1798
  repository_url = aws_ecr_repository.migration_handler.repository_url
1835
- docker_image_tag = var.docker_image_tag
1799
+ migration_docker_image_tag = var.migration_docker_image_tag
1836
1800
  image_tag = local.image_tag
1837
1801
  }
1838
1802
 
1839
1803
  provisioner "local-exec" {
1840
1804
  command = <<-EOT
1841
1805
  aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$REPOSITORY_URL"
1842
- docker tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
1806
+ docker tag "$MIGRATION_DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
1843
1807
  docker push "$REPOSITORY_URL:$IMAGE_TAG"
1844
1808
  EOT
1845
1809
  environment = {
1846
1810
  AWS_REGION = data.aws_region.current.region
1847
1811
  REPOSITORY_URL = self.triggers.repository_url
1848
- DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
1812
+ MIGRATION_DOCKER_IMAGE_TAG = self.triggers.migration_docker_image_tag
1849
1813
  IMAGE_TAG = self.triggers.image_tag
1850
1814
  }
1851
1815
  }
@@ -2233,6 +2197,11 @@ output "proxy_resource_id" {
2233
2197
  value = module.aurora.proxy_resource_id
2234
2198
  }
2235
2199
 
2200
+ output "connect_resource_id" {
2201
+ description = "Resource ID to use in IAM rds-db:connect policies for the application database user. Resolves to the RDS Proxy resource ID when the proxy is enabled (the default), or the Aurora cluster resource ID when it is disabled — connecting through the proxy and connecting directly to the cluster are different IAM permission boundaries."
2202
+ value = module.aurora.connect_resource_id
2203
+ }
2204
+
2236
2205
  output "kms_key_arn" {
2237
2206
  description = "ARN of the KMS key protecting Aurora and the admin credentials secret, used to grant decrypt access alongside secret_arn."
2238
2207
  value = module.aurora.kms_key_arn
@@ -2267,7 +2236,6 @@ output "database_runtime_user" {
2267
2236
  description = "Application database user created for IAM-authenticated access."
2268
2237
  value = local.database_runtime_user
2269
2238
  }
2270
-
2271
2239
  "
2272
2240
  `;
2273
2241
 
@@ -2281,7 +2249,7 @@ terraform {
2281
2249
  required_providers {
2282
2250
  aws = {
2283
2251
  source = "hashicorp/aws"
2284
- version = "6.52.0"
2252
+ version = "6.54.0"
2285
2253
  }
2286
2254
  null = {
2287
2255
  source = "hashicorp/null"
@@ -2728,27 +2696,6 @@ resource "aws_iam_role" "proxy" {
2728
2696
  })
2729
2697
  }
2730
2698
 
2731
- resource "aws_iam_role_policy" "proxy_secret_access" {
2732
- count = var.enable_rds_proxy ? 1 : 0
2733
- role = aws_iam_role.proxy[0].name
2734
-
2735
- policy = jsonencode({
2736
- Version = "2012-10-17"
2737
- Statement = [
2738
- {
2739
- Effect = "Allow"
2740
- Action = ["secretsmanager:GetSecretValue"]
2741
- Resource = [aws_secretsmanager_secret.credentials.arn]
2742
- },
2743
- {
2744
- Effect = "Allow"
2745
- Action = ["kms:Decrypt"]
2746
- Resource = [aws_kms_key.database.arn]
2747
- }
2748
- ]
2749
- })
2750
- }
2751
-
2752
2699
  resource "aws_security_group" "proxy" {
2753
2700
  #checkov:skip=CKV2_AWS_5:Security group is attached to aws_db_proxy.aurora; Checkov cannot resolve count-conditional cross-resource references
2754
2701
  count = var.enable_rds_proxy ? 1 : 0
@@ -2772,17 +2719,6 @@ resource "aws_db_proxy" "aurora" {
2772
2719
  vpc_subnet_ids = var.subnet_ids
2773
2720
  vpc_security_group_ids = [aws_security_group.proxy[0].id]
2774
2721
  require_tls = true
2775
-
2776
- auth {
2777
- auth_scheme = "SECRETS"
2778
- iam_auth = "REQUIRED"
2779
- secret_arn = aws_secretsmanager_secret.credentials.arn
2780
- }
2781
-
2782
- depends_on = [
2783
- aws_iam_role_policy.proxy_secret_access,
2784
- aws_secretsmanager_secret_version.credentials,
2785
- ]
2786
2722
  }
2787
2723
 
2788
2724
  resource "aws_db_proxy_default_target_group" "default" {
@@ -2965,6 +2901,11 @@ output "proxy_resource_id" {
2965
2901
  value = var.enable_rds_proxy ? split(":", aws_db_proxy.aurora[0].arn)[6] : null
2966
2902
  }
2967
2903
 
2904
+ output "connect_resource_id" {
2905
+ description = "Resource ID to use in IAM rds-db:connect policies for the application database user. Resolves to the RDS Proxy resource ID when the proxy is enabled (the default), or the Aurora cluster resource ID when it is disabled — connecting through the proxy and connecting directly to the cluster are different IAM permission boundaries."
2906
+ value = var.enable_rds_proxy ? split(":", aws_db_proxy.aurora[0].arn)[6] : aws_rds_cluster.database.cluster_resource_id
2907
+ }
2908
+
2968
2909
  output "cluster_endpoint" {
2969
2910
  description = "Writer endpoint of the Aurora cluster or proxy."
2970
2911
  value = var.enable_rds_proxy ? aws_db_proxy.aurora[0].endpoint : aws_rds_cluster.database.endpoint
@@ -3043,7 +2984,7 @@ exports[`ts#rdb generator > should generate terraform modules with MySQL engine
3043
2984
  }
3044
2985
  aws = {
3045
2986
  source = "hashicorp/aws"
3046
- version = "6.52.0"
2987
+ version = "6.54.0"
3047
2988
  }
3048
2989
  null = {
3049
2990
  source = "hashicorp/null"
@@ -3155,12 +3096,13 @@ variable "tags" {
3155
3096
  default = {}
3156
3097
  }
3157
3098
 
3158
- variable "docker_image_tag" {
3099
+ variable "migration_docker_image_tag" {
3159
3100
  description = "Docker image tag for the migration handler. Defaults to the tag built by the Nx docker target."
3160
3101
  type = string
3161
3102
  default = "proj-db-migration:latest"
3162
3103
  }
3163
3104
 
3105
+
3164
3106
  variable "asset_bucket_name" {
3165
3107
  description = "Name of the shared asset S3 bucket used to stage the Lambda deployment zip. Instantiate the \`core/asset-bucket\` module once per deployment and pass its \`bucket_name\` output here."
3166
3108
  type = string
@@ -3220,10 +3162,17 @@ resource "aws_iam_role_policy" "proxy_db_user_connect" {
3220
3162
  Statement = [
3221
3163
  {
3222
3164
  Effect = "Allow"
3223
- Action = ["rds-db:connect"]
3224
- Resource = [
3225
- "arn:aws:rds-db:\${data.aws_region.current.region}:\${data.aws_caller_identity.current.account_id}:dbuser:\${module.aurora.cluster_resource_id}/\${local.database_runtime_user}"
3165
+ Action = [
3166
+ "secretsmanager:GetSecretValue"
3167
+ ]
3168
+ Resource = [module.aurora.secret_arn]
3169
+ },
3170
+ {
3171
+ Effect = "Allow"
3172
+ Action = [
3173
+ "kms:Decrypt"
3226
3174
  ]
3175
+ Resource = [module.aurora.kms_key_arn]
3227
3176
  }
3228
3177
  ]
3229
3178
  })
@@ -3309,7 +3258,7 @@ resource "aws_ecr_repository_policy" "migration_handler" {
3309
3258
  }
3310
3259
 
3311
3260
  data "external" "docker_digest" {
3312
- program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.docker_image_tag} --format '{{.Id}}')'\\"}' "]
3261
+ program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.migration_docker_image_tag} --format '{{.Id}}')'\\"}' "]
3313
3262
  }
3314
3263
 
3315
3264
  locals {
@@ -3321,20 +3270,20 @@ resource "null_resource" "docker_publish" {
3321
3270
  triggers = {
3322
3271
  docker_digest = data.external.docker_digest.result.digest
3323
3272
  repository_url = aws_ecr_repository.migration_handler.repository_url
3324
- docker_image_tag = var.docker_image_tag
3273
+ migration_docker_image_tag = var.migration_docker_image_tag
3325
3274
  image_tag = local.image_tag
3326
3275
  }
3327
3276
 
3328
3277
  provisioner "local-exec" {
3329
3278
  command = <<-EOT
3330
3279
  aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$REPOSITORY_URL"
3331
- docker tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
3280
+ docker tag "$MIGRATION_DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
3332
3281
  docker push "$REPOSITORY_URL:$IMAGE_TAG"
3333
3282
  EOT
3334
3283
  environment = {
3335
3284
  AWS_REGION = data.aws_region.current.region
3336
3285
  REPOSITORY_URL = self.triggers.repository_url
3337
- DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
3286
+ MIGRATION_DOCKER_IMAGE_TAG = self.triggers.migration_docker_image_tag
3338
3287
  IMAGE_TAG = self.triggers.image_tag
3339
3288
  }
3340
3289
  }
@@ -3721,6 +3670,11 @@ output "proxy_resource_id" {
3721
3670
  value = module.aurora.proxy_resource_id
3722
3671
  }
3723
3672
 
3673
+ output "connect_resource_id" {
3674
+ description = "Resource ID to use in IAM rds-db:connect policies for the application database user. Resolves to the RDS Proxy resource ID when the proxy is enabled (the default), or the Aurora cluster resource ID when it is disabled — connecting through the proxy and connecting directly to the cluster are different IAM permission boundaries."
3675
+ value = module.aurora.connect_resource_id
3676
+ }
3677
+
3724
3678
  output "kms_key_arn" {
3725
3679
  description = "ARN of the KMS key protecting Aurora and the admin credentials secret, used to grant decrypt access alongside secret_arn."
3726
3680
  value = module.aurora.kms_key_arn
@@ -3755,7 +3709,6 @@ output "database_runtime_user" {
3755
3709
  description = "Application database user created for IAM-authenticated access."
3756
3710
  value = local.database_runtime_user
3757
3711
  }
3758
-
3759
3712
  "
3760
3713
  `;
3761
3714
 
@@ -4143,14 +4096,10 @@ import { CustomResource } from 'aws-cdk-lib';
4143
4096
  import { IConnectable, IVpc, Port, SubnetType } from 'aws-cdk-lib/aws-ec2';
4144
4097
  import { IGrantable, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
4145
4098
  import { Key } from 'aws-cdk-lib/aws-kms';
4146
- import { Platform } from 'aws-cdk-lib/aws-ecr-assets';
4147
4099
  import {
4148
4100
  Architecture,
4149
- Code,
4150
- DockerImageCode,
4151
- DockerImageFunction,
4152
4101
  Function,
4153
- Runtime,
4102
+ FunctionOptions,
4154
4103
  Tracing,
4155
4104
  } from 'aws-cdk-lib/aws-lambda';
4156
4105
  import {
@@ -4266,16 +4215,6 @@ export interface AuroraDatabaseProps extends _AuroraDatabaseProps {
4266
4215
  */
4267
4216
  readonly runtimeConfigKey: string;
4268
4217
 
4269
- /**
4270
- * Migration bundle used to create a migration handler Lambda.
4271
- */
4272
- readonly migrationBundleDir: string;
4273
-
4274
- /**
4275
- * Bundle used to create or reconcile the application database user.
4276
- */
4277
- readonly createDbUserBundleDir: string;
4278
-
4279
4218
  /**
4280
4219
  * Writer instance for the Aurora cluster.
4281
4220
  */
@@ -4350,8 +4289,6 @@ export abstract class AuroraDatabase extends Construct {
4350
4289
  adminUser,
4351
4290
  databaseName,
4352
4291
  runtimeConfigKey,
4353
- migrationBundleDir,
4354
- createDbUserBundleDir,
4355
4292
  vpcSubnets,
4356
4293
  writer,
4357
4294
  enableRdsProxy = true,
@@ -4429,23 +4366,23 @@ export abstract class AuroraDatabase extends Construct {
4429
4366
  this.proxy?.endpoint ?? this.cluster.clusterEndpoint.hostname;
4430
4367
  const databasePort = this.cluster.clusterEndpoint.port;
4431
4368
 
4432
- const createDbUserHandler = new Function(this, 'CreateDbUserHandler', {
4433
- code: Code.fromAsset(createDbUserBundleDir),
4434
- handler: 'index.handler',
4435
- runtime: Runtime.NODEJS_LATEST,
4369
+ const commonProps: FunctionOptions = {
4370
+ vpc,
4436
4371
  timeout: Duration.minutes(5),
4437
4372
  tracing: Tracing.ACTIVE,
4438
- vpc,
4373
+ architecture: Architecture.ARM_64,
4374
+ };
4375
+
4376
+ const createDbUserHandler = this.createDbUserHandler({
4377
+ ...commonProps,
4439
4378
  vpcSubnets: {
4440
4379
  subnetType: SubnetType.PRIVATE_WITH_EGRESS,
4441
4380
  },
4442
- environment: {
4443
- DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
4444
- NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
4445
- },
4446
- architecture: Architecture.ARM_64,
4447
4381
  });
4448
-
4382
+ createDbUserHandler.addEnvironment(
4383
+ 'DATABASE_SECRET_ARN',
4384
+ this.cluster.secret!.secretArn,
4385
+ );
4449
4386
  this.cluster.connections.allowDefaultPortFrom(
4450
4387
  createDbUserHandler,
4451
4388
  'Allow the create-db-user handler to connect to the database',
@@ -4482,20 +4419,14 @@ export abstract class AuroraDatabase extends Construct {
4482
4419
  region: Stack.of(this).region,
4483
4420
  });
4484
4421
 
4485
- const migrationHandler = new DockerImageFunction(this, 'MigrationHandler', {
4486
- code: DockerImageCode.fromImageAsset(migrationBundleDir, {
4487
- platform: Platform.LINUX_ARM64,
4488
- }),
4422
+ const migrationHandler = this.createMigrationHandler({
4423
+ ...commonProps,
4489
4424
  memorySize: 1024,
4490
- timeout: Duration.minutes(5),
4491
- tracing: Tracing.ACTIVE,
4492
- vpc,
4493
- environment: {
4494
- DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
4495
- },
4496
- architecture: Architecture.ARM_64,
4497
4425
  });
4498
-
4426
+ migrationHandler.addEnvironment(
4427
+ 'DATABASE_SECRET_ARN',
4428
+ this.cluster.secret!.secretArn,
4429
+ );
4499
4430
  this.cluster.connections.allowDefaultPortFrom(migrationHandler);
4500
4431
  this.grantSecretRead(migrationHandler);
4501
4432
 
@@ -4515,6 +4446,18 @@ export abstract class AuroraDatabase extends Construct {
4515
4446
  }
4516
4447
  }
4517
4448
 
4449
+ /**
4450
+ * Creates the Lambda handler used to create or reconcile the application database user.
4451
+ */
4452
+ protected abstract createDbUserHandler(baseProps: FunctionOptions): Function;
4453
+
4454
+ /**
4455
+ * Creates the Lambda handler used to run database migrations.
4456
+ */
4457
+ protected abstract createMigrationHandler(
4458
+ baseProps: FunctionOptions,
4459
+ ): Function;
4460
+
4518
4461
  public allowDefaultPortFrom(other: IConnectable, description?: string): void {
4519
4462
  if (this.proxy) {
4520
4463
  this.proxy.connections.allowFrom(
@@ -4545,6 +4488,15 @@ exports[`ts#rdb generator > should generate the aurora shared construct 2`] = `
4545
4488
  import * as url from 'url';
4546
4489
  import { readFileSync } from 'fs';
4547
4490
  import { Construct } from 'constructs';
4491
+ import { Platform } from 'aws-cdk-lib/aws-ecr-assets';
4492
+ import {
4493
+ Code,
4494
+ DockerImageCode,
4495
+ DockerImageFunction,
4496
+ Function,
4497
+ FunctionOptions,
4498
+ Runtime,
4499
+ } from 'aws-cdk-lib/aws-lambda';
4548
4500
  import {
4549
4501
  AuroraDatabase,
4550
4502
  AuroraDatabaseEngines,
@@ -4562,14 +4514,19 @@ const { runtimeConfigKey } = JSON.parse(
4562
4514
  ),
4563
4515
  ) as { runtimeConfigKey: string };
4564
4516
 
4517
+ const migrationBundleDir = path.join(
4518
+ findWorkspaceRoot(url.fileURLToPath(new URL(import.meta.url))),
4519
+ 'dist/packages/db/bundle/migration',
4520
+ );
4521
+
4522
+ const createDbUserBundleDir = path.join(
4523
+ findWorkspaceRoot(url.fileURLToPath(new URL(import.meta.url))),
4524
+ 'dist/packages/db/bundle/create-db-user',
4525
+ );
4526
+
4565
4527
  export type DbProps = Omit<
4566
4528
  AuroraDatabaseProps,
4567
- | 'databaseName'
4568
- | 'adminUser'
4569
- | 'createDbUserBundleDir'
4570
- | 'engine'
4571
- | 'runtimeConfigKey'
4572
- | 'migrationBundleDir'
4529
+ 'databaseName' | 'adminUser' | 'runtimeConfigKey' | 'engine'
4573
4530
  >;
4574
4531
 
4575
4532
  /**
@@ -4582,17 +4539,32 @@ export class Db extends AuroraDatabase {
4582
4539
  databaseName: 'database_name',
4583
4540
  adminUser: 'databaseUser',
4584
4541
  runtimeConfigKey,
4585
- migrationBundleDir: path.join(
4586
- findWorkspaceRoot(url.fileURLToPath(new URL(import.meta.url))),
4587
- 'dist/packages/db/bundle/migration',
4588
- ),
4589
- createDbUserBundleDir: path.join(
4590
- findWorkspaceRoot(url.fileURLToPath(new URL(import.meta.url))),
4591
- 'dist/packages/db/bundle/create-db-user',
4592
- ),
4593
4542
  engine: AuroraDatabaseEngines.postgres({}),
4594
4543
  });
4595
4544
  }
4545
+
4546
+ protected override createDbUserHandler(baseProps: FunctionOptions): Function {
4547
+ return new Function(this, 'CreateDbUserHandler', {
4548
+ ...baseProps,
4549
+ code: Code.fromAsset(createDbUserBundleDir),
4550
+ handler: 'index.handler',
4551
+ runtime: Runtime.NODEJS_LATEST,
4552
+ environment: {
4553
+ NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
4554
+ },
4555
+ });
4556
+ }
4557
+
4558
+ protected override createMigrationHandler(
4559
+ baseProps: FunctionOptions,
4560
+ ): Function {
4561
+ return new DockerImageFunction(this, 'MigrationHandler', {
4562
+ ...baseProps,
4563
+ code: DockerImageCode.fromImageAsset(migrationBundleDir, {
4564
+ platform: Platform.LINUX_ARM64,
4565
+ }),
4566
+ });
4567
+ }
4596
4568
  }
4597
4569
  "
4598
4570
  `;
@@ -2,10 +2,10 @@ import type { CloudFormationCustomResourceEvent } from 'aws-lambda';
2
2
  import { randomBytes } from 'node:crypto';
3
3
  <%_ if (engine === 'mysql') { _%>
4
4
  import { createPool, type PoolConnection } from 'mariadb';
5
- import { getDatabaseSecret, withConnectionRetry } from './utils.js';
5
+ import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
6
6
  <%_ } else { _%>
7
7
  import { Client, escapeIdentifier } from 'pg';
8
- import { getDatabaseSecret, withConnectionRetry } from './utils.js';
8
+ import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
9
9
  <%_ } _%>
10
10
 
11
11
  type OnEventResult = {
@@ -1 +1 @@
1
- export { getPrisma } from './prisma.js';
1
+ export { getPrisma } from './prisma<% if (esm) { %>.js<% } %>';
@@ -1,6 +1,6 @@
1
1
  import { execFile } from 'node:child_process';
2
2
  import { promisify } from 'node:util';
3
- import { getDatabaseSecret, withConnectionRetry } from './utils.js';
3
+ import { getDatabaseSecret, withConnectionRetry } from './utils<% if (esm) { %>.js<% } %>';
4
4
 
5
5
  const buildDatabaseUrl = async (): Promise<string> => {
6
6
  const { host, port, dbname, username, password } = await getDatabaseSecret();
@@ -1,18 +1,21 @@
1
1
  import { <%= prismaAdapterClassName %> } from '<%= prismaAdapterPackage %>';
2
2
  import { Signer } from '@aws-sdk/rds-signer';
3
- import { Prisma, PrismaClient } from '../generated/prisma/client.js';
3
+ import { Prisma, PrismaClient } from '../generated/prisma/client<% if (esm) { %>.js<% } %>';
4
4
  <%_ if (engine === 'postgres') { _%>
5
5
  import { Pool } from 'pg';
6
6
  <%_ } _%>
7
7
  import { readFileSync } from 'fs';
8
- import { join, dirname } from 'path';
8
+ import { join<% if (esm) { %>, dirname<% } %> } from 'path';
9
+ <%_ if (esm) { _%>
9
10
  import { fileURLToPath } from 'url';
10
- import { getDatabaseConfig } from './utils.js';
11
+ <%_ } _%>
12
+ import { getDatabaseConfig } from './utils<% if (esm) { %>.js<% } %>';
11
13
 
12
14
  // Generated: must match runtimeConfigKey in config.json
13
15
  const runtimeConfigKey = '<%= runtimeConfigKey %>';
14
-
16
+ <% if (esm) { %>
15
17
  const __dirname = dirname(fileURLToPath(import.meta.url));
18
+ <%_ } _%>
16
19
  // config.json is only present in local dev (not included in the deployed bundle); guard with LOCAL_DEV check
17
20
  const localDev = () =>
18
21
  JSON.parse(readFileSync(join(__dirname, '../config.json'), 'utf-8')).localDev;