@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.
- package/bin/aws-nx-mcp.js +12317 -10933
- package/docs/get_started/building-with-ai.mdx +116 -0
- package/docs/get_started/concepts.mdx +67 -0
- package/docs/get_started/existing-project.mdx +180 -0
- package/docs/get_started/graph-builder.mdx +39 -0
- package/docs/get_started/quick-start.mdx +277 -0
- package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
- package/docs/get_started/tutorials/dungeon-game/1.mdx +1301 -0
- package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
- package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
- package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
- package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
- package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
- package/docs/get_started/tutorials/existing-project.mdx +4 -0
- package/docs/get_started/upgrading.mdx +147 -0
- package/docs/guides/agentcore-gateway.mdx +490 -0
- package/docs/guides/agentcore-harness.mdx +275 -0
- package/docs/guides/astro-docs.mdx +8 -0
- package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
- package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
- package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
- package/docs/guides/connection/py-agent-a2a.mdx +48 -16
- package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-agent-gateway.mdx +178 -0
- package/docs/guides/connection/py-agent-mcp.mdx +43 -14
- package/docs/guides/connection/py-agent-rdb.mdx +178 -0
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
- package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
- package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
- package/docs/guides/connection/react-agui.mdx +13 -13
- package/docs/guides/connection/react-fastapi.mdx +38 -2
- package/docs/guides/connection/react-py-agent.mdx +9 -15
- package/docs/guides/connection/react-smithy.mdx +3 -3
- package/docs/guides/connection/react-trpc.mdx +1 -1
- package/docs/guides/connection/react-ts-agent.mdx +8 -8
- package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
- package/docs/guides/connection/smithy-rdb.mdx +9 -9
- package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
- package/docs/guides/connection/trpc-rdb.mdx +6 -6
- package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
- package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-agent-gateway.mdx +143 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
- package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
- package/docs/guides/connection.mdx +122 -5
- package/docs/guides/docker-bundling.mdx +69 -12
- package/docs/guides/fastapi.mdx +249 -9
- package/docs/guides/local-development.mdx +87 -0
- package/docs/guides/nx-generator.mdx +4 -3
- package/docs/guides/nx-migration.mdx +165 -0
- package/docs/guides/py-agent.mdx +264 -49
- package/docs/guides/py-dynamodb.mdx +476 -0
- package/docs/guides/py-mcp-server.mdx +61 -2
- package/docs/guides/py-rdb.mdx +265 -0
- package/docs/guides/python-lambda-function.mdx +1 -1
- package/docs/guides/react-website-auth.mdx +65 -4
- package/docs/guides/react-website.mdx +149 -30
- package/docs/guides/runtime-config.mdx +1 -1
- package/docs/guides/security.mdx +75 -0
- package/docs/guides/smithy-project.mdx +167 -0
- package/docs/guides/terraform-project.mdx +2 -2
- package/docs/guides/trpc.mdx +53 -16
- package/docs/guides/ts-agent.mdx +183 -10
- package/docs/guides/ts-dcr-proxy.mdx +569 -0
- package/docs/guides/ts-dynamodb.mdx +66 -242
- package/docs/guides/ts-lambda-function.mdx +1 -1
- package/docs/guides/ts-mcp-server.mdx +109 -29
- package/docs/guides/ts-nx-plugin.mdx +3 -3
- package/docs/guides/ts-rdb.mdx +113 -467
- package/docs/guides/ts-smithy-api.mdx +258 -18
- package/docs/guides/typescript-infrastructure.mdx +46 -24
- package/docs/guides/typescript-project.mdx +134 -27
- package/docs/guides/workspace.mdx +10 -3
- package/docs/snippets/agent/architecture.mdx +1 -1
- package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
- package/docs/snippets/agent/runtime-arn.mdx +23 -2
- package/docs/snippets/agent/securing-your-agent.mdx +39 -0
- package/docs/snippets/api/access-logging.mdx +33 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
- package/docs/snippets/api/type-safe-api-integrations.mdx +33 -2
- package/docs/snippets/api/waf-configuration.mdx +3 -3
- package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
- package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
- package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
- package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
- package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
- package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
- package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
- package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
- package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
- package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
- package/docs/snippets/mcp/architecture.mdx +1 -1
- package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
- package/docs/snippets/mcp/config.mdx +3 -2
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
- package/docs/snippets/prerequisites.mdx +1 -4
- package/docs/snippets/rdb/architecture.mdx +38 -0
- package/docs/snippets/rdb/cluster-instances.mdx +31 -0
- package/docs/snippets/rdb/deletion-protection.mdx +34 -0
- package/docs/snippets/rdb/deploying.mdx +187 -0
- package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
- package/docs/snippets/rdb/engine-version.mdx +63 -0
- package/docs/snippets/rdb/infrastructure.mdx +35 -0
- package/docs/snippets/rdb/logging-mysql.mdx +5 -0
- package/docs/snippets/rdb/logging-postgres.mdx +5 -0
- package/docs/snippets/rdb/performance-insights.mdx +34 -0
- package/docs/snippets/rdb/rds-proxy.mdx +50 -0
- package/docs/snippets/rdb/removal-policy.mdx +57 -0
- package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
- package/docs/snippets/recommended-prerequisites.mdx +10 -0
- package/docs/snippets/required-prerequisites.mdx +1 -4
- package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
- package/docs/snippets/shared-constructs.mdx +1 -1
- package/docs/snippets/trivy-image-scan.mdx +37 -0
- package/generators.json +152 -10
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/schema.json +31 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
- package/src/agentcore-gateway/react-connection/schema.json +31 -0
- package/src/agentcore-gateway/schema.json +72 -0
- package/src/agentcore-harness/schema.json +53 -0
- package/src/connection/schema.json +5 -0
- package/src/infra/app/schema.json +5 -0
- package/src/init/schema.json +35 -0
- package/src/internal/test-matrix/schema.json +21 -0
- package/src/license/schema.json +5 -0
- package/src/preset/schema.json +16 -5
- package/src/py/agent/a2a-connection/schema.json +5 -0
- package/src/py/agent/gateway-connection/schema.json +31 -0
- package/src/py/agent/mcp-connection/schema.json +5 -0
- package/src/py/agent/react-connection/schema.json +5 -0
- package/src/py/agent/schema.json +15 -1
- package/src/py/api/schema.json +5 -0
- package/src/py/dynamodb/agent-connection/schema.json +27 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
- package/src/py/dynamodb/schema.json +76 -0
- package/src/py/fast-api/react/schema.json +5 -0
- package/src/py/fast-api/schema.json +6 -0
- package/src/py/lambda-function/schema.json +5 -0
- package/src/py/mcp-server/schema.json +6 -0
- package/src/py/project/schema.json +5 -0
- package/src/py/rdb/agent-connection/schema.json +27 -0
- package/src/py/rdb/fast-api-connection/schema.json +23 -0
- package/src/py/rdb/mcp-server-connection/schema.json +27 -0
- package/src/py/rdb/schema.json +78 -0
- package/src/smithy/project/schema.json +28 -1
- package/src/smithy/react-connection/schema.json +5 -0
- package/src/smithy/ts/api/schema.json +6 -0
- package/src/terraform/project/schema.json +5 -0
- package/src/trpc/backend/schema.json +6 -0
- package/src/trpc/react/schema.json +5 -0
- package/src/ts/agent/a2a-connection/schema.json +5 -0
- package/src/ts/agent/gateway-connection/schema.json +31 -0
- package/src/ts/agent/mcp-connection/schema.json +5 -0
- package/src/ts/agent/react-connection/schema.json +5 -0
- package/src/ts/agent/schema.json +14 -0
- package/src/ts/api/schema.json +5 -0
- package/src/ts/astro-docs/schema.json +3 -3
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/docs/schema.json +3 -3
- package/src/ts/dynamodb/agent-connection/schema.json +5 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/ts/dynamodb/schema.json +26 -2
- package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
- package/src/ts/lambda-function/schema.json +5 -0
- package/src/ts/lib/schema.json +5 -0
- package/src/ts/mcp-server/schema.json +6 -0
- package/src/ts/nx-generator/schema.json +5 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/schema.json +5 -0
- package/src/ts/rdb/agent-connection/schema.json +5 -0
- package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
- package/src/ts/rdb/schema.json +7 -1
- package/src/ts/rdb/smithy-connection/schema.json +5 -0
- package/src/ts/rdb/trpc-connection/schema.json +5 -0
- package/src/ts/react-website/app/schema.json +12 -6
- package/src/ts/react-website/cognito-auth/schema.json +5 -0
- package/src/ts/react-website/runtime-config/schema.json +5 -0
- package/src/ts/website/app/schema.json +11 -6
- package/src/ts/website/auth/schema.json +5 -0
- /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
- /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
package/docs/guides/ts-rdb.mdx
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
106
|
-
shape: image
|
|
107
|
-
icon: /nx-plugin-for-aws/icons/aws/rds.svg
|
|
108
|
-
}
|
|
65
|
+
### Infrastructure
|
|
109
66
|
|
|
110
|
-
|
|
111
|
-
shape: image
|
|
112
|
-
icon: /nx-plugin-for-aws/icons/aws/aurora.svg
|
|
113
|
-
}
|
|
67
|
+
<Snippet name="rdb/infrastructure" />
|
|
114
68
|
|
|
115
|
-
|
|
116
|
-
shape: image
|
|
117
|
-
icon: /nx-plugin-for-aws/icons/aws/secrets-manager.svg
|
|
118
|
-
near: bottom-right
|
|
119
|
-
}
|
|
69
|
+
#### Architecture
|
|
120
70
|
|
|
121
|
-
|
|
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 `
|
|
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 `
|
|
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 '
|
|
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
|
-
|
|
187
|
+
`getPrisma()` fetches the database connection settings from AWS AppConfig at runtime.
|
|
243
188
|
|
|
244
|
-
|
|
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
|
-
|
|
193
|
+
<Snippet name="rdb/deploying" parentHeading="Deploying your Database" />
|
|
254
194
|
|
|
255
|
-
|
|
256
|
-
<Fragment slot="cdk">
|
|
257
|
-
The CDK construct is created in `common/constructs`. Example usage:
|
|
195
|
+
### Image Scanning
|
|
258
196
|
|
|
259
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
207
|
+
For Amazon RDS, use the global CA bundle from:
|
|
298
208
|
|
|
299
|
-
|
|
300
|
-
-
|
|
301
|
-
|
|
302
|
-
</Fragment>
|
|
303
|
-
</Infrastructure>
|
|
209
|
+
```text
|
|
210
|
+
https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
|
|
211
|
+
```
|
|
304
212
|
|
|
305
|
-
|
|
213
|
+
##### Runtime Container Images
|
|
306
214
|
|
|
307
|
-
|
|
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
|
-
<
|
|
310
|
-
<
|
|
217
|
+
<Tabs>
|
|
218
|
+
<TabItem label="Amazon Linux">
|
|
311
219
|
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
</
|
|
332
|
-
<
|
|
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
|
-
|
|
346
|
-
|
|
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
|
-
</
|
|
351
|
-
</
|
|
237
|
+
</TabItem>
|
|
238
|
+
</Tabs>
|
|
352
239
|
|
|
353
|
-
|
|
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
|
-
|
|
369
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
288
|
+
<Snippet name="rdb/engine-version" />
|
|
540
289
|
|
|
541
|
-
|
|
290
|
+
### Deletion Protection
|
|
542
291
|
|
|
543
|
-
|
|
292
|
+
<Snippet name="rdb/deletion-protection" />
|
|
544
293
|
|
|
545
|
-
|
|
546
|
-
<Infrastructure>
|
|
547
|
-
<Fragment slot="cdk">
|
|
294
|
+
### Removal Policy
|
|
548
295
|
|
|
549
|
-
|
|
550
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
296
|
+
<Snippet name="rdb/removal-policy" />
|
|
551
297
|
|
|
552
|
-
|
|
553
|
-
...
|
|
554
|
-
engineVersion: AuroraPostgresEngineVersion.VER_17_7,
|
|
555
|
-
});
|
|
556
|
-
```
|
|
557
|
-
</Fragment>
|
|
558
|
-
<Fragment slot="terraform">
|
|
298
|
+
### Logging and Monitoring
|
|
559
299
|
|
|
560
|
-
|
|
561
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
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
|
-
|
|
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 '
|
|
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>
|