@aws/nx-plugin-mcp 1.0.0-rc.4 → 1.0.0-rc.41

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 (163) hide show
  1. package/bin/aws-nx-mcp.js +2240 -1030
  2. package/docs/get_started/building-with-ai.mdx +116 -0
  3. package/docs/get_started/concepts.mdx +52 -0
  4. package/docs/get_started/existing-project.mdx +176 -0
  5. package/docs/get_started/quick-start.mdx +266 -0
  6. package/docs/get_started/tutorials/contribute-generator.mdx +405 -0
  7. package/docs/get_started/tutorials/dungeon-game/1.mdx +1205 -0
  8. package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
  9. package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
  10. package/docs/get_started/tutorials/dungeon-game/4.mdx +162 -0
  11. package/docs/get_started/tutorials/dungeon-game/overview.mdx +144 -0
  12. package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
  13. package/docs/get_started/tutorials/existing-project.mdx +4 -0
  14. package/docs/guides/agentcore-gateway.mdx +376 -0
  15. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  16. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  17. package/docs/guides/connection/py-agent-a2a.mdx +47 -15
  18. package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
  19. package/docs/guides/connection/py-agent-gateway.mdx +176 -0
  20. package/docs/guides/connection/py-agent-mcp.mdx +42 -13
  21. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  22. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  23. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  24. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
  25. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  26. package/docs/guides/connection/react-agui.mdx +4 -4
  27. package/docs/guides/connection/react-fastapi.mdx +38 -2
  28. package/docs/guides/connection/react-py-agent.mdx +7 -13
  29. package/docs/guides/connection/react-smithy.mdx +3 -3
  30. package/docs/guides/connection/react-trpc.mdx +1 -1
  31. package/docs/guides/connection/react-ts-agent.mdx +8 -8
  32. package/docs/guides/connection/smithy-dynamodb.mdx +4 -4
  33. package/docs/guides/connection/smithy-rdb.mdx +5 -5
  34. package/docs/guides/connection/trpc-dynamodb.mdx +4 -4
  35. package/docs/guides/connection/trpc-rdb.mdx +5 -5
  36. package/docs/guides/connection/ts-agent-a2a.mdx +12 -9
  37. package/docs/guides/connection/ts-agent-dynamodb.mdx +3 -3
  38. package/docs/guides/connection/ts-agent-gateway.mdx +141 -0
  39. package/docs/guides/connection/ts-agent-mcp.mdx +11 -8
  40. package/docs/guides/connection/ts-agent-rdb.mdx +66 -21
  41. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +3 -3
  42. package/docs/guides/connection/ts-mcp-server-rdb.mdx +66 -16
  43. package/docs/guides/connection.mdx +104 -5
  44. package/docs/guides/docker-bundling.mdx +68 -8
  45. package/docs/guides/fastapi.mdx +244 -4
  46. package/docs/guides/license.mdx +264 -109
  47. package/docs/guides/local-development.mdx +87 -0
  48. package/docs/guides/nx-generator.mdx +7 -2
  49. package/docs/guides/py-agent.mdx +257 -49
  50. package/docs/guides/py-dynamodb.mdx +476 -0
  51. package/docs/guides/py-mcp-server.mdx +61 -2
  52. package/docs/guides/py-rdb.mdx +254 -0
  53. package/docs/guides/react-website-auth.mdx +58 -1
  54. package/docs/guides/react-website.mdx +130 -19
  55. package/docs/guides/security.mdx +75 -0
  56. package/docs/guides/terraform-project.mdx +1 -1
  57. package/docs/guides/trpc.mdx +45 -9
  58. package/docs/guides/ts-agent.mdx +149 -9
  59. package/docs/guides/ts-dynamodb.mdx +62 -239
  60. package/docs/guides/ts-mcp-server.mdx +66 -3
  61. package/docs/guides/ts-nx-plugin.mdx +1 -1
  62. package/docs/guides/ts-rdb.mdx +117 -470
  63. package/docs/guides/ts-smithy-api.mdx +183 -4
  64. package/docs/guides/typescript-infrastructure.mdx +9 -1
  65. package/docs/guides/typescript-project.mdx +5 -10
  66. package/docs/guides/workspace.mdx +2 -2
  67. package/docs/snippets/agent/architecture.mdx +1 -1
  68. package/docs/snippets/agent/bedrock-deployment.mdx +4 -0
  69. package/docs/snippets/agent/runtime-arn.mdx +21 -0
  70. package/docs/snippets/agent/securing-your-agent.mdx +39 -0
  71. package/docs/snippets/api/access-logging.mdx +33 -0
  72. package/docs/snippets/api/type-safe-api-integrations.mdx +31 -0
  73. package/docs/snippets/api/waf-configuration.mdx +1 -1
  74. package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
  75. package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
  76. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  77. package/docs/snippets/connection/rdb-api-infrastructure.mdx +50 -18
  78. package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
  79. package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
  80. package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
  81. package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
  82. package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
  83. package/docs/snippets/mcp/architecture.mdx +1 -1
  84. package/docs/snippets/mcp/bedrock-deployment.mdx +4 -0
  85. package/docs/snippets/mcp/config.mdx +3 -2
  86. package/docs/snippets/rdb/architecture.mdx +38 -0
  87. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  88. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  89. package/docs/snippets/rdb/deploying.mdx +187 -0
  90. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  91. package/docs/snippets/rdb/engine-version.mdx +63 -0
  92. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  93. package/docs/snippets/rdb/logging.mdx +32 -0
  94. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  95. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  96. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  97. package/docs/snippets/required-prerequisites.mdx +1 -1
  98. package/docs/snippets/trivy-image-scan.mdx +27 -0
  99. package/generators.json +101 -2
  100. package/package.json +1 -1
  101. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  102. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  103. package/src/agentcore-gateway/schema.json +70 -0
  104. package/src/connection/schema.json +5 -0
  105. package/src/infra/app/schema.json +5 -0
  106. package/src/init/schema.json +35 -0
  107. package/src/license/schema.json +11 -0
  108. package/src/preset/schema.json +11 -5
  109. package/src/py/agent/a2a-connection/schema.json +5 -0
  110. package/src/py/agent/gateway-connection/schema.json +31 -0
  111. package/src/py/agent/mcp-connection/schema.json +5 -0
  112. package/src/py/agent/react-connection/schema.json +5 -0
  113. package/src/py/agent/schema.json +6 -1
  114. package/src/py/api/schema.json +5 -0
  115. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  116. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  117. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  118. package/src/py/dynamodb/schema.json +75 -0
  119. package/src/py/fast-api/react/schema.json +5 -0
  120. package/src/py/fast-api/schema.json +5 -0
  121. package/src/py/lambda-function/schema.json +5 -0
  122. package/src/py/mcp-server/schema.json +5 -0
  123. package/src/py/project/schema.json +5 -0
  124. package/src/py/rdb/agent-connection/schema.json +27 -0
  125. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  126. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  127. package/src/py/rdb/schema.json +77 -0
  128. package/src/smithy/project/schema.json +5 -0
  129. package/src/smithy/react-connection/schema.json +5 -0
  130. package/src/smithy/ts/api/schema.json +5 -0
  131. package/src/terraform/project/schema.json +5 -0
  132. package/src/trpc/backend/schema.json +5 -0
  133. package/src/trpc/react/schema.json +5 -0
  134. package/src/ts/agent/a2a-connection/schema.json +5 -0
  135. package/src/ts/agent/gateway-connection/schema.json +31 -0
  136. package/src/ts/agent/mcp-connection/schema.json +5 -0
  137. package/src/ts/agent/react-connection/schema.json +5 -0
  138. package/src/ts/agent/schema.json +5 -0
  139. package/src/ts/api/schema.json +5 -0
  140. package/src/ts/astro-docs/schema.json +3 -3
  141. package/src/ts/docs/schema.json +3 -3
  142. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  143. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  144. package/src/ts/dynamodb/schema.json +25 -2
  145. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  146. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  147. package/src/ts/lambda-function/schema.json +5 -0
  148. package/src/ts/lib/schema.json +5 -0
  149. package/src/ts/mcp-server/schema.json +5 -0
  150. package/src/ts/nx-generator/schema.json +5 -0
  151. package/src/ts/nx-plugin/schema.json +5 -0
  152. package/src/ts/rdb/agent-connection/schema.json +5 -0
  153. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  154. package/src/ts/rdb/schema.json +6 -1
  155. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  156. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  157. package/src/ts/react-website/app/schema.json +11 -6
  158. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  159. package/src/ts/react-website/runtime-config/schema.json +5 -0
  160. package/src/ts/website/app/schema.json +11 -6
  161. package/src/ts/website/auth/schema.json +5 -0
  162. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  163. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -0,0 +1,166 @@
1
+ ---
2
+ title: Deploying your DynamoDB Table
3
+ ---
4
+ import Infrastructure from '@components/infrastructure.astro';
5
+
6
+ The DynamoDB generator creates CDK or Terraform infrastructure based on your selected `iac`.
7
+
8
+ <Infrastructure>
9
+ <Fragment slot="cdk">
10
+ The CDK construct is created in `common/constructs`. Example usage:
11
+
12
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
13
+ import { MyTable } from ':my-scope/common-constructs';
14
+
15
+ export class ApplicationStack extends Stack {
16
+ constructor(scope: Construct, id: string, props?: StackProps) {
17
+ super(scope, id, props);
18
+
19
+ const table = new MyTable(this, 'Table');
20
+ }
21
+ }
22
+ ```
23
+
24
+ This provisions a DynamoDB table with:
25
+ - `pk` (partition key) and `sk` (sort key), both `String` type
26
+ - Global Secondary Indexes as defined in `config.json`
27
+ - On-demand (`PAY_PER_REQUEST`) billing
28
+ - Customer-managed KMS encryption with automatic key rotation
29
+ - Point-in-time recovery enabled
30
+ - Deletion protection enabled
31
+ - Table name registered in Runtime Config under the `dynamodb` namespace in AWS AppConfig
32
+ </Fragment>
33
+ <Fragment slot="terraform">
34
+ The Terraform module is created in `common/terraform`. Example usage:
35
+
36
+ ```hcl title="packages/infra/src/main.tf"
37
+ module "my_table" {
38
+ source = "../../common/terraform/src/app/dynamodb/my-table"
39
+ }
40
+ ```
41
+
42
+ This provisions a DynamoDB table with:
43
+ - `pk` (partition key) and `sk` (sort key), both `String` type
44
+ - Global Secondary Indexes as defined in `config.json`
45
+ - On-demand (`PAY_PER_REQUEST`) billing
46
+ - Customer-managed KMS encryption with automatic key rotation
47
+ - Point-in-time recovery enabled
48
+ - Deletion protection enabled
49
+ - Table name registered in Runtime Config
50
+ </Fragment>
51
+ </Infrastructure>
52
+
53
+ ### Deletion Protection
54
+
55
+ Deletion protection is enabled by default to prevent accidental table deletion.
56
+
57
+ #### Disable Deletion Protection
58
+
59
+ Disable it for environments where table deletion is expected, such as short-lived development or preview stacks.
60
+
61
+ <Infrastructure>
62
+ <Fragment slot="cdk">
63
+
64
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
65
+ import { MyTable } from ':my-scope/common-constructs';
66
+
67
+ const table = new MyTable(this, 'Table', {
68
+ deletionProtection: false,
69
+ });
70
+ ```
71
+ </Fragment>
72
+ <Fragment slot="terraform">
73
+
74
+ ```hcl title="packages/infra/src/main.tf"
75
+ module "my_table" {
76
+ source = "../../common/terraform/src/app/dynamodb/my-table"
77
+ deletion_protection_enabled = false
78
+ }
79
+ ```
80
+ </Fragment>
81
+ </Infrastructure>
82
+
83
+ ### Billing Mode
84
+
85
+ The table defaults to on-demand (`PAY_PER_REQUEST`) billing. Switch to provisioned capacity for predictable, high-throughput workloads.
86
+
87
+ <Infrastructure>
88
+ <Fragment slot="cdk">
89
+
90
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
91
+ import { BillingMode } from 'aws-cdk-lib/aws-dynamodb';
92
+ import { MyTable } from ':my-scope/common-constructs';
93
+
94
+ const table = new MyTable(this, 'Table', {
95
+ billingMode: BillingMode.PROVISIONED,
96
+ readCapacity: 5,
97
+ writeCapacity: 5,
98
+ });
99
+ ```
100
+ </Fragment>
101
+ <Fragment slot="terraform">
102
+
103
+ ```hcl title="packages/infra/src/main.tf"
104
+ module "my_table" {
105
+ source = "../../common/terraform/src/app/dynamodb/my-table"
106
+ billing_mode = "PROVISIONED"
107
+ }
108
+ ```
109
+ </Fragment>
110
+ </Infrastructure>
111
+
112
+ ### Point-in-time Recovery
113
+
114
+ [Point-in-time recovery](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Point-in-time-recovery.html) is enabled by default, allowing you to restore the table to any point in the last 35 days.
115
+
116
+ #### Disable Point-in-time Recovery
117
+
118
+ <Infrastructure>
119
+ <Fragment slot="cdk">
120
+
121
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
122
+ import { MyTable } from ':my-scope/common-constructs';
123
+
124
+ const table = new MyTable(this, 'Table', {
125
+ pointInTimeRecoverySpecification: { pointInTimeRecoveryEnabled: false },
126
+ });
127
+ ```
128
+ </Fragment>
129
+ <Fragment slot="terraform">
130
+
131
+ ```hcl title="packages/infra/src/main.tf"
132
+ module "my_table" {
133
+ source = "../../common/terraform/src/app/dynamodb/my-table"
134
+ point_in_time_recovery_enabled = false
135
+ }
136
+ ```
137
+ </Fragment>
138
+ </Infrastructure>
139
+
140
+ ### Encryption Key Rotation
141
+
142
+ The KMS key used to encrypt the table has automatic key rotation enabled by default. Disable it if your security policy manages rotation externally.
143
+
144
+ #### Disable Encryption Key Rotation
145
+
146
+ <Infrastructure>
147
+ <Fragment slot="cdk">
148
+
149
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
150
+ import { MyTable } from ':my-scope/common-constructs';
151
+
152
+ const table = new MyTable(this, 'Table', {
153
+ enableKeyRotation: false,
154
+ });
155
+ ```
156
+ </Fragment>
157
+ <Fragment slot="terraform">
158
+
159
+ ```hcl title="packages/infra/src/main.tf"
160
+ module "my_table" {
161
+ source = "../../common/terraform/src/app/dynamodb/my-table"
162
+ enable_key_rotation = false
163
+ }
164
+ ```
165
+ </Fragment>
166
+ </Infrastructure>
@@ -0,0 +1,38 @@
1
+ ---
2
+ title: GSI Configuration
3
+ ---
4
+
5
+ ```json title="config.json"
6
+ {
7
+ ...
8
+ "tableConfig": {
9
+ "globalSecondaryIndexes": [
10
+ {
11
+ "indexName": "gsi1pk-gsi1sk-index",
12
+ "partitionKey": "gsi1pk",
13
+ "sortKey": "gsi1sk"
14
+ },
15
+ {
16
+ "indexName": "gsi2pk-gsi2sk-index",
17
+ "partitionKey": "gsi2pk",
18
+ "sortKey": "gsi2sk"
19
+ }
20
+ ]
21
+ }
22
+ }
23
+ ```
24
+
25
+ The `sortKey` field is optional for hash-key-only GSIs.
26
+
27
+ This config file is the single source of truth read by all consumers:
28
+ - **Local development** — `dev` reads `config.json` and creates or updates the local table to match the GSI list
29
+ - **CDK** — the construct reads `config.json` at synth time, so GSI changes are reflected on the next `cdk deploy`
30
+ - **Terraform** — the module reads `config.json` at plan/apply time
31
+
32
+ ### One GSI per Deployment
33
+
34
+ :::caution
35
+ DynamoDB [does not allow more than one GSI to be created or deleted in a single table update](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html).
36
+
37
+ Each deployment can add or remove **at most one GSI**. If you need to add or remove multiple GSIs, do so one at a time — update `config.json` and relevant entity classes, deploy the stack, then repeat for the next change.
38
+ :::
@@ -0,0 +1,33 @@
1
+ ---
2
+ title: DynamoDB 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
+ - dynamodb
16
+ - \<name>.ts Infrastructure specific to your table
17
+ - core
18
+ - dynamodb.ts Generic DynamoDB table construct
19
+ </FileTree>
20
+ </Fragment>
21
+ <Fragment slot="terraform">
22
+ <FileTree>
23
+ - packages/common/terraform/src
24
+ - app
25
+ - dynamodb
26
+ - \<name>
27
+ - \<name>.tf Module specific to your table
28
+ - core
29
+ - dynamodb
30
+ - dynamodb.tf Generic DynamoDB module
31
+ </FileTree>
32
+ </Fragment>
33
+ </Infrastructure>
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: Starting Local DynamoDB
3
+ ---
4
+ import NxCommands from '@components/nx-commands.astro';
5
+
6
+ The generator configures a `dev` target that starts a [DynamoDB Local](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html) instance and creates the table. Use the project's `dev` target:
7
+
8
+ <NxCommands commands={['dev <project-name>']} />
9
+
10
+ This automatically:
11
+ 1. Pulls the DynamoDB Local image (`pull-image` target)
12
+ 2. Starts a container
13
+ 3. Creates a local table with the indexes defined in `config.json`
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Local Development Windows Caution
3
+ ---
4
+
5
+ Stopping `dev` (e.g. with `Ctrl+C`) automatically removes the DynamoDB Local container, but preserves the named volume so your data persists across restarts.
6
+
7
+ :::caution[Windows]
8
+ 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:
9
+
10
+ ```bash
11
+ <engine> rm -f <scope>-dynamodb
12
+ ```
13
+
14
+ Replace `<engine>` with your container engine (`docker` or `finch`) and `<scope>` with your Nx workspace scope (e.g. `proj`).
15
+ :::
@@ -23,7 +23,7 @@ ecr: ECR {
23
23
 
24
24
  agentcore: MCP Server\n(AgentCore Runtime) {
25
25
  shape: image
26
- icon: /nx-plugin-for-aws/icons/aws/bedrock-agentcore.svg
26
+ icon: /nx-plugin-for-aws/icons/aws/bedrock-agentcore-runtime.svg
27
27
  }
28
28
 
29
29
  cw: CloudWatch\n(Logs, Metrics) {
@@ -164,4 +164,8 @@ module "my_project_mcp_server" {
164
164
 
165
165
  :::note[Custom OIDC Providers]
166
166
  If you require custom JWT authentication with a non-Cognito OIDC provider, you can modify the generated CDK construct or Terraform module for your MCP server directly. Note that the connection generator will only support `IAM` or `Cognito` authentication.
167
+ :::
168
+
169
+ :::caution[Security Best Practices]
170
+ When implementing your MCP server's business logic, review the [Bedrock AgentCore Runtime security best practices](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-security-best-practices.html).
167
171
  :::
@@ -1,13 +1,14 @@
1
1
  ---
2
2
  title: MCP Server Configuration
3
3
  ---
4
+
4
5
  ```json {3-6}
5
6
  {
6
7
  "mcpServers": {
7
8
  "nx-plugin-for-aws": {
8
9
  "command": "npx",
9
- "args": ["-y", "@aws/nx-plugin-mcp@next"]
10
+ "args": ["-y", "@aws/nx-plugin-mcp"]
10
11
  }
11
12
  }
12
13
  }
13
- ```
14
+ ```
@@ -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>