@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
@@ -1,18 +1,14 @@
1
- import { CfnOutput, Duration, RemovalPolicy, Stack } from 'aws-cdk-lib';
2
- import { CustomResource } from 'aws-cdk-lib';
3
- import { IConnectable, IVpc, Port, SubnetType } from 'aws-cdk-lib/aws-ec2';
4
- import { IGrantable, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
5
- import { Key } from 'aws-cdk-lib/aws-kms';
6
- import { Platform } from 'aws-cdk-lib/aws-ecr-assets';
1
+ import { CfnOutput, Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
2
+ import { CustomResource } from "aws-cdk-lib";
3
+ import { IConnectable, IVpc, Port, SubnetType } from "aws-cdk-lib/aws-ec2";
4
+ import { IGrantable, Role, ServicePrincipal } from "aws-cdk-lib/aws-iam";
5
+ import { Key } from "aws-cdk-lib/aws-kms";
7
6
  import {
8
7
  Architecture,
9
- Code,
10
- DockerImageCode,
11
- DockerImageFunction,
12
8
  Function,
13
- Runtime,
9
+ FunctionOptions,
14
10
  Tracing,
15
- } from 'aws-cdk-lib/aws-lambda';
11
+ } from "aws-cdk-lib/aws-lambda";
16
12
  import {
17
13
  AuroraMysqlEngineVersion,
18
14
  AuroraPostgresEngineVersion,
@@ -24,11 +20,11 @@ import {
24
20
  DatabaseProxy,
25
21
  DefaultAuthScheme,
26
22
  IClusterEngine,
27
- } from 'aws-cdk-lib/aws-rds';
28
- import { Provider } from 'aws-cdk-lib/custom-resources';
29
- import { Trigger } from 'aws-cdk-lib/triggers';
30
- import { Construct } from 'constructs';
31
- import { RuntimeConfig } from '../runtime-config.js';
23
+ } from "aws-cdk-lib/aws-rds";
24
+ import { Provider } from "aws-cdk-lib/custom-resources";
25
+ import { Trigger } from "aws-cdk-lib/triggers";
26
+ import { Construct } from "constructs";
27
+ import { RuntimeConfig } from "../runtime-config<% if (esm) { %>.js<% } %>";
32
28
 
33
29
  export type AuroraDatabaseEngineVersion =
34
30
  | AuroraMysqlEngineVersion
@@ -38,7 +34,7 @@ export interface AuroraDatabaseEngine {
38
34
  /**
39
35
  * Discriminant identifying the engine type.
40
36
  */
41
- readonly type: 'mysql' | 'postgres';
37
+ readonly type: "mysql" | "postgres";
42
38
 
43
39
  /**
44
40
  * Default Aurora engine version used when one is not explicitly provided.
@@ -58,7 +54,7 @@ export class AuroraDatabaseEngines {
58
54
  defaultVersion?: AuroraMysqlEngineVersion;
59
55
  }): AuroraDatabaseEngine {
60
56
  return {
61
- type: 'mysql',
57
+ type: "mysql",
62
58
  defaultVersion,
63
59
  clusterEngine: (version) =>
64
60
  DatabaseClusterEngine.auroraMysql({
@@ -73,7 +69,7 @@ export class AuroraDatabaseEngines {
73
69
  defaultVersion?: AuroraPostgresEngineVersion;
74
70
  }): AuroraDatabaseEngine {
75
71
  return {
76
- type: 'postgres',
72
+ type: "postgres",
77
73
  defaultVersion,
78
74
  clusterEngine: (version) =>
79
75
  DatabaseClusterEngine.auroraPostgres({
@@ -85,12 +81,12 @@ export class AuroraDatabaseEngines {
85
81
 
86
82
  type _AuroraDatabaseProps = Omit<
87
83
  DatabaseClusterProps,
88
- | 'credentials'
89
- | 'defaultDatabaseName'
90
- | 'engine'
91
- | 'iamAuthentication'
92
- | 'instanceProps'
93
- | 'writer'
84
+ | "credentials"
85
+ | "defaultDatabaseName"
86
+ | "engine"
87
+ | "iamAuthentication"
88
+ | "instanceProps"
89
+ | "writer"
94
90
  >;
95
91
 
96
92
  export interface AuroraDatabaseProps extends _AuroraDatabaseProps {
@@ -126,20 +122,10 @@ export interface AuroraDatabaseProps extends _AuroraDatabaseProps {
126
122
  */
127
123
  readonly runtimeConfigKey: string;
128
124
 
129
- /**
130
- * Migration bundle used to create a migration handler Lambda.
131
- */
132
- readonly migrationBundleDir: string;
133
-
134
- /**
135
- * Bundle used to create or reconcile the application database user.
136
- */
137
- readonly createDbUserBundleDir: string;
138
-
139
125
  /**
140
126
  * Writer instance for the Aurora cluster.
141
127
  */
142
- readonly writer?: DatabaseClusterProps['writer'];
128
+ readonly writer?: DatabaseClusterProps["writer"];
143
129
 
144
130
  /**
145
131
  * Whether to provision an RDS Proxy in front of the Aurora cluster.
@@ -210,8 +196,6 @@ export abstract class AuroraDatabase extends Construct {
210
196
  adminUser,
211
197
  databaseName,
212
198
  runtimeConfigKey,
213
- migrationBundleDir,
214
- createDbUserBundleDir,
215
199
  vpcSubnets,
216
200
  writer,
217
201
  enableRdsProxy = true,
@@ -230,15 +214,15 @@ export abstract class AuroraDatabase extends Construct {
230
214
 
231
215
  this.adminUser = adminUser;
232
216
 
233
- const key = new Key(this, 'EncryptionKey', { enableKeyRotation });
234
- this.cluster = new DatabaseCluster(this, 'DatabaseCluster', {
217
+ const key = new Key(this, "EncryptionKey", { enableKeyRotation });
218
+ this.cluster = new DatabaseCluster(this, "DatabaseCluster", {
235
219
  ...clusterProps,
236
220
  vpc,
237
221
  vpcSubnets,
238
222
  engine: engine.clusterEngine(engineVersion ?? engine.defaultVersion),
239
223
  writer:
240
224
  writer ??
241
- ClusterInstance.serverlessV2('writer', {
225
+ ClusterInstance.serverlessV2("writer", {
242
226
  enablePerformanceInsights,
243
227
  performanceInsightEncryptionKey: enablePerformanceInsights
244
228
  ? key
@@ -250,9 +234,9 @@ export abstract class AuroraDatabase extends Construct {
250
234
  iamAuthentication: true,
251
235
  monitoringInterval: Duration.seconds(5),
252
236
  cloudwatchLogsExports: enableCloudwatchLogs
253
- ? engine.type === 'mysql'
254
- ? ['audit', 'error', 'general', 'slowquery']
255
- : ['postgresql']
237
+ ? engine.type === "mysql"
238
+ ? ["audit", "error", "general", "slowquery"]
239
+ : ["postgresql"]
256
240
  : undefined,
257
241
  defaultDatabaseName: databaseName,
258
242
  storageEncrypted: true,
@@ -271,13 +255,13 @@ export abstract class AuroraDatabase extends Construct {
271
255
  }
272
256
 
273
257
  const proxyRole = enableRdsProxy
274
- ? new Role(this, 'DatabaseProxyRole', {
275
- assumedBy: new ServicePrincipal('rds.amazonaws.com'),
258
+ ? new Role(this, "DatabaseProxyRole", {
259
+ assumedBy: new ServicePrincipal("rds.amazonaws.com"),
276
260
  })
277
261
  : undefined;
278
262
 
279
263
  if (enableRdsProxy) {
280
- this.proxy = this.cluster.addProxy('DatabaseProxy', {
264
+ this.proxy = this.cluster.addProxy("DatabaseProxy", {
281
265
  vpc,
282
266
  vpcSubnets,
283
267
  defaultAuthScheme: DefaultAuthScheme.IAM_AUTH,
@@ -289,36 +273,36 @@ export abstract class AuroraDatabase extends Construct {
289
273
  this.proxy?.endpoint ?? this.cluster.clusterEndpoint.hostname;
290
274
  const databasePort = this.cluster.clusterEndpoint.port;
291
275
 
292
- const createDbUserHandler = new Function(this, 'CreateDbUserHandler', {
293
- code: Code.fromAsset(createDbUserBundleDir),
294
- handler: 'index.handler',
295
- runtime: Runtime.NODEJS_LATEST,
276
+ const commonProps: FunctionOptions = {
277
+ vpc,
296
278
  timeout: Duration.minutes(5),
297
279
  tracing: Tracing.ACTIVE,
298
- vpc,
280
+ architecture: Architecture.ARM_64,
281
+ };
282
+
283
+ const createDbUserHandler = this.createDbUserHandler({
284
+ ...commonProps,
299
285
  vpcSubnets: {
300
286
  subnetType: SubnetType.PRIVATE_WITH_EGRESS,
301
287
  },
302
- environment: {
303
- DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
304
- NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
305
- },
306
- architecture: Architecture.ARM_64,
307
288
  });
308
-
289
+ createDbUserHandler.addEnvironment(
290
+ "DATABASE_SECRET_ARN",
291
+ this.cluster.secret!.secretArn,
292
+ );
309
293
  this.cluster.connections.allowDefaultPortFrom(
310
294
  createDbUserHandler,
311
- 'Allow the create-db-user handler to connect to the database',
295
+ "Allow the create-db-user handler to connect to the database",
312
296
  );
313
297
  this.grantSecretRead(createDbUserHandler);
314
298
 
315
- const createDbUserProvider = new Provider(this, 'CreateDbUserProvider', {
299
+ const createDbUserProvider = new Provider(this, "CreateDbUserProvider", {
316
300
  onEventHandler: createDbUserHandler,
317
301
  });
318
302
 
319
303
  const createDbUserResource = new CustomResource(
320
304
  this,
321
- 'CreateDbUserResource',
305
+ "CreateDbUserResource",
322
306
  {
323
307
  serviceToken: createDbUserProvider.serviceToken,
324
308
  properties: {
@@ -327,13 +311,13 @@ export abstract class AuroraDatabase extends Construct {
327
311
  },
328
312
  );
329
313
  createDbUserResource.node.addDependency(this.cluster);
330
- this.dbUser = createDbUserResource.getAttString('dbUser');
314
+ this.dbUser = createDbUserResource.getAttString("dbUser");
331
315
  if (this.proxy && proxyRole) {
332
316
  this.cluster.grantConnect(proxyRole, this.dbUser);
333
317
  }
334
318
 
335
319
  const rc = RuntimeConfig.ensure(this);
336
- rc.set('database', runtimeConfigKey, {
320
+ rc.set("database", runtimeConfigKey, {
337
321
  hostname: databaseHostname,
338
322
  port: databasePort,
339
323
  database: databaseName,
@@ -342,39 +326,45 @@ export abstract class AuroraDatabase extends Construct {
342
326
  region: Stack.of(this).region,
343
327
  });
344
328
 
345
- const migrationHandler = new DockerImageFunction(this, 'MigrationHandler', {
346
- code: DockerImageCode.fromImageAsset(migrationBundleDir, {
347
- platform: Platform.LINUX_ARM64,
348
- }),
329
+ const migrationHandler = this.createMigrationHandler({
330
+ ...commonProps,
349
331
  memorySize: 1024,
350
- timeout: Duration.minutes(5),
351
- tracing: Tracing.ACTIVE,
352
- vpc,
353
- environment: {
354
- DATABASE_SECRET_ARN: this.cluster.secret!.secretArn,
355
- },
356
- architecture: Architecture.ARM_64,
357
332
  });
358
-
333
+ migrationHandler.addEnvironment(
334
+ "DATABASE_SECRET_ARN",
335
+ this.cluster.secret!.secretArn,
336
+ );
359
337
  this.cluster.connections.allowDefaultPortFrom(migrationHandler);
360
338
  this.grantSecretRead(migrationHandler);
361
339
 
362
- const migrationTrigger = new Trigger(this, 'MigrationTrigger', {
340
+ const migrationTrigger = new Trigger(this, "MigrationTrigger", {
363
341
  handler: migrationHandler,
364
342
  });
365
343
  migrationTrigger.node.addDependency(createDbUserResource);
366
344
 
367
- new CfnOutput(this, 'ClusterEndpoint', {
345
+ new CfnOutput(this, "ClusterEndpoint", {
368
346
  value: this.cluster.clusterEndpoint.hostname,
369
347
  });
370
348
 
371
349
  if (this.proxy?.endpoint) {
372
- new CfnOutput(this, 'ProxyEndpoint', {
350
+ new CfnOutput(this, "ProxyEndpoint", {
373
351
  value: this.proxy?.endpoint,
374
352
  });
375
353
  }
376
354
  }
377
355
 
356
+ /**
357
+ * Creates the Lambda handler used to create or reconcile the application database user.
358
+ */
359
+ protected abstract createDbUserHandler(baseProps: FunctionOptions): Function;
360
+
361
+ /**
362
+ * Creates the Lambda handler used to run database migrations.
363
+ */
364
+ protected abstract createMigrationHandler(
365
+ baseProps: FunctionOptions,
366
+ ): Function;
367
+
378
368
  public allowDefaultPortFrom(other: IConnectable, description?: string): void {
379
369
  if (this.proxy) {
380
370
  this.proxy.connections.allowFrom(
@@ -120,16 +120,26 @@ variable "tags" {
120
120
  default = {}
121
121
  }
122
122
 
123
- variable "docker_image_tag" {
123
+ variable "migration_docker_image_tag" {
124
124
  description = "Docker image tag for the migration handler. Defaults to the tag built by the Nx docker target."
125
125
  type = string
126
- default = "<%= dockerImageTag %>"
126
+ default = "<%= migrationDockerImageTag %>"
127
127
  }
128
128
 
129
+ <%_ if (framework === 'sqlmodel') { _%>
130
+ variable "create_db_user_docker_image_tag" {
131
+ description = "Docker image tag for the Python create-db-user handler. Defaults to the tag built by the Nx docker target."
132
+ type = string
133
+ default = "<%= createDbUserDockerImageTag %>"
134
+ }
135
+ <%_ } _%>
136
+
137
+ <%_ if (framework !== 'sqlmodel') { _%>
129
138
  variable "asset_bucket_name" {
130
139
  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."
131
140
  type = string
132
141
  }
142
+ <%_ } _%>
133
143
 
134
144
  data "aws_region" "current" {}
135
145
  data "aws_caller_identity" "current" {}
@@ -143,7 +153,9 @@ resource "random_string" "suffix" {
143
153
  locals {
144
154
  config = jsondecode(file("${path.module}/../../../../../../../<%= projectRoot %>/config.json"))
145
155
  runtime_config_key = local.config.runtimeConfigKey
156
+ <%_ if (framework !== 'sqlmodel') { _%>
146
157
  create_db_user_bundle_path = "${path.module}/../../../../../../../<%- createDbUserBundleDir %>"
158
+ <%_ } _%>
147
159
  migration_function_name = "<%= nameKebabCase %>-migration-${random_string.suffix.result}"
148
160
  create_db_user_function_name = "<%= nameKebabCase %>-create-db-user-${random_string.suffix.result}"
149
161
  database_runtime_user = "db_${random_string.suffix.result}"
@@ -183,6 +195,22 @@ resource "aws_iam_role_policy" "proxy_db_user_connect" {
183
195
  policy = jsonencode({
184
196
  Version = "2012-10-17"
185
197
  Statement = [
198
+ <%_ if (engine === 'mysql' && framework !== 'sqlmodel') { _%>
199
+ {
200
+ Effect = "Allow"
201
+ Action = [
202
+ "secretsmanager:GetSecretValue"
203
+ ]
204
+ Resource = [module.aurora.secret_arn]
205
+ },
206
+ {
207
+ Effect = "Allow"
208
+ Action = [
209
+ "kms:Decrypt"
210
+ ]
211
+ Resource = [module.aurora.kms_key_arn]
212
+ }
213
+ <%_ } else { _%>
186
214
  {
187
215
  Effect = "Allow"
188
216
  Action = ["rds-db:connect"]
@@ -190,10 +218,12 @@ resource "aws_iam_role_policy" "proxy_db_user_connect" {
190
218
  "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}"
191
219
  ]
192
220
  }
221
+ <%_ } _%>
193
222
  ]
194
223
  })
195
224
  }
196
225
 
226
+ <%_ if (framework !== 'sqlmodel') { _%>
197
227
  data "archive_file" "create_db_user_zip" {
198
228
  type = "zip"
199
229
  source_dir = local.create_db_user_bundle_path
@@ -207,6 +237,7 @@ resource "aws_s3_object" "create_db_user_zip" {
207
237
  source_hash = data.archive_file.create_db_user_zip.output_base64sha256
208
238
  etag = data.archive_file.create_db_user_zip.output_md5
209
239
  }
240
+ <%_ } _%>
210
241
 
211
242
  module "add_rdb_to_runtime_config" {
212
243
  source = "../../../core/runtime-config/entry"
@@ -274,33 +305,55 @@ resource "aws_ecr_repository_policy" "migration_handler" {
274
305
  }
275
306
 
276
307
  data "external" "docker_digest" {
277
- program = ["sh", "-c", "echo '{\"digest\":\"'$(<%= containerEngine %> inspect ${var.docker_image_tag} --format '{{.Id}}')'\"}' "]
308
+ program = ["sh", "-c", "echo '{\"digest\":\"'$(<%= containerEngine %> inspect ${var.migration_docker_image_tag} --format '{{.Id}}')'\"}' "]
278
309
  }
279
310
 
280
311
  locals {
281
312
  # Content-based, immutable image tag derived from the local image digest
282
313
  image_tag = replace(data.external.docker_digest.result.digest, "sha256:", "")
283
314
  }
315
+ <%_ if (framework === 'sqlmodel') { _%>
316
+ data "external" "create_db_user_docker_digest" {
317
+ program = ["sh", "-c", "echo '{\"digest\":\"'$(<%= containerEngine %> inspect ${var.create_db_user_docker_image_tag} --format '{{.Id}}')'\"}' "]
318
+ }
319
+
320
+ locals {
321
+ create_db_user_image_tag = replace(data.external.create_db_user_docker_digest.result.digest, "sha256:", "")
322
+ }
323
+ <%_ } _%>
284
324
 
285
325
  resource "null_resource" "docker_publish" {
286
326
  triggers = {
287
327
  docker_digest = data.external.docker_digest.result.digest
288
328
  repository_url = aws_ecr_repository.migration_handler.repository_url
289
- docker_image_tag = var.docker_image_tag
329
+ migration_docker_image_tag = var.migration_docker_image_tag
290
330
  image_tag = local.image_tag
331
+ <%_ if (framework === 'sqlmodel') { _%>
332
+ create_db_user_docker_digest = data.external.create_db_user_docker_digest.result.digest
333
+ create_db_user_docker_image_tag = var.create_db_user_docker_image_tag
334
+ create_db_user_image_tag = local.create_db_user_image_tag
335
+ <%_ } _%>
291
336
  }
292
337
 
293
338
  provisioner "local-exec" {
294
339
  command = <<-EOT
295
340
  aws ecr get-login-password --region "$AWS_REGION" | <%= containerEngine %> login --username AWS --password-stdin "$REPOSITORY_URL"
296
- <%= containerEngine %> tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
341
+ <%= containerEngine %> tag "$MIGRATION_DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
297
342
  <%= containerEngine %> push "$REPOSITORY_URL:$IMAGE_TAG"
343
+ <%_ if (framework === 'sqlmodel') { _%>
344
+ <%= containerEngine %> tag "$CREATE_DB_USER_DOCKER_IMAGE_TAG" "$REPOSITORY_URL:create-db-user-$CREATE_DB_USER_IMAGE_TAG"
345
+ <%= containerEngine %> push "$REPOSITORY_URL:create-db-user-$CREATE_DB_USER_IMAGE_TAG"
346
+ <%_ } _%>
298
347
  EOT
299
348
  environment = {
300
349
  AWS_REGION = data.aws_region.current.region
301
350
  REPOSITORY_URL = self.triggers.repository_url
302
- DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
351
+ MIGRATION_DOCKER_IMAGE_TAG = self.triggers.migration_docker_image_tag
303
352
  IMAGE_TAG = self.triggers.image_tag
353
+ <%_ if (framework === 'sqlmodel') { _%>
354
+ CREATE_DB_USER_DOCKER_IMAGE_TAG = self.triggers.create_db_user_docker_image_tag
355
+ CREATE_DB_USER_IMAGE_TAG = self.triggers.create_db_user_image_tag
356
+ <%_ } _%>
304
357
  }
305
358
  }
306
359
 
@@ -512,6 +565,18 @@ resource "aws_lambda_function" "create_db_user" {
512
565
  #checkov:skip=CKV_AWS_115:Concurrent execution limit not required for the create-db-user handler
513
566
  #checkov:skip=CKV_AWS_173:Lambda environment variables encrypted by managed key
514
567
  #checkov:skip=CKV_AWS_272:Code signing not configured as deployment packages are built and deployed within the same pipeline
568
+ <%_ if (framework === 'sqlmodel') { _%>
569
+ package_type = "Image"
570
+ image_uri = "${aws_ecr_repository.migration_handler.repository_url}:create-db-user-${local.create_db_user_image_tag}"
571
+ function_name = local.create_db_user_function_name
572
+ role = aws_iam_role.create_db_user.arn
573
+ timeout = 300
574
+ architectures = ["arm64"]
575
+
576
+ image_config {
577
+ command = ["<%= databasePackageAlias %>.create_db_user_handler.handler"]
578
+ }
579
+ <%_ } else { _%>
515
580
  s3_bucket = aws_s3_object.create_db_user_zip.bucket
516
581
  s3_key = aws_s3_object.create_db_user_zip.key
517
582
  s3_object_version = aws_s3_object.create_db_user_zip.version_id
@@ -522,6 +587,7 @@ resource "aws_lambda_function" "create_db_user" {
522
587
  runtime = "nodejs24.x"
523
588
  timeout = 300
524
589
  architectures = ["arm64"]
590
+ <%_ } _%>
525
591
 
526
592
  tracing_config {
527
593
  mode = "Active"
@@ -535,14 +601,20 @@ resource "aws_lambda_function" "create_db_user" {
535
601
  environment {
536
602
  variables = {
537
603
  DATABASE_SECRET_ARN = module.aurora.secret_arn
604
+ <%_ if (framework === 'prisma') { _%>
538
605
  NODE_EXTRA_CA_CERTS = "/var/runtime/ca-cert.pem"
606
+ <%_ } _%>
539
607
  }
540
608
  }
541
609
 
542
610
  tags = var.tags
543
611
 
544
612
  depends_on = [
613
+ <%_ if (framework === 'sqlmodel') { _%>
614
+ null_resource.docker_publish,
615
+ <%_ } else { _%>
545
616
  aws_s3_object.create_db_user_zip,
617
+ <%_ } _%>
546
618
  aws_iam_role_policy_attachment.create_db_user_basic_execution,
547
619
  aws_iam_role_policy_attachment.create_db_user_vpc_access,
548
620
  aws_iam_role_policy_attachment.create_db_user_xray,
@@ -557,7 +629,11 @@ resource "null_resource" "create_db_user_trigger" {
557
629
  cluster_arn = module.aurora.cluster_arn
558
630
  function_name = aws_lambda_function.create_db_user.function_name
559
631
  db_user = local.database_runtime_user
632
+ <%_ if (framework === 'sqlmodel') { _%>
633
+ bundle_hash = data.external.create_db_user_docker_digest.result.digest
634
+ <%_ } else { _%>
560
635
  bundle_hash = data.archive_file.create_db_user_zip.output_base64sha256
636
+ <%_ } _%>
561
637
  }
562
638
 
563
639
  provisioner "local-exec" {
@@ -634,7 +710,7 @@ resource "null_resource" "migration_trigger" {
634
710
  cluster_arn = module.aurora.cluster_arn
635
711
  database_ready = module.aurora.database_ready
636
712
  function_name = aws_lambda_function.migration_handler.function_name
637
- <%_ if (engine !== 'mysql') { _%>
713
+ <%_ if (engine !== 'mysql' && framework !== 'sqlmodel') { _%>
638
714
  db_user = local.database_runtime_user
639
715
  <%_ } _%>
640
716
  }
@@ -689,6 +765,11 @@ output "proxy_resource_id" {
689
765
  value = module.aurora.proxy_resource_id
690
766
  }
691
767
 
768
+ output "connect_resource_id" {
769
+ 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."
770
+ value = module.aurora.connect_resource_id
771
+ }
772
+
692
773
  output "kms_key_arn" {
693
774
  description = "ARN of the KMS key protecting Aurora and the admin credentials secret, used to grant decrypt access alongside secret_arn."
694
775
  value = module.aurora.kms_key_arn
@@ -723,4 +804,3 @@ output "database_runtime_user" {
723
804
  description = "Application database user created for IAM-authenticated access."
724
805
  value = local.database_runtime_user
725
806
  }
726
-
@@ -454,27 +454,6 @@ resource "aws_iam_role" "proxy" {
454
454
  })
455
455
  }
456
456
 
457
- resource "aws_iam_role_policy" "proxy_secret_access" {
458
- count = var.enable_rds_proxy ? 1 : 0
459
- role = aws_iam_role.proxy[0].name
460
-
461
- policy = jsonencode({
462
- Version = "2012-10-17"
463
- Statement = [
464
- {
465
- Effect = "Allow"
466
- Action = ["secretsmanager:GetSecretValue"]
467
- Resource = [aws_secretsmanager_secret.credentials.arn]
468
- },
469
- {
470
- Effect = "Allow"
471
- Action = ["kms:Decrypt"]
472
- Resource = [aws_kms_key.database.arn]
473
- }
474
- ]
475
- })
476
- }
477
-
478
457
  resource "aws_security_group" "proxy" {
479
458
  #checkov:skip=CKV2_AWS_5:Security group is attached to aws_db_proxy.aurora; Checkov cannot resolve count-conditional cross-resource references
480
459
  count = var.enable_rds_proxy ? 1 : 0
@@ -498,17 +477,6 @@ resource "aws_db_proxy" "aurora" {
498
477
  vpc_subnet_ids = var.subnet_ids
499
478
  vpc_security_group_ids = [aws_security_group.proxy[0].id]
500
479
  require_tls = true
501
-
502
- auth {
503
- auth_scheme = "SECRETS"
504
- iam_auth = "REQUIRED"
505
- secret_arn = aws_secretsmanager_secret.credentials.arn
506
- }
507
-
508
- depends_on = [
509
- aws_iam_role_policy.proxy_secret_access,
510
- aws_secretsmanager_secret_version.credentials,
511
- ]
512
480
  }
513
481
 
514
482
  resource "aws_db_proxy_default_target_group" "default" {
@@ -691,6 +659,11 @@ output "proxy_resource_id" {
691
659
  value = var.enable_rds_proxy ? split(":", aws_db_proxy.aurora[0].arn)[6] : null
692
660
  }
693
661
 
662
+ output "connect_resource_id" {
663
+ 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."
664
+ value = var.enable_rds_proxy ? split(":", aws_db_proxy.aurora[0].arn)[6] : aws_rds_cluster.database.cluster_resource_id
665
+ }
666
+
694
667
  output "cluster_endpoint" {
695
668
  description = "Writer endpoint of the Aurora cluster or proxy."
696
669
  value = var.enable_rds_proxy ? aws_db_proxy.aurora[0].endpoint : aws_rds_cluster.database.endpoint
@@ -15,8 +15,18 @@ export interface AddRdbConstructOptions {
15
15
  adminUser: string;
16
16
  engine: 'postgres' | 'mysql';
17
17
  migrationBundleDir: string;
18
+ /**
19
+ * Node.js zip bundle directory for the create-db-user Lambda (ts#rdb).
20
+ * When absent the migration Docker image is reused with the
21
+ * `create_db_user_handler.handler` command (py#rdb).
22
+ */
18
23
  createDbUserBundleDir: string;
19
- dockerImageTag: string;
24
+ /** ORM framework used by the create-db-user Lambda. */
25
+ framework: 'prisma' | 'sqlmodel';
26
+ /** Local Docker tag for the Python create-db-user Lambda image. */
27
+ createDbUserDockerImageTag?: string;
28
+ /** Local Docker tag for the migration Lambda image. */
29
+ migrationDockerImageTag: string;
20
30
  containerEngine: Containers;
21
31
  }
22
32
  export declare const addRdbInfra: (tree: Tree, options: AddRdbConstructOptions & {
@@ -3,6 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */ import { generateFiles, joinPathFragments, OverwriteStrategy, updateJson } from "@nx/devkit";
5
5
  import { addStarExport } from "../ast.js";
6
+ import { esmVars } from "../module-format.js";
6
7
  import { addDependencyToTargetIfNotPresent } from "../nx.js";
7
8
  import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, SHARED_TERRAFORM_DIR } from "../shared-constructs-constants.js";
8
9
  import { terraformProviderVersions } from "../versions.js";
@@ -20,10 +21,16 @@ export const addRdbInfra = async (tree, options)=>{
20
21
  });
21
22
  };
22
23
  export const addRdbCdkConstructs = async (tree, options)=>{
23
- generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'cdk', 'core', 'rdb'), joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'core', 'rdb'), options, {
24
+ generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'cdk', 'core', 'rdb'), joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'core', 'rdb'), {
25
+ ...options,
26
+ ...esmVars(tree)
27
+ }, {
24
28
  overwriteStrategy: OverwriteStrategy.KeepExisting
25
29
  });
26
- generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'dbs'), joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'dbs'), options, {
30
+ generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'dbs'), joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'dbs'), {
31
+ ...options,
32
+ ...esmVars(tree)
33
+ }, {
27
34
  overwriteStrategy: OverwriteStrategy.KeepExisting
28
35
  });
29
36
  await addStarExport(tree, joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'core', 'index.ts'), './rdb/aurora.js');
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/rdb-constructs/rdb-constructs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { addStarExport } from '../ast';\nimport type { Containers } from '../containers';\nimport type { Iac } from '../iac';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\nimport { terraformProviderVersions } from '../versions';\n\nexport interface AddRdbConstructOptions {\n projectName: string;\n projectRoot: string;\n nameClassName: string;\n nameKebabCase: string;\n databasePackageAlias: string;\n databaseName: string;\n adminUser: string;\n engine: 'postgres' | 'mysql';\n migrationBundleDir: string;\n createDbUserBundleDir: string;\n dockerImageTag: string;\n containerEngine: Containers;\n}\n\nexport const addRdbInfra = async (\n tree: Tree,\n options: AddRdbConstructOptions & { iac: Iac },\n) => {\n if (options.iac === 'cdk') {\n await addRdbCdkConstructs(tree, options);\n } else if (options.iac === 'terraform') {\n addRdbTerraformModules(tree, options);\n } else {\n throw new Error(`Unsupported iac ${options.iac}`);\n }\n\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.projectName}:build`,\n );\n return config;\n },\n );\n};\n\nexport const addRdbCdkConstructs = async (\n tree: Tree,\n options: AddRdbConstructOptions,\n) => {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cdk', 'core', 'rdb'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'rdb',\n ),\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'dbs'),\n joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'dbs'),\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'index.ts',\n ),\n './rdb/aurora.js',\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'dbs',\n 'index.ts',\n ),\n `./${options.nameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n './dbs/index.js',\n );\n};\n\nexport const addRdbTerraformModules = (\n tree: Tree,\n options: AddRdbConstructOptions,\n) => {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'terraform', 'core', 'rdb'),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'core', 'rdb'),\n { ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'terraform', 'app', 'dbs'),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'app', 'dbs'),\n { ...options, ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","addStarExport","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","terraformProviderVersions","addRdbInfra","tree","options","iac","addRdbCdkConstructs","addRdbTerraformModules","Error","config","projectName","dirname","overwriteStrategy","KeepExisting","nameKebabCase"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,aAAa,QAAQ,YAAS;AAGvC,SAASC,iCAAiC,QAAQ,WAAQ;AAC1D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,oCAAiC;AACxC,SAASC,yBAAyB,QAAQ,iBAAc;AAiBxD,OAAO,MAAMC,cAAc,OACzBC,MACAC;IAEA,IAAIA,QAAQC,GAAG,KAAK,OAAO;QACzB,MAAMC,oBAAoBH,MAAMC;IAClC,OAAO,IAAIA,QAAQC,GAAG,KAAK,aAAa;QACtCE,uBAAuBJ,MAAMC;IAC/B,OAAO;QACL,MAAM,IAAII,MAAM,CAAC,gBAAgB,EAAEJ,QAAQC,GAAG,EAAE;IAClD;IAEAV,WACEQ,MACAV,kBACEK,cACAM,QAAQC,GAAG,KAAK,QAAQN,wBAAwBC,sBAChD,iBAEF,CAACS;QACCZ,kCACEY,QACA,SACA,GAAGL,QAAQM,WAAW,CAAC,MAAM,CAAC;QAEhC,OAAOD;IACT;AAEJ,EAAE;AAEF,OAAO,MAAMH,sBAAsB,OACjCH,MACAC;IAEAZ,cACEW,MACAV,kBAAkB,YAAYkB,OAAO,EAAE,SAAS,OAAO,QAAQ,QAC/DlB,kBACEK,cACAC,uBACA,OACA,QACA,QAEFK,SACA;QACEQ,mBAAmBlB,kBAAkBmB,YAAY;IACnD;IAGFrB,cACEW,MACAV,kBAAkB,YAAYkB,OAAO,EAAE,SAAS,OAAO,OAAO,QAC9DlB,kBAAkBK,cAAcC,uBAAuB,OAAO,OAAO,QACrEK,SACA;QACEQ,mBAAmBlB,kBAAkBmB,YAAY;IACnD;IAGF,MAAMjB,cACJO,MACAV,kBACEK,cACAC,uBACA,OACA,QACA,aAEF;IAEF,MAAMH,cACJO,MACAV,kBACEK,cACAC,uBACA,OACA,OACA,OACA,aAEF,CAAC,EAAE,EAAEK,QAAQU,aAAa,CAAC,GAAG,CAAC;IAEjC,MAAMlB,cACJO,MACAV,kBACEK,cACAC,uBACA,OACA,OACA,aAEF;AAEJ,EAAE;AAEF,OAAO,MAAMQ,yBAAyB,CACpCJ,MACAC;IAEAZ,cACEW,MACAV,kBAAkB,YAAYkB,OAAO,EAAE,SAAS,aAAa,QAAQ,QACrElB,kBAAkBK,cAAcE,sBAAsB,OAAO,QAAQ,QACrE;QAAE,GAAGC,2BAA2B;IAAC,GACjC;QACEW,mBAAmBlB,kBAAkBmB,YAAY;IACnD;IAGFrB,cACEW,MACAV,kBAAkB,YAAYkB,OAAO,EAAE,SAAS,aAAa,OAAO,QACpElB,kBAAkBK,cAAcE,sBAAsB,OAAO,OAAO,QACpE;QAAE,GAAGI,OAAO;QAAE,GAAGH,2BAA2B;IAAC,GAC7C;QACEW,mBAAmBlB,kBAAkBmB,YAAY;IACnD;AAEJ,EAAE"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/rdb-constructs/rdb-constructs.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { addStarExport } from '../ast';\nimport type { Containers } from '../containers';\nimport type { Iac } from '../iac';\nimport { esmVars } from '../module-format';\nimport { addDependencyToTargetIfNotPresent } from '../nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\nimport { terraformProviderVersions } from '../versions';\n\nexport interface AddRdbConstructOptions {\n projectName: string;\n projectRoot: string;\n nameClassName: string;\n nameKebabCase: string;\n databasePackageAlias: string;\n databaseName: string;\n adminUser: string;\n engine: 'postgres' | 'mysql';\n migrationBundleDir: string;\n /**\n * Node.js zip bundle directory for the create-db-user Lambda (ts#rdb).\n * When absent the migration Docker image is reused with the\n * `create_db_user_handler.handler` command (py#rdb).\n */\n createDbUserBundleDir: string;\n /** ORM framework used by the create-db-user Lambda. */\n framework: 'prisma' | 'sqlmodel';\n /** Local Docker tag for the Python create-db-user Lambda image. */\n createDbUserDockerImageTag?: string;\n /** Local Docker tag for the migration Lambda image. */\n migrationDockerImageTag: string;\n containerEngine: Containers;\n}\n\nexport const addRdbInfra = async (\n tree: Tree,\n options: AddRdbConstructOptions & { iac: Iac },\n) => {\n if (options.iac === 'cdk') {\n await addRdbCdkConstructs(tree, options);\n } else if (options.iac === 'terraform') {\n addRdbTerraformModules(tree, options);\n } else {\n throw new Error(`Unsupported iac ${options.iac}`);\n }\n\n updateJson(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n options.iac === 'cdk' ? SHARED_CONSTRUCTS_DIR : SHARED_TERRAFORM_DIR,\n 'project.json',\n ),\n (config: ProjectConfiguration) => {\n addDependencyToTargetIfNotPresent(\n config,\n 'build',\n `${options.projectName}:build`,\n );\n return config;\n },\n );\n};\n\nexport const addRdbCdkConstructs = async (\n tree: Tree,\n options: AddRdbConstructOptions,\n) => {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cdk', 'core', 'rdb'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'rdb',\n ),\n { ...options, ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'cdk', 'app', 'dbs'),\n joinPathFragments(PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, 'src', 'app', 'dbs'),\n { ...options, ...esmVars(tree) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'index.ts',\n ),\n './rdb/aurora.js',\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'dbs',\n 'index.ts',\n ),\n `./${options.nameKebabCase}.js`,\n );\n await addStarExport(\n tree,\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'app',\n 'index.ts',\n ),\n './dbs/index.js',\n );\n};\n\nexport const addRdbTerraformModules = (\n tree: Tree,\n options: AddRdbConstructOptions,\n) => {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'terraform', 'core', 'rdb'),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'core', 'rdb'),\n { ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'terraform', 'app', 'dbs'),\n joinPathFragments(PACKAGES_DIR, SHARED_TERRAFORM_DIR, 'src', 'app', 'dbs'),\n { ...options, ...terraformProviderVersions() },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateJson","addStarExport","esmVars","addDependencyToTargetIfNotPresent","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","terraformProviderVersions","addRdbInfra","tree","options","iac","addRdbCdkConstructs","addRdbTerraformModules","Error","config","projectName","dirname","overwriteStrategy","KeepExisting","nameKebabCase"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SAASC,aAAa,QAAQ,YAAS;AAGvC,SAASC,OAAO,QAAQ,sBAAmB;AAC3C,SAASC,iCAAiC,QAAQ,WAAQ;AAC1D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,oCAAiC;AACxC,SAASC,yBAAyB,QAAQ,iBAAc;AA2BxD,OAAO,MAAMC,cAAc,OACzBC,MACAC;IAEA,IAAIA,QAAQC,GAAG,KAAK,OAAO;QACzB,MAAMC,oBAAoBH,MAAMC;IAClC,OAAO,IAAIA,QAAQC,GAAG,KAAK,aAAa;QACtCE,uBAAuBJ,MAAMC;IAC/B,OAAO;QACL,MAAM,IAAII,MAAM,CAAC,gBAAgB,EAAEJ,QAAQC,GAAG,EAAE;IAClD;IAEAX,WACES,MACAX,kBACEM,cACAM,QAAQC,GAAG,KAAK,QAAQN,wBAAwBC,sBAChD,iBAEF,CAACS;QACCZ,kCACEY,QACA,SACA,GAAGL,QAAQM,WAAW,CAAC,MAAM,CAAC;QAEhC,OAAOD;IACT;AAEJ,EAAE;AAEF,OAAO,MAAMH,sBAAsB,OACjCH,MACAC;IAEAb,cACEY,MACAX,kBAAkB,YAAYmB,OAAO,EAAE,SAAS,OAAO,QAAQ,QAC/DnB,kBACEM,cACAC,uBACA,OACA,QACA,QAEF;QAAE,GAAGK,OAAO;QAAE,GAAGR,QAAQO,KAAK;IAAC,GAC/B;QACES,mBAAmBnB,kBAAkBoB,YAAY;IACnD;IAGFtB,cACEY,MACAX,kBAAkB,YAAYmB,OAAO,EAAE,SAAS,OAAO,OAAO,QAC9DnB,kBAAkBM,cAAcC,uBAAuB,OAAO,OAAO,QACrE;QAAE,GAAGK,OAAO;QAAE,GAAGR,QAAQO,KAAK;IAAC,GAC/B;QACES,mBAAmBnB,kBAAkBoB,YAAY;IACnD;IAGF,MAAMlB,cACJQ,MACAX,kBACEM,cACAC,uBACA,OACA,QACA,aAEF;IAEF,MAAMJ,cACJQ,MACAX,kBACEM,cACAC,uBACA,OACA,OACA,OACA,aAEF,CAAC,EAAE,EAAEK,QAAQU,aAAa,CAAC,GAAG,CAAC;IAEjC,MAAMnB,cACJQ,MACAX,kBACEM,cACAC,uBACA,OACA,OACA,aAEF;AAEJ,EAAE;AAEF,OAAO,MAAMQ,yBAAyB,CACpCJ,MACAC;IAEAb,cACEY,MACAX,kBAAkB,YAAYmB,OAAO,EAAE,SAAS,aAAa,QAAQ,QACrEnB,kBAAkBM,cAAcE,sBAAsB,OAAO,QAAQ,QACrE;QAAE,GAAGC,2BAA2B;IAAC,GACjC;QACEW,mBAAmBnB,kBAAkBoB,YAAY;IACnD;IAGFtB,cACEY,MACAX,kBAAkB,YAAYmB,OAAO,EAAE,SAAS,aAAa,OAAO,QACpEnB,kBAAkBM,cAAcE,sBAAsB,OAAO,OAAO,QACpE;QAAE,GAAGI,OAAO;QAAE,GAAGH,2BAA2B;IAAC,GAC7C;QACEW,mBAAmBnB,kBAAkBoB,YAAY;IACnD;AAEJ,EAAE"}