@aws/nx-plugin-mcp 1.0.0-rc.7 → 1.0.0-rc.71

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 (195) hide show
  1. package/bin/aws-nx-mcp.js +12317 -10933
  2. package/docs/get_started/building-with-ai.mdx +116 -0
  3. package/docs/get_started/concepts.mdx +67 -0
  4. package/docs/get_started/existing-project.mdx +180 -0
  5. package/docs/get_started/graph-builder.mdx +39 -0
  6. package/docs/get_started/quick-start.mdx +277 -0
  7. package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
  8. package/docs/get_started/tutorials/dungeon-game/1.mdx +1301 -0
  9. package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
  10. package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
  11. package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
  12. package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
  13. package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
  14. package/docs/get_started/tutorials/existing-project.mdx +4 -0
  15. package/docs/get_started/upgrading.mdx +147 -0
  16. package/docs/guides/agentcore-gateway.mdx +490 -0
  17. package/docs/guides/agentcore-harness.mdx +275 -0
  18. package/docs/guides/astro-docs.mdx +8 -0
  19. package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
  20. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  21. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  22. package/docs/guides/connection/py-agent-a2a.mdx +48 -16
  23. package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
  24. package/docs/guides/connection/py-agent-gateway.mdx +178 -0
  25. package/docs/guides/connection/py-agent-mcp.mdx +43 -14
  26. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  27. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  28. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  29. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
  30. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  31. package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
  32. package/docs/guides/connection/react-agui.mdx +13 -13
  33. package/docs/guides/connection/react-fastapi.mdx +38 -2
  34. package/docs/guides/connection/react-py-agent.mdx +9 -15
  35. package/docs/guides/connection/react-smithy.mdx +3 -3
  36. package/docs/guides/connection/react-trpc.mdx +1 -1
  37. package/docs/guides/connection/react-ts-agent.mdx +8 -8
  38. package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
  39. package/docs/guides/connection/smithy-rdb.mdx +9 -9
  40. package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
  41. package/docs/guides/connection/trpc-rdb.mdx +6 -6
  42. package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
  43. package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
  44. package/docs/guides/connection/ts-agent-gateway.mdx +143 -0
  45. package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
  46. package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
  47. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
  48. package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
  49. package/docs/guides/connection.mdx +122 -5
  50. package/docs/guides/docker-bundling.mdx +69 -12
  51. package/docs/guides/fastapi.mdx +249 -9
  52. package/docs/guides/local-development.mdx +87 -0
  53. package/docs/guides/nx-generator.mdx +4 -3
  54. package/docs/guides/nx-migration.mdx +165 -0
  55. package/docs/guides/py-agent.mdx +264 -49
  56. package/docs/guides/py-dynamodb.mdx +476 -0
  57. package/docs/guides/py-mcp-server.mdx +61 -2
  58. package/docs/guides/py-rdb.mdx +265 -0
  59. package/docs/guides/python-lambda-function.mdx +1 -1
  60. package/docs/guides/react-website-auth.mdx +65 -4
  61. package/docs/guides/react-website.mdx +149 -30
  62. package/docs/guides/runtime-config.mdx +1 -1
  63. package/docs/guides/security.mdx +75 -0
  64. package/docs/guides/smithy-project.mdx +167 -0
  65. package/docs/guides/terraform-project.mdx +2 -2
  66. package/docs/guides/trpc.mdx +53 -16
  67. package/docs/guides/ts-agent.mdx +183 -10
  68. package/docs/guides/ts-dcr-proxy.mdx +569 -0
  69. package/docs/guides/ts-dynamodb.mdx +66 -242
  70. package/docs/guides/ts-lambda-function.mdx +1 -1
  71. package/docs/guides/ts-mcp-server.mdx +109 -29
  72. package/docs/guides/ts-nx-plugin.mdx +3 -3
  73. package/docs/guides/ts-rdb.mdx +113 -467
  74. package/docs/guides/ts-smithy-api.mdx +258 -18
  75. package/docs/guides/typescript-infrastructure.mdx +46 -24
  76. package/docs/guides/typescript-project.mdx +134 -27
  77. package/docs/guides/workspace.mdx +10 -3
  78. package/docs/snippets/agent/architecture.mdx +1 -1
  79. package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
  80. package/docs/snippets/agent/runtime-arn.mdx +23 -2
  81. package/docs/snippets/agent/securing-your-agent.mdx +39 -0
  82. package/docs/snippets/api/access-logging.mdx +33 -0
  83. package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
  84. package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
  85. package/docs/snippets/api/type-safe-api-integrations.mdx +33 -2
  86. package/docs/snippets/api/waf-configuration.mdx +3 -3
  87. package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
  88. package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
  89. package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
  90. package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
  91. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  92. package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
  93. package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
  94. package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
  95. package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
  96. package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
  97. package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
  98. package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
  99. package/docs/snippets/mcp/architecture.mdx +1 -1
  100. package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
  101. package/docs/snippets/mcp/config.mdx +3 -2
  102. package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
  103. package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
  104. package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
  105. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
  106. package/docs/snippets/prerequisites.mdx +1 -4
  107. package/docs/snippets/rdb/architecture.mdx +38 -0
  108. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  109. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  110. package/docs/snippets/rdb/deploying.mdx +187 -0
  111. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  112. package/docs/snippets/rdb/engine-version.mdx +63 -0
  113. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  114. package/docs/snippets/rdb/logging-mysql.mdx +5 -0
  115. package/docs/snippets/rdb/logging-postgres.mdx +5 -0
  116. package/docs/snippets/rdb/performance-insights.mdx +34 -0
  117. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  118. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  119. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  120. package/docs/snippets/recommended-prerequisites.mdx +10 -0
  121. package/docs/snippets/required-prerequisites.mdx +1 -4
  122. package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
  123. package/docs/snippets/shared-constructs.mdx +1 -1
  124. package/docs/snippets/trivy-image-scan.mdx +37 -0
  125. package/generators.json +152 -10
  126. package/package.json +1 -1
  127. package/src/agentcore-gateway/agent-connection/schema.json +31 -0
  128. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  129. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  130. package/src/agentcore-gateway/react-connection/schema.json +31 -0
  131. package/src/agentcore-gateway/schema.json +72 -0
  132. package/src/agentcore-harness/schema.json +53 -0
  133. package/src/connection/schema.json +5 -0
  134. package/src/infra/app/schema.json +5 -0
  135. package/src/init/schema.json +35 -0
  136. package/src/internal/test-matrix/schema.json +21 -0
  137. package/src/license/schema.json +5 -0
  138. package/src/preset/schema.json +16 -5
  139. package/src/py/agent/a2a-connection/schema.json +5 -0
  140. package/src/py/agent/gateway-connection/schema.json +31 -0
  141. package/src/py/agent/mcp-connection/schema.json +5 -0
  142. package/src/py/agent/react-connection/schema.json +5 -0
  143. package/src/py/agent/schema.json +15 -1
  144. package/src/py/api/schema.json +5 -0
  145. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  146. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  147. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  148. package/src/py/dynamodb/schema.json +76 -0
  149. package/src/py/fast-api/react/schema.json +5 -0
  150. package/src/py/fast-api/schema.json +6 -0
  151. package/src/py/lambda-function/schema.json +5 -0
  152. package/src/py/mcp-server/schema.json +6 -0
  153. package/src/py/project/schema.json +5 -0
  154. package/src/py/rdb/agent-connection/schema.json +27 -0
  155. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  156. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  157. package/src/py/rdb/schema.json +78 -0
  158. package/src/smithy/project/schema.json +28 -1
  159. package/src/smithy/react-connection/schema.json +5 -0
  160. package/src/smithy/ts/api/schema.json +6 -0
  161. package/src/terraform/project/schema.json +5 -0
  162. package/src/trpc/backend/schema.json +6 -0
  163. package/src/trpc/react/schema.json +5 -0
  164. package/src/ts/agent/a2a-connection/schema.json +5 -0
  165. package/src/ts/agent/gateway-connection/schema.json +31 -0
  166. package/src/ts/agent/mcp-connection/schema.json +5 -0
  167. package/src/ts/agent/react-connection/schema.json +5 -0
  168. package/src/ts/agent/schema.json +14 -0
  169. package/src/ts/api/schema.json +5 -0
  170. package/src/ts/astro-docs/schema.json +3 -3
  171. package/src/ts/dcr-proxy/schema.json +44 -0
  172. package/src/ts/docs/schema.json +3 -3
  173. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  174. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  175. package/src/ts/dynamodb/schema.json +26 -2
  176. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  177. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  178. package/src/ts/lambda-function/schema.json +5 -0
  179. package/src/ts/lib/schema.json +5 -0
  180. package/src/ts/mcp-server/schema.json +6 -0
  181. package/src/ts/nx-generator/schema.json +5 -0
  182. package/src/ts/nx-migration/schema.json +63 -0
  183. package/src/ts/nx-plugin/schema.json +5 -0
  184. package/src/ts/rdb/agent-connection/schema.json +5 -0
  185. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  186. package/src/ts/rdb/schema.json +7 -1
  187. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  188. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  189. package/src/ts/react-website/app/schema.json +12 -6
  190. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  191. package/src/ts/react-website/runtime-config/schema.json +5 -0
  192. package/src/ts/website/app/schema.json +11 -6
  193. package/src/ts/website/auth/schema.json +5 -0
  194. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  195. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -1,16 +1,17 @@
1
1
  ---
2
- title: Relational Database
2
+ title: TypeScript Relational Database
3
3
  description: Create a relational database project
4
4
  generator: ts#rdb
5
5
  ---
6
6
 
7
- import { FileTree } from '@astrojs/starlight/components';
7
+ import { FileTree, CardGrid, Tabs, TabItem } from '@astrojs/starlight/components';
8
+ import Astro from '@astrojs/react';
9
+ import ConnectionCard from '@components/connection-card.astro';
10
+ import Infrastructure from '@components/infrastructure.astro';
8
11
  import Link from '@components/link.astro';
9
12
  import RunGenerator from '@components/run-generator.astro';
10
13
  import GeneratorParameters from '@components/generator-parameters.astro';
11
- import Infrastructure from '@components/infrastructure.astro';
12
14
  import NxCommands from '@components/nx-commands.astro';
13
- import PackageManagerExecCommand from '@components/package-manager-exec-command.astro';
14
15
  import Snippet from '@components/snippet.astro';
15
16
  import OptionFilter from '@components/option-filter.astro';
16
17
 
@@ -37,92 +38,37 @@ The generator will create the following project structure in the `<directory>/<n
37
38
  - models
38
39
  - example.prisma Example model definition
39
40
  - schema.prisma Main Prisma schema (references models)
40
- - scripts
41
- - pull-image.ts Pulls the database container image for local development
42
- - start-container.ts Starts a local database container
43
- - wait-for-db.ts Waits for the local database to be ready
44
41
  - src
45
42
  - index.ts Project entry point
46
- - constants.ts Local development connection details and runtime config key
47
43
  - prisma.ts Prisma runtime client wrapper
48
44
  - utils.ts Runtime config and secret helpers
49
45
  - create-db-user-handler.ts Lambda handler used to create the application database user during deployment
50
46
  - migration-handler.ts Lambda handler used to run database migrations during deployment
51
47
  - .gitignore Git ignore entries including generated Prisma client output
48
+ - config.json Local development connection details and runtime config key
52
49
  - Dockerfile Container image definition for the migration handler
50
+ - package.json Project manifest defining the project's package name and dependencies
53
51
  - project.json Project configuration and build targets
54
52
  - prisma.config.ts Configuration for Prisma CLI
55
53
  </FileTree>
56
54
 
57
- ### Infrastructure
58
-
59
- <Snippet name="shared-constructs" />
60
-
61
- <Infrastructure>
62
- <Fragment slot="cdk">
63
- <FileTree>
64
- - packages/common/constructs/src
65
- - app
66
- - dbs
67
- - \<name>.ts Infrastructure specific to your database
68
- - core
69
- - rdb
70
- - aurora.ts Generic Aurora database construct
71
- </FileTree>
72
- </Fragment>
73
- <Fragment slot="terraform">
74
- <FileTree>
75
- - packages/common/terraform/src
76
- - app
77
- - dbs
78
- - \<name>
79
- - \<name>.tf Module specific to your database
80
- - core
81
- - rdb
82
- - aurora
83
- - aurora.tf Generic Aurora module
84
- </FileTree>
85
- </Fragment>
86
- </Infrastructure>
87
-
88
- #### Architecture
89
-
90
- The deployed database has the following architecture. By default, an [Amazon RDS Proxy](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html) sits in front of the Aurora cluster to pool connections and to enable [IAM authentication](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html) — see [Disable RDS Proxy](#disable-rds-proxy) for the alternative. The architecture is the same whether you select the PostgreSQL or MySQL engine; only the Aurora engine flavor differs.
91
-
92
- ```d2 inline=true
93
- direction: right
55
+ Local development scripts are shared across all database projects and generated into `packages/common/scripts/`:
94
56
 
95
- app: Application\n(Lambda, Agent, ...) {
96
- shape: hexagon
97
- }
98
-
99
- migrations: Migrations Lambda {
100
- shape: image
101
- icon: /nx-plugin-for-aws/icons/aws/lambda.svg
102
- near: top-right
103
- }
57
+ <FileTree>
58
+ - packages/common/scripts/src/rdb
59
+ - pull-image.ts Pulls the database container image
60
+ - start-container.ts Starts a local database container
61
+ - wait-for-postgres-db.ts Waits for the local database to be ready (PostgreSQL)
62
+ - wait-for-mysql-db.ts Waits for the local database to be ready (MySQL)
63
+ </FileTree>
104
64
 
105
- proxy: RDS Proxy {
106
- shape: image
107
- icon: /nx-plugin-for-aws/icons/aws/rds.svg
108
- }
65
+ ### Infrastructure
109
66
 
110
- aurora: Aurora\n(PostgreSQL or MySQL) {
111
- shape: image
112
- icon: /nx-plugin-for-aws/icons/aws/aurora.svg
113
- }
67
+ <Snippet name="rdb/infrastructure" />
114
68
 
115
- secrets: Secrets Manager\n(DB credentials) {
116
- shape: image
117
- icon: /nx-plugin-for-aws/icons/aws/secrets-manager.svg
118
- near: bottom-right
119
- }
69
+ #### Architecture
120
70
 
121
- app -> proxy: SQL (IAM auth)
122
- proxy -> aurora
123
- migrations -> aurora: Schema migrations
124
- proxy -> secrets: Master credential rotation
125
- ```
71
+ <Snippet name="rdb/architecture" />
126
72
 
127
73
  ## Local Development
128
74
 
@@ -156,7 +102,6 @@ Use the `prisma` target to run Prisma CLI commands from the workspace root:
156
102
 
157
103
  The runtime wrapper in `src/prisma.ts` exports:
158
104
 
159
- - `DB_PACKAGE_NAME` - the key used under the `database` runtime config namespace in AWS AppConfig
160
105
  - `getPrisma()` - loads database connection settings from AWS AppConfig and creates a Prisma client using IAM authentication
161
106
 
162
107
  The client automatically:
@@ -212,10 +157,10 @@ The generated `prisma` target exposes the Prisma CLI, so you can use it to run a
212
157
 
213
158
  ### Stopping the Local Database
214
159
 
215
- Stopping `serve-local` (e.g. with `Ctrl+C`) automatically removes the local database container, but preserves the named volume so your data persists across restarts.
160
+ Stopping `dev` (e.g. with `Ctrl+C`) automatically removes the local database container, but preserves the named volume so your data persists across restarts.
216
161
 
217
162
  :::caution[Windows]
218
- Due to limitations with signal handling on Windows, the container is not automatically removed when `serve-local` is stopped. You will need to remove it manually:
163
+ Due to limitations with signal handling on Windows, the container is not automatically removed when `dev` is stopped. You will need to remove it manually:
219
164
 
220
165
  ```bash
221
166
  <engine> rm -f <scope>-<db-name>
@@ -229,7 +174,7 @@ Replace `<engine>` with your container engine (`docker` or `finch`), `<scope>` w
229
174
  In any TypeScript project, import `getPrisma` from your database package and call it to get a type-safe Prisma client:
230
175
 
231
176
  ```ts
232
- import { getPrisma } from ':my-scope/db';
177
+ import { getPrisma } from '@my-scope/db';
233
178
 
234
179
  const prisma = await getPrisma();
235
180
  const users = await prisma.user.findMany({ orderBy: { id: 'asc' } });
@@ -239,467 +184,132 @@ const users = await prisma.user.findMany({ orderBy: { id: 'asc' } });
239
184
 
240
185
  The Prisma client exposes fully typed models derived from your `prisma/models/` schema, giving you end-to-end type safety from the database all the way through to your API response.
241
186
 
242
- ### Connection Generators
187
+ `getPrisma()` fetches the database connection settings from AWS AppConfig at runtime.
243
188
 
244
- For specific project types, use the `connection` generator to automatically wire up the database — it handles imports, context injection, and local development dependencies:
245
-
246
- - <Link path="guides/connection/trpc-rdb">tRPC API → Relational Database</Link>
247
- - <Link path="guides/connection/smithy-rdb">Smithy API → Relational Database</Link>
248
- - <Link path="guides/connection/ts-agent-rdb">TypeScript Agent → Relational Database</Link>
249
- - <Link path="guides/connection/ts-mcp-server-rdb">MCP Server → Relational Database</Link>
189
+ <Snippet name="runtime-config-app-id-note" parentHeading="Connecting to the Database" />
250
190
 
251
191
  ## Deploying your Database
252
192
 
253
- The relational database generator creates CDK or Terraform infrastructure based on your selected `iacProvider`.
193
+ <Snippet name="rdb/deploying" parentHeading="Deploying your Database" />
254
194
 
255
- <Infrastructure>
256
- <Fragment slot="cdk">
257
- The CDK construct is created in `common/constructs`. Example usage:
195
+ ### Image Scanning
258
196
 
259
- ```ts title="packages/infra/src/stacks/application-stack.ts"
260
- import { MyDatabase } from ':my-scope/common-constructs';
261
-
262
- export class ApplicationStack extends Stack {
263
- constructor(scope: Construct, id: string, props?: StackProps) {
264
- super(scope, id, props);
265
- ...
266
- const db = new MyDatabase(this, 'Db', {
267
- vpc,
268
- vpcSubnets: {
269
- subnetType: SubnetType.PRIVATE_ISOLATED,
270
- }
271
- });
272
- }
273
- }
274
- ```
197
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
275
198
 
276
- This provisions an Aurora cluster with RDS Proxy, admin credentials, application database user, runtime config registration, and migration handler.
277
-
278
- The generated infrastructure creates two database users:
279
- - **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
280
- - **Application user** - Created via a Lambda custom resource with IAM authentication enabled and full privileges on the application database
281
- </Fragment>
282
- <Fragment slot="terraform">
283
- The Terraform module is created in `common/terraform`. Example usage:
199
+ ### RDS Proxy Configuration
284
200
 
285
- ```hcl title="packages/infra/src/main.tf"
286
- module "my_database" {
287
- source = "../../common/terraform/src/app/dbs/my-database"
201
+ <Snippet name="rdb/rds-proxy" parentHeading="RDS Proxy Configuration" />
288
202
 
289
- vpc_id = module.vpc.vpc_id
290
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
291
- lambda_subnet_ids = module.vpc.private_subnet_ids
203
+ #### SSL Requirements When Connecting Without RDS Proxy
292
204
 
293
- tags = local.common_tags
294
- }
295
- ```
205
+ When connecting directly to the Aurora cluster (without RDS Proxy), the runtime that calls `getPrisma()` must trust the Amazon RDS CA bundle. The generated Prisma client enables certificate verification; how you make the CA bundle available depends on the runtime that connects to the database.
296
206
 
297
- This provisions an Aurora cluster with RDS Proxy, admin credentials, create-db-user Lambda, runtime config registration, migration Lambda, and container registry resources.
207
+ For Amazon RDS, use the global CA bundle from:
298
208
 
299
- The generated infrastructure creates two database users:
300
- - **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
301
- - **Application user** - Created via a Lambda function with IAM authentication enabled and full privileges on the application database
302
- </Fragment>
303
- </Infrastructure>
209
+ ```text
210
+ https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
211
+ ```
304
212
 
305
- The application user is automatically created with a random name and IAM authentication. `getPrisma()` is already configured to authenticate as this user using short-lived RDS tokens, so your application code never handles database passwords.
213
+ ##### Runtime Container Images
306
214
 
307
- Your VPC should include public subnets, private subnets with egress, and private isolated subnets. The database can run in private isolated subnets, while API Lambda functions should run in private subnets with egress so they can reach AWS services such as AppConfig.
215
+ If you prepare your own container image for the runtime, download the RDS CA bundle in your Dockerfile and add it to the operating system trust store.
308
216
 
309
- <Infrastructure>
310
- <Fragment slot="cdk">
217
+ <Tabs>
218
+ <TabItem label="Amazon Linux">
311
219
 
312
- ```ts title="packages/infra/src/stacks/application-stack.ts"
313
- const vpc = new Vpc(this, 'Vpc', {
314
- subnetConfiguration: [
315
- {
316
- name: 'public',
317
- subnetType: SubnetType.PUBLIC,
318
- },
319
- {
320
- name: 'private_with_egress',
321
- subnetType: SubnetType.PRIVATE_WITH_EGRESS,
322
- },
323
- {
324
- name: 'private_isolated',
325
- subnetType: SubnetType.PRIVATE_ISOLATED,
326
- },
327
- ],
328
- });
220
+ ```dockerfile
221
+ RUN curl -fsSL "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" \
222
+ -o /etc/pki/ca-trust/source/anchors/rds-bundle.pem && \
223
+ update-ca-trust
329
224
  ```
330
225
 
331
- </Fragment>
332
- <Fragment slot="terraform">
333
-
334
- ```hcl title="packages/infra/src/main.tf"
335
- module "vpc" {
336
- source = "terraform-aws-modules/vpc/aws"
337
- version = "~> 6.0"
338
-
339
- name = "app"
340
- ...
341
- public_subnet_names = ["public"]
342
- private_subnet_names = ["private_with_egress"]
343
- intra_subnet_names = ["private_isolated"]
226
+ </TabItem>
227
+ <TabItem label="Debian">
344
228
 
345
- enable_nat_gateway = true
346
- single_nat_gateway = true
347
- }
229
+ ```dockerfile
230
+ RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates && \
231
+ rm -rf /var/lib/apt/lists/* && \
232
+ curl -fsSL "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" \
233
+ -o /usr/local/share/ca-certificates/rds-bundle.crt && \
234
+ update-ca-certificates
348
235
  ```
349
236
 
350
- </Fragment>
351
- </Infrastructure>
237
+ </TabItem>
238
+ </Tabs>
352
239
 
353
- ### Connecting an API to the Database
240
+ ##### Zipped Lambda Functions
241
+
242
+ For zipped Lambda functions using Node.js 20 or later runtimes, load the Amazon RDS CA bundle by setting `NODE_EXTRA_CA_CERTS`:
354
243
 
355
244
  <Infrastructure>
356
245
  <Fragment slot="cdk">
357
246
 
358
- In your application stack, deploy the API into the same VPC as the database, then call `allowDefaultPortFrom` and `grantConnect` to open the network path and grant IAM `rds-db:connect` permission to each Lambda handler:
359
-
360
247
  ```ts title="packages/infra/src/stacks/application-stack.ts"
361
- import { MyDatabase } from ':my-scope/common-constructs';
362
-
363
- const db = new MyDatabase(this, 'Db', { vpc, ... });
364
-
365
248
  const api = new Api(this, 'Api', {
366
249
  integrations: Api.defaultIntegrations(this)
367
250
  .withDefaultOptions({
368
- vpc,
369
- vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_EGRESS },
251
+ environment: {
252
+ NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
253
+ },
370
254
  })
371
255
  .build(),
372
256
  });
373
-
374
- Object.entries(api.integrations).forEach(([operation, integration]) => {
375
- db.allowDefaultPortFrom(integration.handler, `Allow ${operation} to connect to the database`);
376
- db.grantConnect(integration.handler);
377
- });
378
257
  ```
379
258
 
380
- Deploy the API Lambda functions into a **private subnet with egress** (recommended) or a public subnet, not a private isolated subnet. At runtime, `getPrisma()` retrieves database connection details from AWS AppConfig, which is a public AWS service endpoint. Lambda functions in a private isolated subnet have no outbound internet access and cannot reach AppConfig. Private subnets with egress route outbound traffic through a NAT Gateway which sits in a public subnet.
381
259
  </Fragment>
382
260
  <Fragment slot="terraform">
383
261
 
384
- Pass the database module outputs into your compute module so it can reach the database and read its runtime configuration:
385
-
386
262
  ```hcl title="packages/infra/src/main.tf"
387
- module "my_database" {
388
- source = "../../common/terraform/src/app/dbs/my-database"
389
- vpc_id = module.vpc.vpc_id
390
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
391
- lambda_subnet_ids = module.vpc.private_subnet_ids
392
- }
393
-
394
263
  module "api" {
395
- source = "..."
396
- vpc_id = module.vpc.vpc_id
397
- private_subnet_ids = module.vpc.private_subnet_ids
398
-
399
- # Allow the API to read runtime config from AppConfig
400
- appconfig_application_id = module.my_database.appconfig_application_id
401
-
402
- # Grant rds-db:connect for the application database user
403
- database_cluster_resource_id = module.my_database.cluster_resource_id
404
- database_runtime_user = module.my_database.database_runtime_user
405
-
406
- # Allow network access to the database port
407
- database_security_group_id = module.my_database.security_group_id
408
- database_port = module.my_database.cluster_port
264
+ source = "..."
265
+ ...
409
266
 
410
267
  environment_variables = {
411
- RUNTIME_CONFIG_APP_ID = module.my_database.appconfig_application_id
268
+ NODE_EXTRA_CA_CERTS = "/var/runtime/ca-cert.pem"
412
269
  }
413
270
  }
414
271
  ```
415
272
 
416
- Deploy the API Lambda functions into **private subnets with egress** (recommended) or public subnets, not private isolated subnets. At runtime, `getPrisma()` retrieves database connection details from AWS AppConfig, which is a public AWS service endpoint. Lambda functions in a private isolated subnet have no outbound internet access and cannot reach AppConfig. Private subnets with egress route outbound traffic through a NAT Gateway which requires a public subnet.
417
-
418
- Ensure the API Lambda role has `rds-db:connect` on `arn:aws:rds-db:<region>:<account>:dbuser:<cluster_resource_id>/<database_runtime_user>` and AppConfig read permissions, that the API's security group can reach the database security group on the database port, and that the Lambda environment includes `RUNTIME_CONFIG_APP_ID`.
419
273
  </Fragment>
420
274
  </Infrastructure>
421
275
 
422
- :::note
423
- This example grants every handler in your API access, but if only some handlers need access it's better to configure individually.
424
- :::
425
-
426
- ### RDS Proxy Configuration
427
-
428
- The generated infrastructure includes an RDS Proxy by default, which sits between your application and the Aurora cluster. RDS Proxy provides several benefits:
429
-
430
- - **Connection pooling** - Maintains a pool of database connections that can be shared across application instances, reducing the overhead of establishing new connections
431
- - **Connection resilience** - Automatically handles failovers and reconnects during Aurora instance replacements or maintenance
432
- - **IAM authentication** - Supports IAM-based database authentication, eliminating the need to manage database credentials in your application code
433
- - **Improved security** - Enforces TLS encryption for all connections
434
-
435
- :::note[Additional Cost]
436
- RDS Proxy is enabled by default but incurs additional charges on top of the Aurora cluster cost. See [AWS RDS Proxy pricing](https://aws.amazon.com/rds/proxy/pricing/) for details. If you would prefer to disable the proxy, see the section below.
437
- :::
438
-
439
- #### Disable RDS Proxy
440
-
441
- You can disable the RDS proxy as follows:
442
-
443
- <Infrastructure>
444
- <Fragment slot="cdk">
445
-
446
-
447
- ```ts title="packages/infra/src/stacks/application-stack.ts"
448
- import { MyDatabase } from ':my-scope/common-constructs';
449
-
450
- const db = new MyDatabase(this, 'Db', {
451
- ...
452
- enableRdsProxy: false,
453
- });
454
- ```
455
-
456
- When RDS Proxy is disabled, your application connects directly to the Aurora cluster endpoint.
457
- </Fragment>
458
- <Fragment slot="terraform">
459
-
460
- By default, RDS Proxy is enabled. The generated runtime client (`getPrisma()`) automatically connects through the proxy endpoint. You can disable it if needed:
461
-
462
- ```hcl title="packages/infra/src/main.tf"
463
- module "my_database" {
464
- source = "../../common/terraform/src/app/dbs/my-database"
465
- ...
466
- enable_rds_proxy = false
467
- }
468
- ```
469
-
470
- When RDS Proxy is disabled, your application connects directly to the Aurora cluster endpoint.
471
- </Fragment>
472
- </Infrastructure>
473
-
474
- <Snippet name="connection/lambda-rdb-ssl-requirements" parentHeading="Disable RDS Proxy" />
475
-
476
- The generated infrastructure can be customised to match your workload requirements. The following examples demonstrate a few common customisation options available.
276
+ For more details, see the AWS Lambda [SSL/TLS requirements for Amazon RDS connections](https://docs.aws.amazon.com/lambda/latest/dg/services-rds.html#services-rds-tls). When using RDS Proxy, you do not need to configure the RDS CA bundle in the runtime that connects to the database.
477
277
 
478
278
  ### Cluster Instances
479
279
 
480
- Configure the writer and reader instances for your Aurora cluster.
481
-
482
- <Infrastructure>
483
- <Fragment slot="cdk">
484
-
485
- ```ts title="packages/infra/src/stacks/application-stack.ts"
486
- import { MyDatabase } from ':my-scope/common-constructs';
487
-
488
- const db = new MyDatabase(this, 'Db', {
489
- ...
490
- writer: ClusterInstance.serverlessV2('writer'),
491
- readers: [ClusterInstance.serverlessV2('reader')],
492
- });
493
- ```
494
- </Fragment>
495
- <Fragment slot="terraform">
496
-
497
- ```hcl title="packages/infra/src/main.tf"
498
- module "my_database" {
499
- source = "../../common/terraform/src/app/dbs/my-database"
500
- ...
501
- instance_count = 2 # 1 writer + 1 reader
502
- }
503
- ```
504
- </Fragment>
505
- </Infrastructure>
280
+ <Snippet name="rdb/cluster-instances" />
506
281
 
507
282
  ### Serverless Capacity
508
283
 
509
- Control Aurora Serverless v2 scaling limits to match your workload.
510
-
511
- <Infrastructure>
512
- <Fragment slot="cdk">
513
-
514
- ```ts title="packages/infra/src/stacks/application-stack.ts"
515
- import { MyDatabase } from ':my-scope/common-constructs';
516
-
517
- const db = new MyDatabase(this, 'Db', {
518
- ...
519
- serverlessV2MinCapacity: 0.5,
520
- serverlessV2MaxCapacity: 8,
521
- });
522
- ```
523
- </Fragment>
524
- <Fragment slot="terraform">
525
-
526
- ```hcl title="packages/infra/src/main.tf"
527
- module "my_database" {
528
- source = "../../common/terraform/src/app/dbs/my-database"
529
- ...
530
- serverless_min_capacity = 0.5
531
- serverless_max_capacity = 8
532
- }
533
- ```
534
- </Fragment>
535
- </Infrastructure>
284
+ <Snippet name="rdb/serverless-capacity" />
536
285
 
537
286
  ### Engine Version
538
287
 
539
- Pin a specific Aurora engine version.
288
+ <Snippet name="rdb/engine-version" />
540
289
 
541
- By default, the generated local database container image matches the default Aurora engine version. If you change the Aurora engine version, it's recommended to also use a matching local container image version for maximum compatibility. See the AWS release notes for [Aurora PostgreSQL versions](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraPostgreSQLReleaseNotes/aurorapostgresql-release-calendar.html) and [Aurora MySQL versions](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraMySQLReleaseNotes/AuroraMySQL.Updates.30Updates.html) to identify the corresponding community database version.
290
+ ### Deletion Protection
542
291
 
543
- The local database image is configured in the generated database project's `serve-local` target in `project.json`. Update the image argument passed to `scripts/start-container.ts` when you change engine versions.
292
+ <Snippet name="rdb/deletion-protection" />
544
293
 
545
- <OptionFilter when={{ engine: 'postgres' }}>
546
- <Infrastructure>
547
- <Fragment slot="cdk">
294
+ ### Removal Policy
548
295
 
549
- ```ts title="packages/infra/src/stacks/application-stack.ts"
550
- import { MyDatabase } from ':my-scope/common-constructs';
296
+ <Snippet name="rdb/removal-policy" />
551
297
 
552
- const db = new MyDatabase(this, 'Db', {
553
- ...
554
- engineVersion: AuroraPostgresEngineVersion.VER_17_7,
555
- });
556
- ```
557
- </Fragment>
558
- <Fragment slot="terraform">
298
+ ### Logging and Monitoring
559
299
 
560
- ```hcl title="packages/infra/src/main.tf"
561
- module "my_database" {
562
- source = "../../common/terraform/src/app/dbs/my-database"
563
- ...
564
- engine_version = "17.7"
565
- }
566
- ```
567
- </Fragment>
568
- </Infrastructure>
300
+ <OptionFilter when={{ engine: 'postgres' }}>
301
+ <Snippet name="rdb/logging-postgres" />
569
302
  </OptionFilter>
570
303
 
571
304
  <OptionFilter when={{ engine: 'mysql' }}>
572
- <Infrastructure>
573
- <Fragment slot="cdk">
574
-
575
- ```ts title="packages/infra/src/stacks/application-stack.ts"
576
- import { MyDatabase } from ':my-scope/common-constructs';
577
-
578
- const db = new MyDatabase(this, 'Db', {
579
- ...
580
- engineVersion: AuroraMysqlEngineVersion.VER_3_12_0,
581
- });
582
- ```
583
- </Fragment>
584
- <Fragment slot="terraform">
585
-
586
- ```hcl title="packages/infra/src/main.tf"
587
- module "my_database" {
588
- source = "../../common/terraform/src/app/dbs/my-database"
589
- ...
590
- engine_version = "8.0.mysql_aurora.3.12.0"
591
- }
592
- ```
593
- </Fragment>
594
- </Infrastructure>
305
+ <Snippet name="rdb/logging-mysql" />
595
306
  </OptionFilter>
596
307
 
597
- ### Deletion Protection
598
-
599
- Deletion protection is enabled by default (`deletionProtection: true` in CDK, `deletion_protection = true` in Terraform) to protect the Aurora cluster from accidental deletion.
600
-
601
- #### Disable Deletion Protection
602
-
603
- You can disable deletion protection for environments where database deletion is expected, such as short-lived development or preview stacks.
604
-
605
- <Infrastructure>
606
- <Fragment slot="cdk">
607
-
608
- ```ts title="packages/infra/src/stacks/application-stack.ts"
609
- import { MyDatabase } from ':my-scope/common-constructs';
610
-
611
- const db = new MyDatabase(this, 'Db', {
612
- ...
613
- deletionProtection: false,
614
- });
615
- ```
616
- </Fragment>
617
- <Fragment slot="terraform">
618
-
619
- ```hcl title="packages/infra/src/main.tf"
620
- module "my_database" {
621
- source = "../../common/terraform/src/app/dbs/my-database"
622
- ...
623
- deletion_protection = false
624
- }
625
- ```
626
- </Fragment>
627
- </Infrastructure>
628
-
629
- ### Removal Policy
630
-
631
- The CDK construct retains the Aurora cluster by default (`removalPolicy: RemovalPolicy.RETAIN`). Change this when you want CDK stack deletion to snapshot or destroy the cluster instead.
632
-
633
- When using `RemovalPolicy.DESTROY`, deletion protection must also be disabled before the cluster can be deleted.
634
-
635
- <Infrastructure>
636
- <Fragment slot="cdk">
637
-
638
- ```ts title="packages/infra/src/stacks/application-stack.ts"
639
- import { RemovalPolicy } from 'aws-cdk-lib';
640
- import { MyDatabase } from ':my-scope/common-constructs';
641
-
642
- const db = new MyDatabase(this, 'Db', {
643
- ...
644
- removalPolicy: RemovalPolicy.SNAPSHOT,
645
- });
646
- ```
647
-
648
- For an ephemeral environment where the database should be deleted with the stack:
649
-
650
- ```ts title="packages/infra/src/stacks/application-stack.ts"
651
- import { RemovalPolicy } from 'aws-cdk-lib';
652
- import { MyDatabase } from ':my-scope/common-constructs';
653
-
654
- const db = new MyDatabase(this, 'Db', {
655
- ...
656
- deletionProtection: false,
657
- removalPolicy: RemovalPolicy.DESTROY,
658
- });
659
- ```
660
- </Fragment>
661
- <Fragment slot="terraform">
662
-
663
- Terraform does not use CDK removal policies. By default, the module creates a final snapshot on deletion (`skip_final_snapshot = false`). To skip the final snapshot for an ephemeral environment:
664
-
665
- ```hcl title="packages/infra/src/main.tf"
666
- module "my_database" {
667
- source = "../../common/terraform/src/app/dbs/my-database"
668
- ...
669
- deletion_protection = false
670
- skip_final_snapshot = true
671
- }
672
- ```
673
- </Fragment>
674
- </Infrastructure>
308
+ <Snippet name="rdb/performance-insights" />
675
309
 
676
310
  ### Encryption Key Rotation
677
311
 
678
- The KMS key used to encrypt the Aurora cluster and its credentials secret has automatic key rotation enabled by default. Disable it if your security policy manages rotation externally.
679
-
680
- <Infrastructure>
681
- <Fragment slot="cdk">
682
-
683
- ```ts title="packages/infra/src/stacks/application-stack.ts"
684
- import { MyDatabase } from ':my-scope/common-constructs';
685
-
686
- const db = new MyDatabase(this, 'Db', {
687
- ...
688
- enableKeyRotation: false,
689
- });
690
- ```
691
- </Fragment>
692
- <Fragment slot="terraform">
693
-
694
- ```hcl title="packages/infra/src/main.tf"
695
- module "my_database" {
696
- source = "../../common/terraform/src/app/dbs/my-database"
697
- ...
698
- enable_key_rotation = false
699
- }
700
- ```
701
- </Fragment>
702
- </Infrastructure>
312
+ <Snippet name="rdb/encryption-key-rotation" />
703
313
 
704
314
  ## Limitations
705
315
 
@@ -731,7 +341,7 @@ export const listExampleTable = publicProcedure
731
341
  If you are using the [middleware pattern](#injecting-the-prisma-client-via-middleware), add the `$disconnect()` call to the middleware so all procedures built on it are covered automatically:
732
342
 
733
343
  ```ts title="packages/api/src/middleware/db.ts"
734
- import { getPrisma } from ':my-scope/db';
344
+ import { getPrisma } from '@my-scope/db';
735
345
  import { initTRPC } from '@trpc/server';
736
346
 
737
347
  export interface IDbContext {
@@ -771,3 +381,39 @@ Be cautious with tasks running longer than 15 minutes. If the MySQL client needs
771
381
  For long-running tasks such as batch jobs or data migrations, call `getPrisma()` at the start of each unit of work rather than once for the entire operation. Because `getPrisma()` always creates a fresh client and fetches a new IAM token for MySQL, this ensures each connection authenticates with a valid token.
772
382
 
773
383
  </OptionFilter>
384
+
385
+ ## Connections
386
+
387
+ Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
388
+
389
+ <CardGrid>
390
+ <ConnectionCard
391
+ title="tRPC API to Relational Database"
392
+ description="Connect a tRPC API to an Aurora relational database"
393
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-rdb`}
394
+ source="trpc"
395
+ target="aurora"
396
+ />
397
+ <ConnectionCard
398
+ title="Smithy API to Relational Database"
399
+ description="Connect a Smithy API to an Aurora relational database"
400
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/smithy-rdb`}
401
+ source="smithy"
402
+ target="aurora"
403
+ />
404
+ <ConnectionCard
405
+ title="TypeScript Agent to Relational Database"
406
+ description="Connect a TypeScript Agent to an Aurora relational database"
407
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-agent-rdb`}
408
+ source="strands"
409
+ sourceBadge="typescript"
410
+ target="aurora"
411
+ />
412
+ <ConnectionCard
413
+ title="MCP Server to Relational Database"
414
+ description="Connect a TypeScript MCP Server to an Aurora relational database"
415
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/ts-mcp-server-rdb`}
416
+ source="mcp"
417
+ target="aurora"
418
+ />
419
+ </CardGrid>