@aws/nx-plugin-mcp 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.
- package/bin/aws-nx-mcp.js +1444 -1348
- package/docs/guides/connection/py-agent-rdb.mdx +162 -0
- package/docs/guides/connection/py-fast-api-rdb.mdx +170 -0
- package/docs/guides/connection/py-mcp-server-rdb.mdx +171 -0
- package/docs/guides/connection/smithy-rdb.mdx +1 -1
- package/docs/guides/connection/trpc-rdb.mdx +1 -1
- package/docs/guides/connection/ts-agent-rdb.mdx +45 -16
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +45 -11
- package/docs/guides/connection.mdx +28 -1
- package/docs/guides/py-rdb.mdx +250 -0
- package/docs/guides/ts-rdb.mdx +48 -483
- package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +36 -15
- 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 +107 -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.mdx +32 -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/generators.json +27 -0
- package/package.json +1 -1
- package/src/preset/schema.json +6 -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 +77 -0
- package/src/ts/rdb/schema.json +1 -1
- /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,18 +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, CardGrid } from '@astrojs/starlight/components';
|
|
7
|
+
import { FileTree, CardGrid, Tabs, TabItem } from '@astrojs/starlight/components';
|
|
8
8
|
import Astro from '@astrojs/react';
|
|
9
9
|
import ConnectionCard from '@components/connection-card.astro';
|
|
10
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
10
11
|
import Link from '@components/link.astro';
|
|
11
12
|
import RunGenerator from '@components/run-generator.astro';
|
|
12
13
|
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
13
|
-
import Infrastructure from '@components/infrastructure.astro';
|
|
14
14
|
import NxCommands from '@components/nx-commands.astro';
|
|
15
|
-
import PackageManagerExecCommand from '@components/package-manager-exec-command.astro';
|
|
16
15
|
import Snippet from '@components/snippet.astro';
|
|
17
16
|
import OptionFilter from '@components/option-filter.astro';
|
|
18
17
|
|
|
@@ -64,73 +63,11 @@ Local development scripts are shared across all database projects and generated
|
|
|
64
63
|
|
|
65
64
|
### Infrastructure
|
|
66
65
|
|
|
67
|
-
<Snippet name="
|
|
68
|
-
|
|
69
|
-
<Infrastructure>
|
|
70
|
-
<Fragment slot="cdk">
|
|
71
|
-
<FileTree>
|
|
72
|
-
- packages/common/constructs/src
|
|
73
|
-
- app
|
|
74
|
-
- dbs
|
|
75
|
-
- \<name>.ts Infrastructure specific to your database
|
|
76
|
-
- core
|
|
77
|
-
- rdb
|
|
78
|
-
- aurora.ts Generic Aurora database construct
|
|
79
|
-
</FileTree>
|
|
80
|
-
</Fragment>
|
|
81
|
-
<Fragment slot="terraform">
|
|
82
|
-
<FileTree>
|
|
83
|
-
- packages/common/terraform/src
|
|
84
|
-
- app
|
|
85
|
-
- dbs
|
|
86
|
-
- \<name>
|
|
87
|
-
- \<name>.tf Module specific to your database
|
|
88
|
-
- core
|
|
89
|
-
- rdb
|
|
90
|
-
- aurora
|
|
91
|
-
- aurora.tf Generic Aurora module
|
|
92
|
-
</FileTree>
|
|
93
|
-
</Fragment>
|
|
94
|
-
</Infrastructure>
|
|
66
|
+
<Snippet name="rdb/infrastructure" />
|
|
95
67
|
|
|
96
68
|
#### Architecture
|
|
97
69
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
```d2 inline=true
|
|
101
|
-
direction: right
|
|
102
|
-
|
|
103
|
-
app: Application\n(Lambda, Agent, ...) {
|
|
104
|
-
shape: hexagon
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
migrations: Migrations Lambda {
|
|
108
|
-
shape: image
|
|
109
|
-
icon: /nx-plugin-for-aws/icons/aws/lambda.svg
|
|
110
|
-
near: top-right
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
proxy: RDS Proxy {
|
|
114
|
-
shape: image
|
|
115
|
-
icon: /nx-plugin-for-aws/icons/aws/rds.svg
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
aurora: Aurora\n(PostgreSQL or MySQL) {
|
|
119
|
-
shape: image
|
|
120
|
-
icon: /nx-plugin-for-aws/icons/aws/aurora.svg
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
secrets: Secrets Manager\n(DB credentials) {
|
|
124
|
-
shape: image
|
|
125
|
-
icon: /nx-plugin-for-aws/icons/aws/secrets-manager.svg
|
|
126
|
-
near: bottom-right
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
app -> proxy: SQL (IAM auth)
|
|
130
|
-
proxy -> aurora
|
|
131
|
-
migrations -> aurora: Schema migrations
|
|
132
|
-
proxy -> secrets: Master credential rotation
|
|
133
|
-
```
|
|
70
|
+
<Snippet name="rdb/architecture" />
|
|
134
71
|
|
|
135
72
|
## Local Development
|
|
136
73
|
|
|
@@ -248,486 +185,114 @@ The Prisma client exposes fully typed models derived from your `prisma/models/`
|
|
|
248
185
|
|
|
249
186
|
## Deploying your Database
|
|
250
187
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
<Infrastructure>
|
|
254
|
-
<Fragment slot="cdk">
|
|
255
|
-
The CDK construct is created in `common/constructs`. Example usage:
|
|
188
|
+
<Snippet name="rdb/deploying" parentHeading="Deploying your Database" />
|
|
256
189
|
|
|
257
|
-
|
|
258
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
259
|
-
|
|
260
|
-
export class ApplicationStack extends Stack {
|
|
261
|
-
constructor(scope: Construct, id: string, props?: StackProps) {
|
|
262
|
-
super(scope, id, props);
|
|
263
|
-
...
|
|
264
|
-
const db = new MyDatabase(this, 'Db', {
|
|
265
|
-
vpc,
|
|
266
|
-
vpcSubnets: {
|
|
267
|
-
subnetType: SubnetType.PRIVATE_ISOLATED,
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
```
|
|
190
|
+
### RDS Proxy Configuration
|
|
273
191
|
|
|
274
|
-
|
|
192
|
+
<Snippet name="rdb/rds-proxy" parentHeading="RDS Proxy Configuration" />
|
|
275
193
|
|
|
276
|
-
|
|
277
|
-
- **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
|
|
278
|
-
- **Application user** - Created via a Lambda custom resource with IAM authentication enabled and full privileges on the application database
|
|
279
|
-
</Fragment>
|
|
280
|
-
<Fragment slot="terraform">
|
|
281
|
-
The Terraform module is created in `common/terraform`. Example usage:
|
|
194
|
+
#### SSL Requirements When Connecting Without RDS Proxy
|
|
282
195
|
|
|
283
|
-
|
|
284
|
-
module "my_database" {
|
|
285
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
196
|
+
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.
|
|
286
197
|
|
|
287
|
-
|
|
288
|
-
database_subnet_ids = module.vpc.private_isolated_subnet_ids
|
|
289
|
-
lambda_subnet_ids = module.vpc.private_subnet_ids
|
|
198
|
+
For Amazon RDS, use the global CA bundle from:
|
|
290
199
|
|
|
291
|
-
|
|
292
|
-
|
|
200
|
+
```text
|
|
201
|
+
https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
|
|
293
202
|
```
|
|
294
203
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
The generated infrastructure creates two database users:
|
|
298
|
-
- **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
|
|
299
|
-
- **Application user** - Created via a Lambda function with IAM authentication enabled and full privileges on the application database
|
|
300
|
-
</Fragment>
|
|
301
|
-
</Infrastructure>
|
|
302
|
-
|
|
303
|
-
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.
|
|
204
|
+
##### Runtime Container Images
|
|
304
205
|
|
|
305
|
-
|
|
206
|
+
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.
|
|
306
207
|
|
|
307
|
-
<
|
|
308
|
-
<
|
|
208
|
+
<Tabs>
|
|
209
|
+
<TabItem label="Amazon Linux">
|
|
309
210
|
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
name: 'public',
|
|
315
|
-
subnetType: SubnetType.PUBLIC,
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
name: 'private_with_egress',
|
|
319
|
-
subnetType: SubnetType.PRIVATE_WITH_EGRESS,
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
name: 'private_isolated',
|
|
323
|
-
subnetType: SubnetType.PRIVATE_ISOLATED,
|
|
324
|
-
},
|
|
325
|
-
],
|
|
326
|
-
});
|
|
211
|
+
```dockerfile
|
|
212
|
+
RUN curl -fsSL "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" \
|
|
213
|
+
-o /etc/pki/ca-trust/source/anchors/rds-bundle.pem && \
|
|
214
|
+
update-ca-trust
|
|
327
215
|
```
|
|
328
216
|
|
|
329
|
-
</
|
|
330
|
-
<
|
|
331
|
-
|
|
332
|
-
```hcl title="packages/infra/src/main.tf"
|
|
333
|
-
module "vpc" {
|
|
334
|
-
source = "terraform-aws-modules/vpc/aws"
|
|
335
|
-
version = "~> 6.0"
|
|
336
|
-
|
|
337
|
-
name = "app"
|
|
338
|
-
...
|
|
339
|
-
public_subnet_names = ["public"]
|
|
340
|
-
private_subnet_names = ["private_with_egress"]
|
|
341
|
-
intra_subnet_names = ["private_isolated"]
|
|
217
|
+
</TabItem>
|
|
218
|
+
<TabItem label="Debian">
|
|
342
219
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
220
|
+
```dockerfile
|
|
221
|
+
RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates && \
|
|
222
|
+
rm -rf /var/lib/apt/lists/* && \
|
|
223
|
+
curl -fsSL "https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem" \
|
|
224
|
+
-o /usr/local/share/ca-certificates/rds-bundle.crt && \
|
|
225
|
+
update-ca-certificates
|
|
346
226
|
```
|
|
347
227
|
|
|
348
|
-
</
|
|
349
|
-
</
|
|
228
|
+
</TabItem>
|
|
229
|
+
</Tabs>
|
|
230
|
+
|
|
231
|
+
##### Zipped Lambda Functions
|
|
350
232
|
|
|
351
|
-
|
|
233
|
+
For zipped Lambda functions using Node.js 20 or later runtimes, load the Amazon RDS CA bundle by setting `NODE_EXTRA_CA_CERTS`:
|
|
352
234
|
|
|
353
235
|
<Infrastructure>
|
|
354
236
|
<Fragment slot="cdk">
|
|
355
237
|
|
|
356
|
-
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:
|
|
357
|
-
|
|
358
238
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
359
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
360
|
-
|
|
361
|
-
const db = new MyDatabase(this, 'Db', { vpc, ... });
|
|
362
|
-
|
|
363
239
|
const api = new Api(this, 'Api', {
|
|
364
240
|
integrations: Api.defaultIntegrations(this)
|
|
365
241
|
.withDefaultOptions({
|
|
366
|
-
|
|
367
|
-
|
|
242
|
+
environment: {
|
|
243
|
+
NODE_EXTRA_CA_CERTS: '/var/runtime/ca-cert.pem',
|
|
244
|
+
},
|
|
368
245
|
})
|
|
369
246
|
.build(),
|
|
370
247
|
});
|
|
371
|
-
|
|
372
|
-
Object.entries(api.integrations).forEach(([operation, integration]) => {
|
|
373
|
-
db.allowDefaultPortFrom(integration.handler, `Allow ${operation} to connect to the database`);
|
|
374
|
-
db.grantConnect(integration.handler);
|
|
375
|
-
});
|
|
376
248
|
```
|
|
377
249
|
|
|
378
|
-
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.
|
|
379
250
|
</Fragment>
|
|
380
251
|
<Fragment slot="terraform">
|
|
381
252
|
|
|
382
|
-
Pass the database module outputs into your compute module so it can reach the database and read its runtime configuration:
|
|
383
|
-
|
|
384
253
|
```hcl title="packages/infra/src/main.tf"
|
|
385
|
-
module "my_database" {
|
|
386
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
387
|
-
vpc_id = module.vpc.vpc_id
|
|
388
|
-
database_subnet_ids = module.vpc.private_isolated_subnet_ids
|
|
389
|
-
lambda_subnet_ids = module.vpc.private_subnet_ids
|
|
390
|
-
}
|
|
391
|
-
|
|
392
254
|
module "api" {
|
|
393
|
-
source
|
|
394
|
-
|
|
395
|
-
private_subnet_ids = module.vpc.private_subnet_ids
|
|
396
|
-
|
|
397
|
-
# Allow the API to read runtime config from AppConfig
|
|
398
|
-
appconfig_application_id = module.my_database.appconfig_application_id
|
|
399
|
-
|
|
400
|
-
# Grant rds-db:connect for the application database user
|
|
401
|
-
database_cluster_resource_id = module.my_database.cluster_resource_id
|
|
402
|
-
database_runtime_user = module.my_database.database_runtime_user
|
|
403
|
-
|
|
404
|
-
# Allow network access to the database port
|
|
405
|
-
database_security_group_id = module.my_database.security_group_id
|
|
406
|
-
database_port = module.my_database.cluster_port
|
|
255
|
+
source = "..."
|
|
256
|
+
...
|
|
407
257
|
|
|
408
258
|
environment_variables = {
|
|
409
|
-
|
|
259
|
+
NODE_EXTRA_CA_CERTS = "/var/runtime/ca-cert.pem"
|
|
410
260
|
}
|
|
411
261
|
}
|
|
412
262
|
```
|
|
413
263
|
|
|
414
|
-
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.
|
|
415
|
-
|
|
416
|
-
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`.
|
|
417
|
-
</Fragment>
|
|
418
|
-
</Infrastructure>
|
|
419
|
-
|
|
420
|
-
:::note
|
|
421
|
-
This example grants every handler in your API access, but if only some handlers need access it's better to configure individually.
|
|
422
|
-
:::
|
|
423
|
-
|
|
424
|
-
### RDS Proxy Configuration
|
|
425
|
-
|
|
426
|
-
The generated infrastructure includes an RDS Proxy by default, which sits between your application and the Aurora cluster. RDS Proxy provides several benefits:
|
|
427
|
-
|
|
428
|
-
- **Connection pooling** - Maintains a pool of database connections that can be shared across application instances, reducing the overhead of establishing new connections
|
|
429
|
-
- **Connection resilience** - Automatically handles failovers and reconnects during Aurora instance replacements or maintenance
|
|
430
|
-
- **IAM authentication** - Supports IAM-based database authentication, eliminating the need to manage database credentials in your application code
|
|
431
|
-
- **Improved security** - Enforces TLS encryption for all connections
|
|
432
|
-
|
|
433
|
-
:::note[Additional Cost]
|
|
434
|
-
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.
|
|
435
|
-
:::
|
|
436
|
-
|
|
437
|
-
#### Disable RDS Proxy
|
|
438
|
-
|
|
439
|
-
You can disable the RDS proxy as follows:
|
|
440
|
-
|
|
441
|
-
<Infrastructure>
|
|
442
|
-
<Fragment slot="cdk">
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
446
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
447
|
-
|
|
448
|
-
const db = new MyDatabase(this, 'Db', {
|
|
449
|
-
...
|
|
450
|
-
enableRdsProxy: false,
|
|
451
|
-
});
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
When RDS Proxy is disabled, your application connects directly to the Aurora cluster endpoint.
|
|
455
|
-
</Fragment>
|
|
456
|
-
<Fragment slot="terraform">
|
|
457
|
-
|
|
458
|
-
By default, RDS Proxy is enabled. The generated runtime client (`getPrisma()`) automatically connects through the proxy endpoint. You can disable it if needed:
|
|
459
|
-
|
|
460
|
-
```hcl title="packages/infra/src/main.tf"
|
|
461
|
-
module "my_database" {
|
|
462
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
463
|
-
...
|
|
464
|
-
enable_rds_proxy = false
|
|
465
|
-
}
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
When RDS Proxy is disabled, your application connects directly to the Aurora cluster endpoint.
|
|
469
264
|
</Fragment>
|
|
470
265
|
</Infrastructure>
|
|
471
266
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
The generated infrastructure can be customised to match your workload requirements. The following examples demonstrate a few common customisation options available.
|
|
267
|
+
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.
|
|
475
268
|
|
|
476
269
|
### Cluster Instances
|
|
477
270
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
<Infrastructure>
|
|
481
|
-
<Fragment slot="cdk">
|
|
482
|
-
|
|
483
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
484
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
485
|
-
|
|
486
|
-
const db = new MyDatabase(this, 'Db', {
|
|
487
|
-
...
|
|
488
|
-
writer: ClusterInstance.serverlessV2('writer'),
|
|
489
|
-
readers: [ClusterInstance.serverlessV2('reader')],
|
|
490
|
-
});
|
|
491
|
-
```
|
|
492
|
-
</Fragment>
|
|
493
|
-
<Fragment slot="terraform">
|
|
494
|
-
|
|
495
|
-
```hcl title="packages/infra/src/main.tf"
|
|
496
|
-
module "my_database" {
|
|
497
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
498
|
-
...
|
|
499
|
-
instance_count = 2 # 1 writer + 1 reader
|
|
500
|
-
}
|
|
501
|
-
```
|
|
502
|
-
</Fragment>
|
|
503
|
-
</Infrastructure>
|
|
271
|
+
<Snippet name="rdb/cluster-instances" />
|
|
504
272
|
|
|
505
273
|
### Serverless Capacity
|
|
506
274
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
<Infrastructure>
|
|
510
|
-
<Fragment slot="cdk">
|
|
511
|
-
|
|
512
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
513
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
514
|
-
|
|
515
|
-
const db = new MyDatabase(this, 'Db', {
|
|
516
|
-
...
|
|
517
|
-
serverlessV2MinCapacity: 0.5,
|
|
518
|
-
serverlessV2MaxCapacity: 8,
|
|
519
|
-
});
|
|
520
|
-
```
|
|
521
|
-
</Fragment>
|
|
522
|
-
<Fragment slot="terraform">
|
|
523
|
-
|
|
524
|
-
```hcl title="packages/infra/src/main.tf"
|
|
525
|
-
module "my_database" {
|
|
526
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
527
|
-
...
|
|
528
|
-
serverless_min_capacity = 0.5
|
|
529
|
-
serverless_max_capacity = 8
|
|
530
|
-
}
|
|
531
|
-
```
|
|
532
|
-
</Fragment>
|
|
533
|
-
</Infrastructure>
|
|
275
|
+
<Snippet name="rdb/serverless-capacity" />
|
|
534
276
|
|
|
535
277
|
### Engine Version
|
|
536
278
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
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.
|
|
540
|
-
|
|
541
|
-
The local database image is configured in the `localDev.image` field of the generated `config.json` file in your database project root. Update that value when you change engine versions.
|
|
542
|
-
|
|
543
|
-
<OptionFilter when={{ engine: 'postgres' }}>
|
|
544
|
-
<Infrastructure>
|
|
545
|
-
<Fragment slot="cdk">
|
|
546
|
-
|
|
547
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
548
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
549
|
-
|
|
550
|
-
const db = new MyDatabase(this, 'Db', {
|
|
551
|
-
...
|
|
552
|
-
engineVersion: AuroraPostgresEngineVersion.VER_17_7,
|
|
553
|
-
});
|
|
554
|
-
```
|
|
555
|
-
</Fragment>
|
|
556
|
-
<Fragment slot="terraform">
|
|
557
|
-
|
|
558
|
-
```hcl title="packages/infra/src/main.tf"
|
|
559
|
-
module "my_database" {
|
|
560
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
561
|
-
...
|
|
562
|
-
engine_version = "17.7"
|
|
563
|
-
}
|
|
564
|
-
```
|
|
565
|
-
</Fragment>
|
|
566
|
-
</Infrastructure>
|
|
567
|
-
</OptionFilter>
|
|
568
|
-
|
|
569
|
-
<OptionFilter when={{ engine: 'mysql' }}>
|
|
570
|
-
<Infrastructure>
|
|
571
|
-
<Fragment slot="cdk">
|
|
572
|
-
|
|
573
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
574
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
575
|
-
|
|
576
|
-
const db = new MyDatabase(this, 'Db', {
|
|
577
|
-
...
|
|
578
|
-
engineVersion: AuroraMysqlEngineVersion.VER_3_12_0,
|
|
579
|
-
});
|
|
580
|
-
```
|
|
581
|
-
</Fragment>
|
|
582
|
-
<Fragment slot="terraform">
|
|
583
|
-
|
|
584
|
-
```hcl title="packages/infra/src/main.tf"
|
|
585
|
-
module "my_database" {
|
|
586
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
587
|
-
...
|
|
588
|
-
engine_version = "8.0.mysql_aurora.3.12.0"
|
|
589
|
-
}
|
|
590
|
-
```
|
|
591
|
-
</Fragment>
|
|
592
|
-
</Infrastructure>
|
|
593
|
-
</OptionFilter>
|
|
279
|
+
<Snippet name="rdb/engine-version" />
|
|
594
280
|
|
|
595
281
|
### Deletion Protection
|
|
596
282
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
#### Disable Deletion Protection
|
|
600
|
-
|
|
601
|
-
You can disable deletion protection for environments where database deletion is expected, such as short-lived development or preview stacks.
|
|
602
|
-
|
|
603
|
-
<Infrastructure>
|
|
604
|
-
<Fragment slot="cdk">
|
|
605
|
-
|
|
606
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
607
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
608
|
-
|
|
609
|
-
const db = new MyDatabase(this, 'Db', {
|
|
610
|
-
...
|
|
611
|
-
deletionProtection: false,
|
|
612
|
-
});
|
|
613
|
-
```
|
|
614
|
-
</Fragment>
|
|
615
|
-
<Fragment slot="terraform">
|
|
616
|
-
|
|
617
|
-
```hcl title="packages/infra/src/main.tf"
|
|
618
|
-
module "my_database" {
|
|
619
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
620
|
-
...
|
|
621
|
-
deletion_protection = false
|
|
622
|
-
}
|
|
623
|
-
```
|
|
624
|
-
</Fragment>
|
|
625
|
-
</Infrastructure>
|
|
283
|
+
<Snippet name="rdb/deletion-protection" />
|
|
626
284
|
|
|
627
285
|
### Removal Policy
|
|
628
286
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
When using `RemovalPolicy.DESTROY`, deletion protection must also be disabled before the cluster can be deleted.
|
|
632
|
-
|
|
633
|
-
<Infrastructure>
|
|
634
|
-
<Fragment slot="cdk">
|
|
635
|
-
|
|
636
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
637
|
-
import { RemovalPolicy } from 'aws-cdk-lib';
|
|
638
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
639
|
-
|
|
640
|
-
const db = new MyDatabase(this, 'Db', {
|
|
641
|
-
...
|
|
642
|
-
removalPolicy: RemovalPolicy.SNAPSHOT,
|
|
643
|
-
});
|
|
644
|
-
```
|
|
645
|
-
|
|
646
|
-
For an ephemeral environment where the database should be deleted with the stack:
|
|
647
|
-
|
|
648
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
649
|
-
import { RemovalPolicy } from 'aws-cdk-lib';
|
|
650
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
651
|
-
|
|
652
|
-
const db = new MyDatabase(this, 'Db', {
|
|
653
|
-
...
|
|
654
|
-
deletionProtection: false,
|
|
655
|
-
removalPolicy: RemovalPolicy.DESTROY,
|
|
656
|
-
});
|
|
657
|
-
```
|
|
658
|
-
</Fragment>
|
|
659
|
-
<Fragment slot="terraform">
|
|
660
|
-
|
|
661
|
-
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:
|
|
662
|
-
|
|
663
|
-
```hcl title="packages/infra/src/main.tf"
|
|
664
|
-
module "my_database" {
|
|
665
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
666
|
-
...
|
|
667
|
-
deletion_protection = false
|
|
668
|
-
skip_final_snapshot = true
|
|
669
|
-
}
|
|
670
|
-
```
|
|
671
|
-
</Fragment>
|
|
672
|
-
</Infrastructure>
|
|
287
|
+
<Snippet name="rdb/removal-policy" />
|
|
673
288
|
|
|
674
289
|
### Logging and Monitoring
|
|
675
290
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
<Infrastructure>
|
|
679
|
-
<Fragment slot="cdk">
|
|
680
|
-
|
|
681
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
682
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
683
|
-
|
|
684
|
-
const db = new MyDatabase(this, 'Db', {
|
|
685
|
-
...
|
|
686
|
-
enableCloudwatchLogs: true,
|
|
687
|
-
enablePerformanceInsights: false, // disable if not required
|
|
688
|
-
});
|
|
689
|
-
```
|
|
690
|
-
</Fragment>
|
|
691
|
-
<Fragment slot="terraform">
|
|
692
|
-
|
|
693
|
-
```hcl title="packages/infra/src/main.tf"
|
|
694
|
-
module "my_database" {
|
|
695
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
696
|
-
...
|
|
697
|
-
enable_cloudwatch_logs = true
|
|
698
|
-
enable_performance_insights = false # disable if not required
|
|
699
|
-
}
|
|
700
|
-
```
|
|
701
|
-
</Fragment>
|
|
702
|
-
</Infrastructure>
|
|
291
|
+
<Snippet name="rdb/logging" />
|
|
703
292
|
|
|
704
293
|
### Encryption Key Rotation
|
|
705
294
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
<Infrastructure>
|
|
709
|
-
<Fragment slot="cdk">
|
|
710
|
-
|
|
711
|
-
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
712
|
-
import { MyDatabase } from ':my-scope/common-constructs';
|
|
713
|
-
|
|
714
|
-
const db = new MyDatabase(this, 'Db', {
|
|
715
|
-
...
|
|
716
|
-
enableKeyRotation: false,
|
|
717
|
-
});
|
|
718
|
-
```
|
|
719
|
-
</Fragment>
|
|
720
|
-
<Fragment slot="terraform">
|
|
721
|
-
|
|
722
|
-
```hcl title="packages/infra/src/main.tf"
|
|
723
|
-
module "my_database" {
|
|
724
|
-
source = "../../common/terraform/src/app/dbs/my-database"
|
|
725
|
-
...
|
|
726
|
-
enable_key_rotation = false
|
|
727
|
-
}
|
|
728
|
-
```
|
|
729
|
-
</Fragment>
|
|
730
|
-
</Infrastructure>
|
|
295
|
+
<Snippet name="rdb/encryption-key-rotation" />
|
|
731
296
|
|
|
732
297
|
## Limitations
|
|
733
298
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: SSL Requirements when Connecting without RDS Proxy
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The Amazon Linux 2023 Lambda execution environment's built-in CA trust store includes the Amazon Root CAs used by RDS, so no additional configuration is needed.
|
|
6
|
+
|
|
7
|
+
When using RDS Proxy, you do not need to configure the RDS CA bundle in your Lambda function.
|