@aws/nx-plugin-mcp 1.0.0-rc.33 → 1.0.0-rc.35

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 (35) hide show
  1. package/bin/aws-nx-mcp.js +27 -0
  2. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  3. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  4. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  5. package/docs/guides/connection/smithy-rdb.mdx +1 -1
  6. package/docs/guides/connection/trpc-rdb.mdx +1 -1
  7. package/docs/guides/connection/ts-agent-rdb.mdx +63 -18
  8. package/docs/guides/connection/ts-mcp-server-rdb.mdx +63 -13
  9. package/docs/guides/connection.mdx +28 -1
  10. package/docs/guides/py-dynamodb.mdx +1 -1
  11. package/docs/guides/py-rdb.mdx +250 -0
  12. package/docs/guides/ts-rdb.mdx +48 -483
  13. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  14. package/docs/snippets/connection/rdb-api-infrastructure.mdx +50 -19
  15. package/docs/snippets/dynamodb/deploying-table.mdx +0 -5
  16. package/docs/snippets/rdb/architecture.mdx +38 -0
  17. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  18. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  19. package/docs/snippets/rdb/deploying.mdx +187 -0
  20. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  21. package/docs/snippets/rdb/engine-version.mdx +63 -0
  22. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  23. package/docs/snippets/rdb/logging.mdx +32 -0
  24. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  25. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  26. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  27. package/generators.json +27 -0
  28. package/package.json +1 -1
  29. package/src/py/rdb/agent-connection/schema.json +27 -0
  30. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  31. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  32. package/src/py/rdb/schema.json +77 -0
  33. package/src/ts/rdb/schema.json +1 -1
  34. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  35. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -2,6 +2,7 @@
2
2
  title: RDB API Infrastructure
3
3
  ---
4
4
  import Infrastructure from '@components/infrastructure.astro';
5
+ import Link from '@components/link.astro';
5
6
 
6
7
  To allow your API to connect to the database at runtime, the API Lambda functions must be deployed into the same VPC as the database and granted network and IAM access.
7
8
 
@@ -39,35 +40,65 @@ This example grants every handler in your API access, but if only some handlers
39
40
  </Fragment>
40
41
  <Fragment slot="terraform">
41
42
 
42
- Pass the database module outputs into your API module so it can reach the database and read its runtime configuration:
43
+ Deploy the API into the same VPC as the database, grant it `rds-db:connect` via `additional_iam_policy_statements`, and open the network path with a pair of security group rules. The `aws_vpc.main` and `aws_subnet` resources are defined in the database deployment guide:
43
44
 
44
45
  ```hcl title="packages/infra/src/main.tf"
45
46
  module "my_database" {
46
47
  source = "../../common/terraform/src/app/dbs/my-database"
47
- vpc_id = module.vpc.vpc_id
48
- database_subnet_ids = module.vpc.private_isolated_subnet_ids
49
- lambda_subnet_ids = module.vpc.private_subnet_ids
48
+ vpc_id = aws_vpc.main.id
49
+ database_subnet_ids = aws_subnet.database[*].id
50
+ lambda_subnet_ids = aws_subnet.private[*].id
50
51
  }
51
52
 
52
53
  module "api" {
53
- source = "..."
54
- enable_vpc = true
55
- vpc_id = module.vpc.vpc_id
56
- private_subnet_ids = module.vpc.private_subnet_ids
57
-
58
- appconfig_application_id = module.my_database.appconfig_application_id
59
- database_cluster_resource_id = module.my_database.cluster_resource_id
60
- database_runtime_user = module.my_database.database_runtime_user
61
- database_security_group_id = module.my_database.security_group_id
62
- database_port = module.my_database.cluster_port
63
-
64
- environment_variables = {
65
- RUNTIME_CONFIG_APP_ID = module.my_database.appconfig_application_id
66
- }
54
+ source = "../../common/terraform/src/app/apis/my-api"
55
+ enable_vpc = true
56
+ vpc_id = aws_vpc.main.id
57
+ subnet_ids = aws_subnet.private[*].id
58
+
59
+ appconfig_application_id = module.runtime_config_appconfig.application_id
60
+ appconfig_application_arn = module.runtime_config_appconfig.application_arn
61
+
62
+ additional_iam_policy_statements = [
63
+ {
64
+ Effect = "Allow"
65
+ Action = ["rds-db:connect"]
66
+ Resource = [
67
+ "arn:aws:rds-db:${data.aws_region.current.region}:${data.aws_caller_identity.current.account_id}:dbuser:${module.my_database.connect_resource_id}/${module.my_database.database_runtime_user}"
68
+ ]
69
+ }
70
+ ]
71
+ }
72
+
73
+ resource "aws_vpc_security_group_ingress_rule" "api_to_database" {
74
+ description = "Allow the API Lambda functions to connect to the database"
75
+ security_group_id = module.my_database.security_group_id
76
+ referenced_security_group_id = module.api.security_group_id
77
+ from_port = module.my_database.cluster_port
78
+ to_port = module.my_database.cluster_port
79
+ ip_protocol = "tcp"
80
+ }
81
+
82
+ resource "aws_vpc_security_group_egress_rule" "api_to_database" {
83
+ description = "Allow outbound traffic from the API Lambda functions to the database"
84
+ security_group_id = module.api.security_group_id
85
+ referenced_security_group_id = module.my_database.security_group_id
86
+ from_port = module.my_database.cluster_port
87
+ to_port = module.my_database.cluster_port
88
+ ip_protocol = "tcp"
67
89
  }
68
90
  ```
69
91
 
70
- Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. Ensure the API Lambda role has `rds-db:connect` permission and that its security group can reach the database security group on the database port.
92
+ Deploy the API Lambda functions into **private subnets with egress**, not private isolated subnets. `appconfig_application_id`/`appconfig_application_arn` come from the shared <Link path="guides/runtime-config">runtime configuration</Link> AppConfig application declared once in your root module, not from the database module — passing them sets `RUNTIME_CONFIG_APP_ID` on the Lambda functions and grants them read access to the application. Include the `database` namespace when instantiating it so the database module's runtime configuration entry is deployed:
93
+
94
+ ```hcl title="packages/infra/src/main.tf"
95
+ module "runtime_config_appconfig" {
96
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
97
+
98
+ application_name = "my-app-runtime-config"
99
+ namespaces = ["connection", "agentcore", "database"]
100
+ }
101
+ ```
71
102
 
72
103
  </Fragment>
73
104
  </Infrastructure>
@@ -2,7 +2,6 @@
2
2
  title: Deploying your DynamoDB Table
3
3
  ---
4
4
  import Infrastructure from '@components/infrastructure.astro';
5
- import Snippet from '@components/snippet.astro';
6
5
 
7
6
  The DynamoDB generator creates CDK or Terraform infrastructure based on your selected `iac`.
8
7
 
@@ -51,10 +50,6 @@ This provisions a DynamoDB table with:
51
50
  </Fragment>
52
51
  </Infrastructure>
53
52
 
54
- ### Granting Access
55
-
56
- <Snippet name="connection/lambda-dynamodb-access" />
57
-
58
53
  ### Deletion Protection
59
54
 
60
55
  Deletion protection is enabled by default to prevent accidental table deletion.
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: RDB Architecture
3
+ ---
4
+
5
+ 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.
6
+
7
+ ```d2 inline=true
8
+ direction: right
9
+
10
+ app: Application\n(Lambda, Agent, ...) {
11
+ shape: hexagon
12
+ }
13
+
14
+ proxy: RDS Proxy {
15
+ shape: image
16
+ icon: /nx-plugin-for-aws/icons/aws/rds.svg
17
+ }
18
+
19
+ migrations: Migrations Lambda {
20
+ shape: image
21
+ icon: /nx-plugin-for-aws/icons/aws/lambda.svg
22
+ }
23
+
24
+ aurora: Aurora\n(PostgreSQL or MySQL) {
25
+ shape: image
26
+ icon: /nx-plugin-for-aws/icons/aws/aurora.svg
27
+ }
28
+
29
+ secrets: Secrets Manager\n(DB credentials) {
30
+ shape: image
31
+ icon: /nx-plugin-for-aws/icons/aws/secrets-manager.svg
32
+ }
33
+
34
+ app -> proxy: SQL (IAM auth)
35
+ proxy -> aurora
36
+ migrations -> aurora: Schema migrations
37
+ migrations -> secrets: Admin credentials
38
+ ```
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Cluster Instances
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ Configure the writer and reader instances for your Aurora cluster.
7
+
8
+ <Infrastructure>
9
+ <Fragment slot="cdk">
10
+
11
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
12
+ import { MyDatabase } from ':my-scope/common-constructs';
13
+
14
+ const db = new MyDatabase(this, 'Db', {
15
+ ...
16
+ writer: ClusterInstance.serverlessV2('writer'),
17
+ readers: [ClusterInstance.serverlessV2('reader')],
18
+ });
19
+ ```
20
+ </Fragment>
21
+ <Fragment slot="terraform">
22
+
23
+ ```hcl title="packages/infra/src/main.tf"
24
+ module "my_database" {
25
+ source = "../../common/terraform/src/app/dbs/my-database"
26
+ ...
27
+ instance_count = 2 # 1 writer + 1 reader
28
+ }
29
+ ```
30
+ </Fragment>
31
+ </Infrastructure>
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Deletion Protection
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ Deletion protection is enabled by default (`deletionProtection: true` in CDK, `deletion_protection = true` in Terraform) to protect the Aurora cluster from accidental deletion.
7
+
8
+ #### Disable Deletion Protection
9
+
10
+ You can disable deletion protection for environments where database deletion is expected, such as short-lived development or preview stacks.
11
+
12
+ <Infrastructure>
13
+ <Fragment slot="cdk">
14
+
15
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
16
+ import { MyDatabase } from ':my-scope/common-constructs';
17
+
18
+ const db = new MyDatabase(this, 'Db', {
19
+ ...
20
+ deletionProtection: false,
21
+ });
22
+ ```
23
+ </Fragment>
24
+ <Fragment slot="terraform">
25
+
26
+ ```hcl title="packages/infra/src/main.tf"
27
+ module "my_database" {
28
+ source = "../../common/terraform/src/app/dbs/my-database"
29
+ ...
30
+ deletion_protection = false
31
+ }
32
+ ```
33
+ </Fragment>
34
+ </Infrastructure>
@@ -0,0 +1,187 @@
1
+ ---
2
+ title: Deploying your Relational Database
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+ import Link from '@components/link.astro';
6
+ import Drawer from '@components/drawer.astro';
7
+
8
+ The relational database generator creates CDK or Terraform infrastructure based on your selected `iacProvider`.
9
+
10
+ <Infrastructure>
11
+ <Fragment slot="cdk">
12
+ The CDK construct is created in `common/constructs`. Example usage:
13
+
14
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
15
+ import { MyDatabase } from ':my-scope/common-constructs';
16
+
17
+ export class ApplicationStack extends Stack {
18
+ constructor(scope: Construct, id: string, props?: StackProps) {
19
+ super(scope, id, props);
20
+ ...
21
+ const db = new MyDatabase(this, 'Db', {
22
+ vpc,
23
+ vpcSubnets: {
24
+ subnetType: SubnetType.PRIVATE_ISOLATED,
25
+ }
26
+ });
27
+ }
28
+ }
29
+ ```
30
+
31
+ This provisions an Aurora cluster with RDS Proxy, admin credentials, application database user, runtime config registration, and migration handler.
32
+
33
+ The generated infrastructure creates two database users:
34
+ - **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
35
+ - **Application user** - Created via a Lambda custom resource with IAM authentication enabled and DML privileges (SELECT, INSERT, UPDATE, DELETE) on the application database
36
+ </Fragment>
37
+ <Fragment slot="terraform">
38
+ The Terraform module is created in `common/terraform`. Example usage:
39
+
40
+ ```hcl title="packages/infra/src/main.tf"
41
+ module "my_database" {
42
+ source = "../../common/terraform/src/app/dbs/my-database"
43
+
44
+ # Database subnets have no internet route; Lambda subnets need NAT egress.
45
+ vpc_id = aws_vpc.main.id
46
+ database_subnet_ids = aws_subnet.database[*].id
47
+ lambda_subnet_ids = aws_subnet.private[*].id
48
+
49
+ tags = local.common_tags
50
+ }
51
+ ```
52
+
53
+ This provisions an Aurora cluster with RDS Proxy, admin credentials, create-db-user Lambda, runtime config registration, migration Lambda, and container registry resources.
54
+
55
+ The database module registers its connection details under the `database` runtime configuration namespace. Include this namespace when instantiating the shared runtime configuration AppConfig application:
56
+
57
+ ```hcl title="packages/infra/src/main.tf"
58
+ module "runtime_config_appconfig" {
59
+ source = "../../common/terraform/src/core/runtime-config/appconfig"
60
+
61
+ application_name = "my-app-runtime-config"
62
+ namespaces = ["connection", "agentcore", "database"]
63
+ }
64
+ ```
65
+
66
+ The generated infrastructure creates two database users:
67
+ - **Admin user** - Created during cluster provisioning with credentials stored in AWS Secrets Manager
68
+ - **Application user** - Created via a Lambda function with IAM authentication enabled and DML privileges (SELECT, INSERT, UPDATE, DELETE) on the application database
69
+ </Fragment>
70
+ </Infrastructure>
71
+
72
+ The application user is automatically created with a random name and IAM authentication. The generated database client is already configured to authenticate as this user using short-lived RDS tokens, so your application code never handles database passwords.
73
+
74
+ Your VPC should include public subnets, private subnets with egress, and private isolated subnets. The database can run in private isolated subnets, while application Lambda functions should run in private subnets with egress so they can reach AWS services such as AppConfig.
75
+
76
+ <Drawer title="Example VPC configuration" trigger="Click here for an example VPC configuration.">
77
+
78
+ <Infrastructure>
79
+ <Fragment slot="cdk">
80
+
81
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
82
+ const vpc = new Vpc(this, 'Vpc', {
83
+ subnetConfiguration: [
84
+ {
85
+ name: 'public',
86
+ subnetType: SubnetType.PUBLIC,
87
+ },
88
+ {
89
+ name: 'private_with_egress',
90
+ subnetType: SubnetType.PRIVATE_WITH_EGRESS,
91
+ },
92
+ {
93
+ name: 'private_isolated',
94
+ subnetType: SubnetType.PRIVATE_ISOLATED,
95
+ },
96
+ ],
97
+ });
98
+ ```
99
+
100
+ </Fragment>
101
+ <Fragment slot="terraform">
102
+
103
+ ```hcl title="packages/infra/src/main.tf"
104
+ data "aws_availability_zones" "available" {
105
+ state = "available"
106
+ }
107
+
108
+ resource "aws_vpc" "main" {
109
+ cidr_block = "10.0.0.0/16"
110
+ enable_dns_hostnames = true
111
+ enable_dns_support = true
112
+ }
113
+
114
+ # Isolated subnets for the database: no route to the internet
115
+ resource "aws_subnet" "database" {
116
+ count = 2
117
+ vpc_id = aws_vpc.main.id
118
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index)
119
+ availability_zone = data.aws_availability_zones.available.names[count.index]
120
+ }
121
+
122
+ # Private subnets with NAT egress for Lambda functions and runtimes,
123
+ # so they can reach AWS services such as AppConfig
124
+ resource "aws_subnet" "private" {
125
+ count = 2
126
+ vpc_id = aws_vpc.main.id
127
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 2)
128
+ availability_zone = data.aws_availability_zones.available.names[count.index]
129
+ }
130
+
131
+ # Public subnet hosting the NAT gateway
132
+ resource "aws_subnet" "public" {
133
+ vpc_id = aws_vpc.main.id
134
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, 4)
135
+ availability_zone = data.aws_availability_zones.available.names[0]
136
+ }
137
+
138
+ resource "aws_internet_gateway" "main" {
139
+ vpc_id = aws_vpc.main.id
140
+ }
141
+
142
+ resource "aws_route_table" "public" {
143
+ vpc_id = aws_vpc.main.id
144
+
145
+ route {
146
+ cidr_block = "0.0.0.0/0"
147
+ gateway_id = aws_internet_gateway.main.id
148
+ }
149
+ }
150
+
151
+ resource "aws_route_table_association" "public" {
152
+ subnet_id = aws_subnet.public.id
153
+ route_table_id = aws_route_table.public.id
154
+ }
155
+
156
+ resource "aws_eip" "nat" {
157
+ domain = "vpc"
158
+ }
159
+
160
+ resource "aws_nat_gateway" "main" {
161
+ allocation_id = aws_eip.nat.id
162
+ subnet_id = aws_subnet.public.id
163
+ depends_on = [aws_internet_gateway.main]
164
+ }
165
+
166
+ resource "aws_route_table" "private" {
167
+ vpc_id = aws_vpc.main.id
168
+
169
+ route {
170
+ cidr_block = "0.0.0.0/0"
171
+ nat_gateway_id = aws_nat_gateway.main.id
172
+ }
173
+ }
174
+
175
+ resource "aws_route_table_association" "private" {
176
+ count = 2
177
+ subnet_id = aws_subnet.private[count.index].id
178
+ route_table_id = aws_route_table.private.id
179
+ }
180
+ ```
181
+
182
+ </Fragment>
183
+ </Infrastructure>
184
+
185
+ </Drawer>
186
+
187
+ Use the <Link path="guides/connection">`connection`</Link> generator to connect a project to this database — see the connection guide for the relevant compute type (e.g. FastAPI, MCP server, agent) for the infrastructure wiring required to reach it.
@@ -0,0 +1,30 @@
1
+ ---
2
+ title: Encryption Key Rotation
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ 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.
7
+
8
+ <Infrastructure>
9
+ <Fragment slot="cdk">
10
+
11
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
12
+ import { MyDatabase } from ':my-scope/common-constructs';
13
+
14
+ const db = new MyDatabase(this, 'Db', {
15
+ ...
16
+ enableKeyRotation: false,
17
+ });
18
+ ```
19
+ </Fragment>
20
+ <Fragment slot="terraform">
21
+
22
+ ```hcl title="packages/infra/src/main.tf"
23
+ module "my_database" {
24
+ source = "../../common/terraform/src/app/dbs/my-database"
25
+ ...
26
+ enable_key_rotation = false
27
+ }
28
+ ```
29
+ </Fragment>
30
+ </Infrastructure>
@@ -0,0 +1,63 @@
1
+ ---
2
+ title: Engine Version
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+ import OptionFilter from '@components/option-filter.astro';
6
+
7
+ Pin a specific Aurora engine version.
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ <OptionFilter when={{ engine: 'postgres' }}>
14
+ <Infrastructure>
15
+ <Fragment slot="cdk">
16
+
17
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
18
+ import { MyDatabase } from ':my-scope/common-constructs';
19
+
20
+ const db = new MyDatabase(this, 'Db', {
21
+ ...
22
+ engineVersion: AuroraPostgresEngineVersion.VER_17_7,
23
+ });
24
+ ```
25
+ </Fragment>
26
+ <Fragment slot="terraform">
27
+
28
+ ```hcl title="packages/infra/src/main.tf"
29
+ module "my_database" {
30
+ source = "../../common/terraform/src/app/dbs/my-database"
31
+ ...
32
+ engine_version = "17.7"
33
+ }
34
+ ```
35
+ </Fragment>
36
+ </Infrastructure>
37
+ </OptionFilter>
38
+
39
+ <OptionFilter when={{ engine: 'mysql' }}>
40
+ <Infrastructure>
41
+ <Fragment slot="cdk">
42
+
43
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
44
+ import { MyDatabase } from ':my-scope/common-constructs';
45
+
46
+ const db = new MyDatabase(this, 'Db', {
47
+ ...
48
+ engineVersion: AuroraMysqlEngineVersion.VER_3_12_0,
49
+ });
50
+ ```
51
+ </Fragment>
52
+ <Fragment slot="terraform">
53
+
54
+ ```hcl title="packages/infra/src/main.tf"
55
+ module "my_database" {
56
+ source = "../../common/terraform/src/app/dbs/my-database"
57
+ ...
58
+ engine_version = "8.0.mysql_aurora.3.12.0"
59
+ }
60
+ ```
61
+ </Fragment>
62
+ </Infrastructure>
63
+ </OptionFilter>
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: RDB Infrastructure
3
+ ---
4
+ import { FileTree } from '@astrojs/starlight/components';
5
+ import Infrastructure from '@components/infrastructure.astro';
6
+ import Snippet from '@components/snippet.astro';
7
+
8
+ <Snippet name="shared-constructs" />
9
+
10
+ <Infrastructure>
11
+ <Fragment slot="cdk">
12
+ <FileTree>
13
+ - packages/common/constructs/src
14
+ - app
15
+ - dbs
16
+ - \<name>.ts Infrastructure specific to your database
17
+ - core
18
+ - rdb
19
+ - aurora.ts Generic Aurora database construct
20
+ </FileTree>
21
+ </Fragment>
22
+ <Fragment slot="terraform">
23
+ <FileTree>
24
+ - packages/common/terraform/src
25
+ - app
26
+ - dbs
27
+ - \<name>
28
+ - \<name>.tf Module specific to your database
29
+ - core
30
+ - rdb
31
+ - aurora
32
+ - aurora.tf Generic Aurora module
33
+ </FileTree>
34
+ </Fragment>
35
+ </Infrastructure>
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: Logging and Monitoring
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ Performance Insights is enabled on the Aurora writer instance by default (encrypted with the cluster's KMS key). You can also export the Aurora engine logs to [CloudWatch Logs](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_LogAccess.html) (`postgresql` for [Aurora PostgreSQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.CloudWatch.html); `audit`, `error`, `general` and `slowquery` for [Aurora MySQL](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraMySQL.Integrating.CloudWatch.html)). Enable log export per database:
7
+
8
+ <Infrastructure>
9
+ <Fragment slot="cdk">
10
+
11
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
12
+ import { MyDatabase } from ':my-scope/common-constructs';
13
+
14
+ const db = new MyDatabase(this, 'Db', {
15
+ ...
16
+ enableCloudwatchLogs: true,
17
+ enablePerformanceInsights: false, // disable if not required
18
+ });
19
+ ```
20
+ </Fragment>
21
+ <Fragment slot="terraform">
22
+
23
+ ```hcl title="packages/infra/src/main.tf"
24
+ module "my_database" {
25
+ source = "../../common/terraform/src/app/dbs/my-database"
26
+ ...
27
+ enable_cloudwatch_logs = true
28
+ enable_performance_insights = false # disable if not required
29
+ }
30
+ ```
31
+ </Fragment>
32
+ </Infrastructure>
@@ -0,0 +1,50 @@
1
+ ---
2
+ title: RDS Proxy Configuration
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ The generated infrastructure includes an [RDS Proxy](https://aws.amazon.com/rds/proxy/) by default, which sits between your application and the Aurora cluster. RDS Proxy provides several benefits:
7
+
8
+ - **Connection pooling** - Maintains a pool of database connections that can be shared across application instances, reducing the overhead of establishing new connections
9
+ - **Connection resilience** - Automatically handles failovers and reconnects during Aurora instance replacements or maintenance
10
+ - **IAM authentication** - Supports IAM-based database authentication, eliminating the need to manage database credentials in your application code
11
+ - **Improved security** - Enforces TLS encryption for all connections
12
+
13
+ :::note[Additional Cost]
14
+ 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.
15
+ :::
16
+
17
+ #### Disable RDS Proxy
18
+
19
+ You can disable the RDS proxy as follows:
20
+
21
+ <Infrastructure>
22
+ <Fragment slot="cdk">
23
+
24
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
25
+ import { MyDatabase } from ':my-scope/common-constructs';
26
+
27
+ const db = new MyDatabase(this, 'Db', {
28
+ ...
29
+ enableRdsProxy: false,
30
+ });
31
+ ```
32
+
33
+ When RDS Proxy is disabled, your application connects directly to the Aurora cluster endpoint.
34
+ </Fragment>
35
+ <Fragment slot="terraform">
36
+
37
+ By default, RDS Proxy is enabled. You can disable it if needed:
38
+
39
+ ```hcl title="packages/infra/src/main.tf"
40
+ module "my_database" {
41
+ source = "../../common/terraform/src/app/dbs/my-database"
42
+ ...
43
+ enable_rds_proxy = false
44
+ }
45
+ ```
46
+
47
+ When RDS Proxy is disabled, your application connects directly to the Aurora cluster endpoint.
48
+ </Fragment>
49
+ </Infrastructure>
50
+
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: Removal Policy
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ 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.
7
+
8
+ When using `RemovalPolicy.DESTROY`, deletion protection must also be disabled before the cluster can be deleted.
9
+
10
+ <Infrastructure>
11
+ <Fragment slot="cdk">
12
+
13
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
14
+ import { RemovalPolicy } from 'aws-cdk-lib';
15
+ import { MyDatabase } from ':my-scope/common-constructs';
16
+
17
+ const db = new MyDatabase(this, 'Db', {
18
+ ...
19
+ removalPolicy: RemovalPolicy.SNAPSHOT,
20
+ });
21
+ ```
22
+
23
+ For an ephemeral environment where the database should be deleted with the stack:
24
+
25
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
26
+ import { RemovalPolicy } from 'aws-cdk-lib';
27
+ import { MyDatabase } from ':my-scope/common-constructs';
28
+
29
+ const db = new MyDatabase(this, 'Db', {
30
+ ...
31
+ deletionProtection: false,
32
+ removalPolicy: RemovalPolicy.DESTROY,
33
+ });
34
+ ```
35
+
36
+ ::::caution[Data Loss]
37
+ `RemovalPolicy.DESTROY` will permanently erase all data when the stack is deleted. Use only in ephemeral environments (such as automated tests). Use `RETAIN` or `SNAPSHOT` for all persistent and production stacks to prevent data loss.
38
+ ::::
39
+ </Fragment>
40
+ <Fragment slot="terraform">
41
+
42
+ 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:
43
+
44
+ ```hcl title="packages/infra/src/main.tf"
45
+ module "my_database" {
46
+ source = "../../common/terraform/src/app/dbs/my-database"
47
+ ...
48
+ deletion_protection = false
49
+ skip_final_snapshot = true
50
+ }
51
+ ```
52
+
53
+ ::::caution[Data Loss]
54
+ `skip_final_snapshot = true` will permanently erase all data when the cluster is deleted. Use only in ephemeral environments (such as automated tests). Keep `skip_final_snapshot = false` for all persistent and production stacks to prevent data loss.
55
+ ::::
56
+ </Fragment>
57
+ </Infrastructure>