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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/bin/aws-nx-mcp.js +12317 -10933
  2. package/docs/get_started/building-with-ai.mdx +116 -0
  3. package/docs/get_started/concepts.mdx +67 -0
  4. package/docs/get_started/existing-project.mdx +180 -0
  5. package/docs/get_started/graph-builder.mdx +39 -0
  6. package/docs/get_started/quick-start.mdx +277 -0
  7. package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
  8. package/docs/get_started/tutorials/dungeon-game/1.mdx +1301 -0
  9. package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
  10. package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
  11. package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
  12. package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
  13. package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
  14. package/docs/get_started/tutorials/existing-project.mdx +4 -0
  15. package/docs/get_started/upgrading.mdx +147 -0
  16. package/docs/guides/agentcore-gateway.mdx +490 -0
  17. package/docs/guides/agentcore-harness.mdx +275 -0
  18. package/docs/guides/astro-docs.mdx +8 -0
  19. package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
  20. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  21. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  22. package/docs/guides/connection/py-agent-a2a.mdx +48 -16
  23. package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
  24. package/docs/guides/connection/py-agent-gateway.mdx +178 -0
  25. package/docs/guides/connection/py-agent-mcp.mdx +43 -14
  26. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  27. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  28. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  29. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
  30. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  31. package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
  32. package/docs/guides/connection/react-agui.mdx +13 -13
  33. package/docs/guides/connection/react-fastapi.mdx +38 -2
  34. package/docs/guides/connection/react-py-agent.mdx +9 -15
  35. package/docs/guides/connection/react-smithy.mdx +3 -3
  36. package/docs/guides/connection/react-trpc.mdx +1 -1
  37. package/docs/guides/connection/react-ts-agent.mdx +8 -8
  38. package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
  39. package/docs/guides/connection/smithy-rdb.mdx +9 -9
  40. package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
  41. package/docs/guides/connection/trpc-rdb.mdx +6 -6
  42. package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
  43. package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
  44. package/docs/guides/connection/ts-agent-gateway.mdx +143 -0
  45. package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
  46. package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
  47. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
  48. package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
  49. package/docs/guides/connection.mdx +122 -5
  50. package/docs/guides/docker-bundling.mdx +69 -12
  51. package/docs/guides/fastapi.mdx +249 -9
  52. package/docs/guides/local-development.mdx +87 -0
  53. package/docs/guides/nx-generator.mdx +4 -3
  54. package/docs/guides/nx-migration.mdx +165 -0
  55. package/docs/guides/py-agent.mdx +264 -49
  56. package/docs/guides/py-dynamodb.mdx +476 -0
  57. package/docs/guides/py-mcp-server.mdx +61 -2
  58. package/docs/guides/py-rdb.mdx +265 -0
  59. package/docs/guides/python-lambda-function.mdx +1 -1
  60. package/docs/guides/react-website-auth.mdx +65 -4
  61. package/docs/guides/react-website.mdx +149 -30
  62. package/docs/guides/runtime-config.mdx +1 -1
  63. package/docs/guides/security.mdx +75 -0
  64. package/docs/guides/smithy-project.mdx +167 -0
  65. package/docs/guides/terraform-project.mdx +2 -2
  66. package/docs/guides/trpc.mdx +53 -16
  67. package/docs/guides/ts-agent.mdx +183 -10
  68. package/docs/guides/ts-dcr-proxy.mdx +569 -0
  69. package/docs/guides/ts-dynamodb.mdx +66 -242
  70. package/docs/guides/ts-lambda-function.mdx +1 -1
  71. package/docs/guides/ts-mcp-server.mdx +109 -29
  72. package/docs/guides/ts-nx-plugin.mdx +3 -3
  73. package/docs/guides/ts-rdb.mdx +113 -467
  74. package/docs/guides/ts-smithy-api.mdx +258 -18
  75. package/docs/guides/typescript-infrastructure.mdx +46 -24
  76. package/docs/guides/typescript-project.mdx +134 -27
  77. package/docs/guides/workspace.mdx +10 -3
  78. package/docs/snippets/agent/architecture.mdx +1 -1
  79. package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
  80. package/docs/snippets/agent/runtime-arn.mdx +23 -2
  81. package/docs/snippets/agent/securing-your-agent.mdx +39 -0
  82. package/docs/snippets/api/access-logging.mdx +33 -0
  83. package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
  84. package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
  85. package/docs/snippets/api/type-safe-api-integrations.mdx +33 -2
  86. package/docs/snippets/api/waf-configuration.mdx +3 -3
  87. package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
  88. package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
  89. package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
  90. package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
  91. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  92. package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
  93. package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
  94. package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
  95. package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
  96. package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
  97. package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
  98. package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
  99. package/docs/snippets/mcp/architecture.mdx +1 -1
  100. package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
  101. package/docs/snippets/mcp/config.mdx +3 -2
  102. package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
  103. package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
  104. package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
  105. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
  106. package/docs/snippets/prerequisites.mdx +1 -4
  107. package/docs/snippets/rdb/architecture.mdx +38 -0
  108. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  109. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  110. package/docs/snippets/rdb/deploying.mdx +187 -0
  111. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  112. package/docs/snippets/rdb/engine-version.mdx +63 -0
  113. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  114. package/docs/snippets/rdb/logging-mysql.mdx +5 -0
  115. package/docs/snippets/rdb/logging-postgres.mdx +5 -0
  116. package/docs/snippets/rdb/performance-insights.mdx +34 -0
  117. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  118. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  119. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  120. package/docs/snippets/recommended-prerequisites.mdx +10 -0
  121. package/docs/snippets/required-prerequisites.mdx +1 -4
  122. package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
  123. package/docs/snippets/shared-constructs.mdx +1 -1
  124. package/docs/snippets/trivy-image-scan.mdx +37 -0
  125. package/generators.json +152 -10
  126. package/package.json +1 -1
  127. package/src/agentcore-gateway/agent-connection/schema.json +31 -0
  128. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  129. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  130. package/src/agentcore-gateway/react-connection/schema.json +31 -0
  131. package/src/agentcore-gateway/schema.json +72 -0
  132. package/src/agentcore-harness/schema.json +53 -0
  133. package/src/connection/schema.json +5 -0
  134. package/src/infra/app/schema.json +5 -0
  135. package/src/init/schema.json +35 -0
  136. package/src/internal/test-matrix/schema.json +21 -0
  137. package/src/license/schema.json +5 -0
  138. package/src/preset/schema.json +16 -5
  139. package/src/py/agent/a2a-connection/schema.json +5 -0
  140. package/src/py/agent/gateway-connection/schema.json +31 -0
  141. package/src/py/agent/mcp-connection/schema.json +5 -0
  142. package/src/py/agent/react-connection/schema.json +5 -0
  143. package/src/py/agent/schema.json +15 -1
  144. package/src/py/api/schema.json +5 -0
  145. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  146. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  147. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  148. package/src/py/dynamodb/schema.json +76 -0
  149. package/src/py/fast-api/react/schema.json +5 -0
  150. package/src/py/fast-api/schema.json +6 -0
  151. package/src/py/lambda-function/schema.json +5 -0
  152. package/src/py/mcp-server/schema.json +6 -0
  153. package/src/py/project/schema.json +5 -0
  154. package/src/py/rdb/agent-connection/schema.json +27 -0
  155. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  156. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  157. package/src/py/rdb/schema.json +78 -0
  158. package/src/smithy/project/schema.json +28 -1
  159. package/src/smithy/react-connection/schema.json +5 -0
  160. package/src/smithy/ts/api/schema.json +6 -0
  161. package/src/terraform/project/schema.json +5 -0
  162. package/src/trpc/backend/schema.json +6 -0
  163. package/src/trpc/react/schema.json +5 -0
  164. package/src/ts/agent/a2a-connection/schema.json +5 -0
  165. package/src/ts/agent/gateway-connection/schema.json +31 -0
  166. package/src/ts/agent/mcp-connection/schema.json +5 -0
  167. package/src/ts/agent/react-connection/schema.json +5 -0
  168. package/src/ts/agent/schema.json +14 -0
  169. package/src/ts/api/schema.json +5 -0
  170. package/src/ts/astro-docs/schema.json +3 -3
  171. package/src/ts/dcr-proxy/schema.json +44 -0
  172. package/src/ts/docs/schema.json +3 -3
  173. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  174. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  175. package/src/ts/dynamodb/schema.json +26 -2
  176. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  177. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  178. package/src/ts/lambda-function/schema.json +5 -0
  179. package/src/ts/lib/schema.json +5 -0
  180. package/src/ts/mcp-server/schema.json +6 -0
  181. package/src/ts/nx-generator/schema.json +5 -0
  182. package/src/ts/nx-migration/schema.json +63 -0
  183. package/src/ts/nx-plugin/schema.json +5 -0
  184. package/src/ts/rdb/agent-connection/schema.json +5 -0
  185. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  186. package/src/ts/rdb/schema.json +7 -1
  187. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  188. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  189. package/src/ts/react-website/app/schema.json +12 -6
  190. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  191. package/src/ts/react-website/runtime-config/schema.json +5 -0
  192. package/src/ts/website/app/schema.json +11 -6
  193. package/src/ts/website/auth/schema.json +5 -0
  194. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  195. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -0,0 +1,265 @@
1
+ ---
2
+ title: Python Relational Database
3
+ description: Create a Python relational database project
4
+ generator: py#rdb
5
+ ---
6
+
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';
11
+ import Link from '@components/link.astro';
12
+ import RunGenerator from '@components/run-generator.astro';
13
+ import GeneratorParameters from '@components/generator-parameters.astro';
14
+ import NxCommands from '@components/nx-commands.astro';
15
+ import Snippet from '@components/snippet.astro';
16
+ import OptionFilter from '@components/option-filter.astro';
17
+
18
+ This generator creates a new Python relational database project backed by [Amazon Aurora](https://aws.amazon.com/rds/aurora/) (PostgreSQL or MySQL), [SQLModel](https://sqlmodel.tiangolo.com/) for data modelling, and [Alembic](https://alembic.sqlalchemy.org/) for schema migrations. It generates the application code and infrastructure needed to provision and manage a database using AWS CDK or Terraform, with declarative schema definition, automatic migration deployment, and a database client.
19
+
20
+ ## Usage
21
+
22
+ ### Generate a Relational Database
23
+
24
+ <RunGenerator generator="py#rdb" />
25
+
26
+ ### Options
27
+
28
+ <GeneratorParameters generator="py#rdb" />
29
+
30
+ ## Generator Output
31
+
32
+ The generator creates the following project structure in the `<directory>/<name>` directory:
33
+
34
+ <FileTree>
35
+ - \<name>
36
+ - \_\_init\_\_.py Package exports (`get_engine`, `session_context`)
37
+ - connection.py Database engine and session factory with IAM authentication
38
+ - utils.py Runtime config and local development helpers
39
+ - migration_handler.py Lambda handler that runs Alembic migrations during deployment
40
+ - create_db_user_handler.py Lambda handler that creates the application database user during deployment
41
+ - models
42
+ - example.py Example SQLModel table definition
43
+ - migrations
44
+ - versions Alembic-generated migration scripts
45
+ - env.py Alembic environment (connects to the database)
46
+ - script.py.mako Alembic migration script template
47
+ - alembic.ini Alembic configuration
48
+ - config.json Local development connection details and runtime config key
49
+ - Dockerfile.migration Container image for the migration handler
50
+ - Dockerfile.create-db-user Container image for the create-db-user handler
51
+ - project.json Project configuration and build targets
52
+ </FileTree>
53
+
54
+ Local development scripts are shared across all database projects and generated into `packages/common/scripts/`:
55
+
56
+ <FileTree>
57
+ - packages/common/scripts/src/rdb
58
+ - pull-image.ts Pulls the database container image
59
+ - start-container.ts Starts a local database container
60
+ - wait-for-postgres-db.ts Waits for the local database to be ready (PostgreSQL)
61
+ - wait-for-mysql-db.ts Waits for the local database to be ready (MySQL)
62
+ </FileTree>
63
+
64
+ ### Infrastructure
65
+
66
+ <Snippet name="rdb/infrastructure" />
67
+
68
+ #### Architecture
69
+
70
+ <Snippet name="rdb/architecture" />
71
+
72
+ ## Local Development
73
+
74
+ ### Data Modelling
75
+
76
+ The generated project uses [SQLModel](https://sqlmodel.tiangolo.com/) to define your database schema. The workflow is model-first: add or update SQLModel table classes under your database project's `<name>/models/` directory, then generate a migration from those model changes.
77
+
78
+ Example model:
79
+
80
+ ```python title="packages/my_db/my_db/models/example.py"
81
+ from sqlalchemy import Column, String
82
+ from sqlmodel import Field, SQLModel
83
+
84
+
85
+ class ExampleModel(SQLModel, table=True):
86
+ id: int | None = Field(default=None, primary_key=True)
87
+ name: str = Field(sa_column=Column(String(255), nullable=False))
88
+ description: str | None = Field(default=None, sa_column=Column(String(255), nullable=True))
89
+ ```
90
+
91
+ Import your models in `<name>/models/__init__.py` so Alembic can discover them during autogeneration.
92
+
93
+ ### Creating Migrations
94
+
95
+ After adding or updating models, use Alembic to generate and apply migration scripts. The generated `alembic` target automatically starts a local database container before running:
96
+
97
+ <NxCommands commands={['run <project>:alembic revision --autogenerate -m "describe your change"']} />
98
+
99
+ This generates a new migration script under `migrations/versions/`. Review the generated script before applying it.
100
+
101
+ Apply the migration to your local database:
102
+
103
+ <NxCommands commands={['run <project>:migrate']} />
104
+
105
+ When you deploy the AWS stack, the generated infrastructure automatically applies the generated migrations to the deployed database.
106
+
107
+ ### Applying Existing Migrations
108
+
109
+ When you pull migration files created by other developers, apply them to your local database:
110
+
111
+ <NxCommands commands={['run <project>:migrate']} />
112
+
113
+ ### Running Alembic Commands
114
+
115
+ The generated `alembic` target exposes the Alembic CLI, so you can run any Alembic command against the local database. See the [Alembic command reference](https://alembic.sqlalchemy.org/en/latest/ops.html) for available commands.
116
+
117
+ <NxCommands commands={['run <project>:alembic <alembic-command>']} />
118
+
119
+ ### Stopping the Local Database
120
+
121
+ Stopping `dev` (e.g. with `Ctrl+C`) automatically removes the local database container, but preserves the named volume so your data persists across restarts.
122
+
123
+ :::caution[Windows]
124
+ 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:
125
+
126
+ ```bash
127
+ <engine> rm -f <scope>-<db-name>
128
+ ```
129
+
130
+ Replace `<engine>` with your container engine (`docker` or `finch`), `<scope>` with your Nx workspace scope (e.g. `proj`), and `<db-name>` with your database project name (e.g. `my-db`).
131
+ :::
132
+
133
+ ## Connecting to the Database
134
+
135
+ Import `session_context` from your database package and use it as an async context manager to obtain an `AsyncSession`:
136
+
137
+ ```python
138
+ from sqlmodel import select
139
+
140
+ from my_scope.my_db import session_context
141
+ from my_scope.my_db.models.example import ExampleModel
142
+
143
+ async def example():
144
+ async with session_context() as session:
145
+ results = (await session.execute(select(ExampleModel))).all()
146
+ ```
147
+
148
+ The database client automatically:
149
+ - Retrieves database configuration from AWS AppConfig at runtime
150
+ - Generates temporary authentication tokens via `boto3` RDS Signer for IAM authentication
151
+ - Establishes TLS connections using `ssl.create_default_context()`
152
+
153
+ <Snippet name="runtime-config-app-id-note" parentHeading="Connecting to the Database" />
154
+
155
+ ## Deploying your Database
156
+
157
+ <Snippet name="rdb/deploying" parentHeading="Deploying your Database" />
158
+
159
+ ### Image Scanning
160
+
161
+ <Snippet name="trivy-image-scan" parentHeading="Image Scanning" />
162
+
163
+ ### RDS Proxy Configuration
164
+
165
+ <Snippet name="rdb/rds-proxy" parentHeading="RDS Proxy Configuration" />
166
+
167
+ #### SSL Requirements When Connecting Without RDS Proxy
168
+
169
+ The Amazon RDS CA bundle must be in the runtime's system trust store.
170
+
171
+ ##### Container Runtimes
172
+
173
+ <Tabs>
174
+ <TabItem label="Amazon Linux">
175
+
176
+ ```dockerfile
177
+ ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /etc/pki/ca-trust/source/anchors/global-bundle.pem
178
+ RUN update-ca-trust
179
+ ```
180
+
181
+ </TabItem>
182
+ <TabItem label="Debian">
183
+
184
+ ```dockerfile
185
+ ADD https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem /usr/local/share/ca-certificates/rds-global-bundle.crt
186
+ RUN update-ca-certificates
187
+ ```
188
+
189
+ </TabItem>
190
+ </Tabs>
191
+
192
+ ##### Zip Lambda Functions
193
+
194
+ For zip-deployed Lambda functions (such as a <Link path="guides/fastapi">`py#api` FastAPI</Link>), the Amazon Linux 2023 Lambda execution environment's built-in CA trust store includes the Amazon Root CAs used by RDS.
195
+
196
+ When using RDS Proxy, you do not need to configure the RDS CA bundle in the runtime that connects to the database.
197
+
198
+ ### Cluster Instances
199
+
200
+ <Snippet name="rdb/cluster-instances" />
201
+
202
+ ### Serverless Capacity
203
+
204
+ <Snippet name="rdb/serverless-capacity" />
205
+
206
+ ### Engine Version
207
+
208
+ <Snippet name="rdb/engine-version" />
209
+
210
+ ### Deletion Protection
211
+
212
+ <Snippet name="rdb/deletion-protection" />
213
+
214
+ ### Removal Policy
215
+
216
+ <Snippet name="rdb/removal-policy" />
217
+
218
+ ### Logging and Monitoring
219
+
220
+ <OptionFilter when={{ engine: 'postgres' }}>
221
+ <Snippet name="rdb/logging-postgres" />
222
+ </OptionFilter>
223
+
224
+ <OptionFilter when={{ engine: 'mysql' }}>
225
+ <Snippet name="rdb/logging-mysql" />
226
+ </OptionFilter>
227
+
228
+ <Snippet name="rdb/performance-insights" />
229
+
230
+ ### Encryption Key Rotation
231
+
232
+ <Snippet name="rdb/encryption-key-rotation" />
233
+
234
+ ## Connections
235
+
236
+ Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
237
+
238
+ <CardGrid>
239
+ <ConnectionCard
240
+ title="Python Agent to Relational Database"
241
+ description="Connect a Python Agent to an Aurora relational database"
242
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-agent-rdb`}
243
+ source="strands"
244
+ sourceBadge="python"
245
+ target="aurora"
246
+ targetBadge="python"
247
+ />
248
+ <ConnectionCard
249
+ title="FastAPI to Relational Database"
250
+ description="Connect a FastAPI to an Aurora relational database"
251
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-fast-api-rdb`}
252
+ source="fastapi"
253
+ target="aurora"
254
+ targetBadge="python"
255
+ />
256
+ <ConnectionCard
257
+ title="Python MCP Server to Relational Database"
258
+ description="Connect a Python MCP Server to an Aurora relational database"
259
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/py-mcp-server-rdb`}
260
+ source="mcp"
261
+ sourceBadge="python"
262
+ target="aurora"
263
+ targetBadge="python"
264
+ />
265
+ </CardGrid>
@@ -54,7 +54,7 @@ If the `functionPath` option is provided, the generater will add the necessary f
54
54
 
55
55
  <Snippet name="shared-constructs" />
56
56
 
57
- The generator creates infrastructure as code for deploying your function based on your selected `iacProvider`:
57
+ The generator creates infrastructure as code for deploying your function based on your selected `iac`:
58
58
 
59
59
  <Infrastructure>
60
60
  <Fragment slot="cdk">
@@ -43,7 +43,7 @@ You will find the following changes in your React website:
43
43
 
44
44
  <Snippet name="shared-constructs" />
45
45
 
46
- You will also find the following infrastructure code generated based on your selected `iacProvider`:
46
+ You will also find the following infrastructure code generated based on your selected `iac`:
47
47
 
48
48
  <Infrastructure>
49
49
  <Fragment slot="cdk">
@@ -79,6 +79,11 @@ browser: Web Browser {
79
79
  icon: /nx-plugin-for-aws/icons/aws/client.svg
80
80
  }
81
81
 
82
+ waf: WAF {
83
+ shape: image
84
+ icon: /nx-plugin-for-aws/icons/aws/waf.svg
85
+ }
86
+
82
87
  cognito: Cognito\n(User + Identity Pool) {
83
88
  shape: image
84
89
  icon: /nx-plugin-for-aws/icons/aws/cognito.svg
@@ -93,11 +98,52 @@ backend: Authenticated\nAWS Resources {
93
98
  shape: rectangle
94
99
  }
95
100
 
96
- browser -> cognito: Sign in
101
+ browser -> waf: Sign in
102
+ waf -> cognito
97
103
  cognito -> iam
98
104
  browser -> backend: IAM/Cognito
99
105
  ```
100
106
 
107
+ #### Threat protection
108
+
109
+ The User Pool is created on the Cognito [Plus feature plan](https://docs.aws.amazon.com/cognito/latest/developerguide/feature-plans-features-plus.html) with [threat protection](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pool-settings-threat-protection.html) set to `AUDIT` mode for standard authentication. In audit mode, Cognito assigns a risk level to each sign-in and logs the assessment to CloudWatch without blocking users.
110
+
111
+ Once you have observed the risk assessments for your users, you can switch to full-function enforcement to automatically respond to risky activity (for example requiring MFA or blocking sign-in):
112
+
113
+ <Infrastructure>
114
+ <Fragment slot="cdk">
115
+ Set `standardThreatProtectionMode` to `StandardThreatProtectionMode.FULL_FUNCTION` in `packages/common/constructs/src/core/user-identity.ts`.
116
+ </Fragment>
117
+ <Fragment slot="terraform">
118
+ Set `advanced_security_mode` to `ENFORCED` in the `user_pool_add_ons` block in `packages/common/terraform/src/core/user-identity/identity/identity.tf`.
119
+ </Fragment>
120
+ </Infrastructure>
121
+
122
+ #### Web Application Firewall (WAF)
123
+
124
+ By default the User Pool is associated with an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL using the `AWSManagedRulesCommonRuleSet` and `AWSManagedRulesKnownBadInputsRuleSet` managed rule groups. You can disable this if you wish to manage your own Web ACL or do not require one:
125
+
126
+ <Infrastructure>
127
+ <Fragment slot="cdk">
128
+ ```ts
129
+ new UserIdentity(this, 'Identity', { enableWaf: false });
130
+ ```
131
+ </Fragment>
132
+ <Fragment slot="terraform">
133
+ ```hcl
134
+ module "user_identity" {
135
+ source = "../../common/terraform/src/core/user-identity"
136
+
137
+ enable_waf = false
138
+ }
139
+ ```
140
+ </Fragment>
141
+ </Infrastructure>
142
+
143
+ :::caution[`EC2MetaDataSSRF_QUERYARGUMENTS` is set to Count]
144
+ This rule flags loopback addresses in query arguments as [SSRF](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-list.html) attempts, which would block local sign-in since the Hosted UI receives a `localhost` `redirect_uri`. It is therefore set to [Count](https://docs.aws.amazon.com/waf/latest/developerguide/web-acl-rule-action.html#web-acl-rule-action-count) while local callback URLs are configured — matches are still logged, and every other rule blocks. Remove the local callback URLs to restore it to Block.
145
+ :::
146
+
101
147
  ## Infrastructure Usage
102
148
 
103
149
  <Infrastructure>
@@ -107,7 +153,7 @@ You will need to add the user identity infrastructure to your stack, declaring i
107
153
  ```ts title="packages/infra/src/stacks/application-stack.ts" {3,9}
108
154
  import { Stack } from 'aws-cdk-lib';
109
155
  import { Construct } from 'constructs';
110
- import { MyWebsite, UserIdentity } from ':my-scope/common-constructs';
156
+ import { MyWebsite, UserIdentity } from '@my-scope/common-constructs';
111
157
 
112
158
  export class ApplicationStack extends Stack {
113
159
  constructor(scope: Construct, id: string) {
@@ -152,6 +198,21 @@ The user identity module automatically adds the necessary <Link path="guides/rea
152
198
  </Fragment>
153
199
  </Infrastructure>
154
200
 
201
+ :::caution[Remove localhost callback URLs for production]
202
+ The generated User Pool client allows your CloudFront distribution URL (and any custom domain names configured on it) as OAuth callback/logout URLs, plus `http://localhost:4200` and `http://localhost:4300` for local development against the deployed pool.
203
+
204
+ It is recommended to **remove the `http://localhost` callback/logout URLs for production stages**, keeping the allowlist limited to your real application origins.
205
+
206
+ <Infrastructure>
207
+ <Fragment slot="cdk">
208
+ Edit the callback/logout URLs in `packages/common/constructs/src/core/user-identity.ts`.
209
+ </Fragment>
210
+ <Fragment slot="terraform">
211
+ Edit the `callback_urls`/`logout_urls` in `packages/common/terraform/src/core/user-identity/identity/identity.tf`.
212
+ </Fragment>
213
+ </Infrastructure>
214
+ :::
215
+
155
216
  ### Granting Access to Authenticated Users
156
217
 
157
218
  In order to grant authenticated users access to perform certain actions, such as granting permissions to invoke an API, you can add IAM policy statements to the identity pool authenticated role:
@@ -161,7 +222,7 @@ In order to grant authenticated users access to perform certain actions, such as
161
222
  ```ts title="packages/infra/src/stacks/application-stack.ts" {12}
162
223
  import { Stack } from 'aws-cdk-lib';
163
224
  import { Construct } from 'constructs';
164
- import { MyWebsite, UserIdentity, MyApi } from ':my-scope/common-constructs';
225
+ import { MyWebsite, UserIdentity, MyApi } from '@my-scope/common-constructs';
165
226
 
166
227
  export class ApplicationStack extends Stack {
167
228
  constructor(scope: Construct, id: string) {