@aws/nx-plugin-mcp 1.0.0-rc.7 → 1.0.0-rc.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/aws-nx-mcp.js +12317 -10933
- package/docs/get_started/building-with-ai.mdx +116 -0
- package/docs/get_started/concepts.mdx +67 -0
- package/docs/get_started/existing-project.mdx +180 -0
- package/docs/get_started/graph-builder.mdx +39 -0
- package/docs/get_started/quick-start.mdx +277 -0
- package/docs/get_started/tutorials/contribute-generator.mdx +408 -0
- package/docs/get_started/tutorials/dungeon-game/1.mdx +1301 -0
- package/docs/get_started/tutorials/dungeon-game/2.mdx +237 -0
- package/docs/get_started/tutorials/dungeon-game/3.mdx +76 -0
- package/docs/get_started/tutorials/dungeon-game/4.mdx +164 -0
- package/docs/get_started/tutorials/dungeon-game/overview.mdx +145 -0
- package/docs/get_started/tutorials/dungeon-game/wrap-up.mdx +41 -0
- package/docs/get_started/tutorials/existing-project.mdx +4 -0
- package/docs/get_started/upgrading.mdx +147 -0
- package/docs/guides/agentcore-gateway.mdx +490 -0
- package/docs/guides/agentcore-harness.mdx +275 -0
- package/docs/guides/astro-docs.mdx +8 -0
- package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
- package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
- package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
- package/docs/guides/connection/py-agent-a2a.mdx +48 -16
- package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-agent-gateway.mdx +178 -0
- package/docs/guides/connection/py-agent-mcp.mdx +43 -14
- package/docs/guides/connection/py-agent-rdb.mdx +178 -0
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
- package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
- package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
- package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
- package/docs/guides/connection/react-agui.mdx +13 -13
- package/docs/guides/connection/react-fastapi.mdx +38 -2
- package/docs/guides/connection/react-py-agent.mdx +9 -15
- package/docs/guides/connection/react-smithy.mdx +3 -3
- package/docs/guides/connection/react-trpc.mdx +1 -1
- package/docs/guides/connection/react-ts-agent.mdx +8 -8
- package/docs/guides/connection/smithy-dynamodb.mdx +5 -5
- package/docs/guides/connection/smithy-rdb.mdx +9 -9
- package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
- package/docs/guides/connection/trpc-rdb.mdx +6 -6
- package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
- package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-agent-gateway.mdx +143 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
- package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
- package/docs/guides/connection.mdx +122 -5
- package/docs/guides/docker-bundling.mdx +69 -12
- package/docs/guides/fastapi.mdx +249 -9
- package/docs/guides/local-development.mdx +87 -0
- package/docs/guides/nx-generator.mdx +4 -3
- package/docs/guides/nx-migration.mdx +165 -0
- package/docs/guides/py-agent.mdx +264 -49
- package/docs/guides/py-dynamodb.mdx +476 -0
- package/docs/guides/py-mcp-server.mdx +61 -2
- package/docs/guides/py-rdb.mdx +265 -0
- package/docs/guides/python-lambda-function.mdx +1 -1
- package/docs/guides/react-website-auth.mdx +65 -4
- package/docs/guides/react-website.mdx +149 -30
- package/docs/guides/runtime-config.mdx +1 -1
- package/docs/guides/security.mdx +75 -0
- package/docs/guides/smithy-project.mdx +167 -0
- package/docs/guides/terraform-project.mdx +2 -2
- package/docs/guides/trpc.mdx +53 -16
- package/docs/guides/ts-agent.mdx +183 -10
- package/docs/guides/ts-dcr-proxy.mdx +569 -0
- package/docs/guides/ts-dynamodb.mdx +66 -242
- package/docs/guides/ts-lambda-function.mdx +1 -1
- package/docs/guides/ts-mcp-server.mdx +109 -29
- package/docs/guides/ts-nx-plugin.mdx +3 -3
- package/docs/guides/ts-rdb.mdx +113 -467
- package/docs/guides/ts-smithy-api.mdx +258 -18
- package/docs/guides/typescript-infrastructure.mdx +46 -24
- package/docs/guides/typescript-project.mdx +134 -27
- package/docs/guides/workspace.mdx +10 -3
- package/docs/snippets/agent/architecture.mdx +1 -1
- package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
- package/docs/snippets/agent/runtime-arn.mdx +23 -2
- package/docs/snippets/agent/securing-your-agent.mdx +39 -0
- package/docs/snippets/api/access-logging.mdx +33 -0
- package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
- package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
- package/docs/snippets/api/type-safe-api-integrations.mdx +33 -2
- package/docs/snippets/api/waf-configuration.mdx +3 -3
- package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
- package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
- package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
- package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
- package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
- package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
- package/docs/snippets/dynamodb/deploying-table.mdx +166 -0
- package/docs/snippets/dynamodb/gsi-config.mdx +38 -0
- package/docs/snippets/dynamodb/infrastructure.mdx +33 -0
- package/docs/snippets/dynamodb/local-dev-start.mdx +13 -0
- package/docs/snippets/dynamodb/local-dev-windows.mdx +15 -0
- package/docs/snippets/lambda-function/deploying-your-function.mdx +3 -3
- package/docs/snippets/mcp/architecture.mdx +1 -1
- package/docs/snippets/mcp/bedrock-deployment.mdx +9 -5
- package/docs/snippets/mcp/config.mdx +3 -2
- package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
- package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
- package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
- package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
- package/docs/snippets/prerequisites.mdx +1 -4
- package/docs/snippets/rdb/architecture.mdx +38 -0
- package/docs/snippets/rdb/cluster-instances.mdx +31 -0
- package/docs/snippets/rdb/deletion-protection.mdx +34 -0
- package/docs/snippets/rdb/deploying.mdx +187 -0
- package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
- package/docs/snippets/rdb/engine-version.mdx +63 -0
- package/docs/snippets/rdb/infrastructure.mdx +35 -0
- package/docs/snippets/rdb/logging-mysql.mdx +5 -0
- package/docs/snippets/rdb/logging-postgres.mdx +5 -0
- package/docs/snippets/rdb/performance-insights.mdx +34 -0
- package/docs/snippets/rdb/rds-proxy.mdx +50 -0
- package/docs/snippets/rdb/removal-policy.mdx +57 -0
- package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
- package/docs/snippets/recommended-prerequisites.mdx +10 -0
- package/docs/snippets/required-prerequisites.mdx +1 -4
- package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
- package/docs/snippets/shared-constructs.mdx +1 -1
- package/docs/snippets/trivy-image-scan.mdx +37 -0
- package/generators.json +152 -10
- package/package.json +1 -1
- package/src/agentcore-gateway/agent-connection/schema.json +31 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
- package/src/agentcore-gateway/react-connection/schema.json +31 -0
- package/src/agentcore-gateway/schema.json +72 -0
- package/src/agentcore-harness/schema.json +53 -0
- package/src/connection/schema.json +5 -0
- package/src/infra/app/schema.json +5 -0
- package/src/init/schema.json +35 -0
- package/src/internal/test-matrix/schema.json +21 -0
- package/src/license/schema.json +5 -0
- package/src/preset/schema.json +16 -5
- package/src/py/agent/a2a-connection/schema.json +5 -0
- package/src/py/agent/gateway-connection/schema.json +31 -0
- package/src/py/agent/mcp-connection/schema.json +5 -0
- package/src/py/agent/react-connection/schema.json +5 -0
- package/src/py/agent/schema.json +15 -1
- package/src/py/api/schema.json +5 -0
- package/src/py/dynamodb/agent-connection/schema.json +27 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
- package/src/py/dynamodb/schema.json +76 -0
- package/src/py/fast-api/react/schema.json +5 -0
- package/src/py/fast-api/schema.json +6 -0
- package/src/py/lambda-function/schema.json +5 -0
- package/src/py/mcp-server/schema.json +6 -0
- package/src/py/project/schema.json +5 -0
- package/src/py/rdb/agent-connection/schema.json +27 -0
- package/src/py/rdb/fast-api-connection/schema.json +23 -0
- package/src/py/rdb/mcp-server-connection/schema.json +27 -0
- package/src/py/rdb/schema.json +78 -0
- package/src/smithy/project/schema.json +28 -1
- package/src/smithy/react-connection/schema.json +5 -0
- package/src/smithy/ts/api/schema.json +6 -0
- package/src/terraform/project/schema.json +5 -0
- package/src/trpc/backend/schema.json +6 -0
- package/src/trpc/react/schema.json +5 -0
- package/src/ts/agent/a2a-connection/schema.json +5 -0
- package/src/ts/agent/gateway-connection/schema.json +31 -0
- package/src/ts/agent/mcp-connection/schema.json +5 -0
- package/src/ts/agent/react-connection/schema.json +5 -0
- package/src/ts/agent/schema.json +14 -0
- package/src/ts/api/schema.json +5 -0
- package/src/ts/astro-docs/schema.json +3 -3
- package/src/ts/dcr-proxy/schema.json +44 -0
- package/src/ts/docs/schema.json +3 -3
- package/src/ts/dynamodb/agent-connection/schema.json +5 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/ts/dynamodb/schema.json +26 -2
- package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
- package/src/ts/lambda-function/schema.json +5 -0
- package/src/ts/lib/schema.json +5 -0
- package/src/ts/mcp-server/schema.json +6 -0
- package/src/ts/nx-generator/schema.json +5 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/schema.json +5 -0
- package/src/ts/rdb/agent-connection/schema.json +5 -0
- package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
- package/src/ts/rdb/schema.json +7 -1
- package/src/ts/rdb/smithy-connection/schema.json +5 -0
- package/src/ts/rdb/trpc-connection/schema.json +5 -0
- package/src/ts/react-website/app/schema.json +12 -6
- package/src/ts/react-website/cognito-auth/schema.json +5 -0
- package/src/ts/react-website/runtime-config/schema.json +5 -0
- package/src/ts/website/app/schema.json +11 -6
- package/src/ts/website/auth/schema.json +5 -0
- /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
- /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
|
@@ -3,12 +3,13 @@ title: TypeScript Projects
|
|
|
3
3
|
description: Reference documentation for TypeScript projects
|
|
4
4
|
generator: ts#project
|
|
5
5
|
---
|
|
6
|
-
import { FileTree } from '@astrojs/starlight/components';
|
|
6
|
+
import { FileTree, Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
|
7
7
|
import RunGenerator from '@components/run-generator.astro';
|
|
8
8
|
import InstallCommand from '@components/install-command.astro';
|
|
9
9
|
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
10
10
|
import NxCommands from '@components/nx-commands.astro';
|
|
11
11
|
import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
|
|
12
|
+
import CreateNxWorkspaceCommand from '@components/create-nx-workspace-command.astro';
|
|
12
13
|
import Link from '@components/link.astro';
|
|
13
14
|
|
|
14
15
|
The TypeScript project generator can be used to create a modern [TypeScript](https://www.typescriptlang.org/) library or application configured with best practices such as [ECMAScript Modules (ESM)](https://www.typescriptlang.org/docs/handbook/modules/reference.html), TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html), [Vitest](https://vitest.dev/) for running tests and [Biome](https://biomejs.dev/) for linting and formatting.
|
|
@@ -33,6 +34,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
33
34
|
|
|
34
35
|
- src TypeScript source code
|
|
35
36
|
- index.ts
|
|
37
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
36
38
|
- project.json Project configuration and build targets
|
|
37
39
|
- tsconfig.json Base TypeScript configuration for this project (extends workspace root tsconfig.base.json)
|
|
38
40
|
- tsconfig.lib.json TypeScript configuration for your library (your runtime or packaged source)
|
|
@@ -41,8 +43,8 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
41
43
|
|
|
42
44
|
</FileTree>
|
|
43
45
|
|
|
44
|
-
:::tip[
|
|
45
|
-
|
|
46
|
+
:::tip[Project package.json]
|
|
47
|
+
The project's `package.json` starts minimal. As you add runtime dependencies they are declared here (shared build/test tooling stays in the workspace root) — you can find out more [below](#dependencies).
|
|
46
48
|
:::
|
|
47
49
|
|
|
48
50
|
You will also notice some changes to the following files in your workspace root:
|
|
@@ -85,13 +87,9 @@ export * from './algorithms/index.js';
|
|
|
85
87
|
[TypeScript aliases](https://www.typescriptlang.org/docs/handbook/modules/reference.html#paths) for your project are configured in your workspace `tsconfig.base.json`, which allows you to reference your TypeScript project from other TypeScript projects:
|
|
86
88
|
|
|
87
89
|
```ts title="packages/my-other-project/src/index.ts"
|
|
88
|
-
import { sayHello } from '
|
|
90
|
+
import { sayHello } from '@my-scope/my-library';
|
|
89
91
|
```
|
|
90
92
|
|
|
91
|
-
:::note[Project Aliases]
|
|
92
|
-
Aliases for your TypeScript projects begin with a `:` rather than the traditional `@`, since this avoids the possibility of name conflicts between local packages in your workspace and remote packages in [NPM](https://www.npmjs.com/).
|
|
93
|
-
:::
|
|
94
|
-
|
|
95
93
|
When you add an import statement for a new project in your workspace for the first time, you will likely see an error in your IDE similar to the below:
|
|
96
94
|
|
|
97
95
|
<details>
|
|
@@ -106,28 +104,40 @@ File '/path/to/my/workspace/packages/my-library/src/index.ts' is not listed with
|
|
|
106
104
|
|
|
107
105
|
</details>
|
|
108
106
|
|
|
109
|
-
This is because a [project reference](https://www.typescriptlang.org/docs/handbook/project-references.html) has not yet been set up.
|
|
107
|
+
This is because a [project reference](https://www.typescriptlang.org/docs/handbook/project-references.html) has not yet been set up, and the imported project has not yet been declared as a workspace dependency in your project's `package.json`.
|
|
110
108
|
|
|
111
|
-
|
|
109
|
+
Your workspace is configured with sync generators which manage both for you, so you don't need to configure them by hand. Simply run the following command and Nx will add the required configuration:
|
|
112
110
|
|
|
113
111
|
<NxCommands commands={['sync']} />
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
```bash wrap
|
|
114
|
+
NX The workspace is out of sync
|
|
115
|
+
|
|
116
|
+
[@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on, contain stale project references, or have duplicate project references.
|
|
117
|
+
[@aws/nx-plugin:ts#sync]: Local project dependencies are out of sync. The following workspace dependencies will be declared:
|
|
118
|
+
packages/my-other-project/package.json:
|
|
119
|
+
- @my-scope/my-library: workspace:*
|
|
120
|
+
|
|
121
|
+
Syncing the workspace...
|
|
122
|
+
The workspace was synced successfully!
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Nx's TypeScript sync generator adds the project reference, and the plugin's `ts#sync` generator declares the imported project in your project's `package.json` (`workspace:*` where the package manager supports the workspace protocol, `*` on npm and yarn classic), so the package manager links the local project on install. After this, the error in your IDE should be gone and you are ready to use your library.
|
|
116
126
|
|
|
117
127
|
:::tip[Build Shortcut]
|
|
118
|
-
You can also just build your project and you'll be prompted
|
|
128
|
+
You can also just build your project — the sync generators run first and you'll be prompted to apply any outstanding changes:
|
|
119
129
|
|
|
120
130
|
```bash wrap
|
|
121
|
-
|
|
131
|
+
NX The workspace is out of sync
|
|
122
132
|
|
|
123
|
-
|
|
133
|
+
...
|
|
124
134
|
|
|
125
|
-
? Would you like to sync the identified changes to get your workspace up to date?
|
|
135
|
+
? Would you like to sync the identified changes to get your workspace up to date? …
|
|
126
136
|
Yes, sync the changes and run the tasks
|
|
127
137
|
No, run the tasks without syncing the changes
|
|
128
138
|
```
|
|
129
139
|
|
|
130
|
-
Select `Yes` to allow Nx to
|
|
140
|
+
Select `Yes` to allow Nx to sync your workspace.
|
|
131
141
|
:::
|
|
132
142
|
|
|
133
143
|
### Keeping Path Aliases In Sync
|
|
@@ -136,13 +146,116 @@ If you add custom `compilerOptions.paths` entries in a project's `tsconfig.json`
|
|
|
136
146
|
|
|
137
147
|
### Dependencies
|
|
138
148
|
|
|
139
|
-
|
|
149
|
+
Each TypeScript project declares its third-party runtime dependencies in its own `package.json`. Build and test tooling shared across projects is defined in the root `package.json`.
|
|
150
|
+
|
|
151
|
+
To add a runtime dependency to a project, install it into that project:
|
|
152
|
+
|
|
153
|
+
<InstallCommand pkg="some-npm-package" project="@my-scope/my-library" />
|
|
154
|
+
|
|
155
|
+
You can also run your package manager's plain `add`/`install` command from within the project's directory.
|
|
156
|
+
|
|
157
|
+
To add a shared dev tool, install it at the workspace root:
|
|
158
|
+
|
|
159
|
+
<InstallCommand pkg="some-dev-tool" dev />
|
|
160
|
+
|
|
161
|
+
:::note
|
|
162
|
+
Biome's [`noUndeclaredDependencies`](https://biomejs.dev/linter/rules/no-undeclared-dependencies/) lint rule enforces that a project's source only imports packages declared in its own `package.json`. Config files, build scripts and tests are exempt, so shared tooling can stay at the root.
|
|
163
|
+
:::
|
|
164
|
+
|
|
165
|
+
#### Catalogs
|
|
166
|
+
|
|
167
|
+
For package managers which support catalogs ([pnpm](https://pnpm.io/catalogs), [yarn](https://yarnpkg.com/features/catalogs) and [bun](https://bun.com/docs/install/catalogs)), generators record each version in the catalog and reference it with the `catalog:` protocol (eg `"zod": "catalog:"`), so the catalog is the single source of truth for versions regardless of which project declares the dependency. This helps you to follow a [single version policy](https://nx.dev/concepts/decisions/dependency-management#single-version-policy), avoiding type conflicts and multiple copies of packages in deployment bundles.
|
|
168
|
+
|
|
169
|
+
When you add a new dependency yourself, keep it in the catalog too:
|
|
170
|
+
|
|
171
|
+
<Tabs syncKey="package-manager">
|
|
172
|
+
<TabItem label="pnpm">
|
|
173
|
+
The workspace sets [`catalogMode: strict`](https://pnpm.io/settings#catalogmode), so `pnpm add` records the version in the catalog and references it automatically — no extra steps.
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
pnpm add some-npm-package --filter my-library
|
|
177
|
+
```
|
|
178
|
+
</TabItem>
|
|
179
|
+
<TabItem label="yarn">
|
|
180
|
+
yarn's `catalog:` protocol only *references* an existing catalog entry — it cannot create one — so record the version first.
|
|
181
|
+
|
|
182
|
+
<Steps>
|
|
183
|
+
1. Add the version under `catalog` in `.yarnrc.yml`:
|
|
184
|
+
|
|
185
|
+
```yaml title=".yarnrc.yml"
|
|
186
|
+
catalog:
|
|
187
|
+
some-npm-package: ^1.0.0
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
2. Reference it from the project:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
yarn workspace @my-scope/my-library add some-npm-package@catalog:
|
|
194
|
+
```
|
|
195
|
+
</Steps>
|
|
196
|
+
</TabItem>
|
|
197
|
+
<TabItem label="bun">
|
|
198
|
+
bun's `catalog:` protocol only *references* an existing catalog entry — it cannot create one — so record the version first.
|
|
140
199
|
|
|
141
|
-
|
|
200
|
+
<Steps>
|
|
201
|
+
1. Add the version under `catalog` in the root `package.json`:
|
|
142
202
|
|
|
143
|
-
|
|
203
|
+
```json title="package.json"
|
|
204
|
+
{
|
|
205
|
+
"catalog": {
|
|
206
|
+
"some-npm-package": "^1.0.0"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
144
210
|
|
|
145
|
-
|
|
211
|
+
2. Reference it from the project:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
bun add some-npm-package@catalog: --cwd packages/my-library
|
|
215
|
+
```
|
|
216
|
+
</Steps>
|
|
217
|
+
</TabItem>
|
|
218
|
+
</Tabs>
|
|
219
|
+
|
|
220
|
+
:::tip[Aligning versions on npm]
|
|
221
|
+
npm has no catalog feature, so versions are declared directly in each `package.json`. To keep them consistent across projects, we recommend [syncpack](https://github.com/JamieMason/syncpack) (`npx syncpack lint`).
|
|
222
|
+
:::
|
|
223
|
+
|
|
224
|
+
##### Opting out of catalogs
|
|
225
|
+
|
|
226
|
+
Catalogs are enabled by default. To turn them off, create your workspace with `--catalog false`:
|
|
227
|
+
|
|
228
|
+
<CreateNxWorkspaceCommand workspace="my-project" extraArgs="--catalog false" />
|
|
229
|
+
|
|
230
|
+
Or set it in `aws-nx-plugin.config.mts` at any time:
|
|
231
|
+
|
|
232
|
+
```ts title="aws-nx-plugin.config.mts"
|
|
233
|
+
export default {
|
|
234
|
+
packageManager: {
|
|
235
|
+
catalogs: false,
|
|
236
|
+
},
|
|
237
|
+
} satisfies AwsNxPluginConfig;
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
With catalogs disabled, generators write dependency versions directly into each project's `package.json`, and keeping versions aligned across projects is your responsibility.
|
|
241
|
+
|
|
242
|
+
#### Declaring all dependencies at the root
|
|
243
|
+
|
|
244
|
+
If you prefer declaring every dependency in the root `package.json` only (no per-project dependency declarations), turn off the lint rule in the workspace `biome.json`:
|
|
245
|
+
|
|
246
|
+
```json title="biome.json"
|
|
247
|
+
{
|
|
248
|
+
"linter": {
|
|
249
|
+
"rules": {
|
|
250
|
+
"correctness": {
|
|
251
|
+
"noUndeclaredDependencies": "off"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Projects resolve root-installed packages at build time, so everything still builds — you give up per-project manifests as an accurate record of each project's dependencies (which matters if you later publish a project or split the repo).
|
|
146
259
|
|
|
147
260
|
#### Runtime Code
|
|
148
261
|
|
|
@@ -179,7 +292,7 @@ export default defineConfig([
|
|
|
179
292
|
output: {
|
|
180
293
|
file: '../../dist/packages/my-library/bundle/index.js',
|
|
181
294
|
format: 'cjs',
|
|
182
|
-
|
|
295
|
+
codeSplitting: false,
|
|
183
296
|
},
|
|
184
297
|
},
|
|
185
298
|
]);
|
|
@@ -193,12 +306,6 @@ Note that in the above target, we chose `src/index.ts` as our entrypoint for the
|
|
|
193
306
|
If you're building an AWS Lambda function, check out the <Link path="/guides/ts-lambda-function">`ts#lambda-function`</Link> generator as this configures bundling for you, as well as generating infrastructure and adding observability and type-safety.
|
|
194
307
|
:::
|
|
195
308
|
|
|
196
|
-
#### Publishing to NPM
|
|
197
|
-
|
|
198
|
-
If you are publishing your TypeScript project to NPM, you must create a `package.json` file for it.
|
|
199
|
-
|
|
200
|
-
This must declare the dependencies that your project references. Since at build time your project will resolve dependencies installed via the workspace root `package.json`, Biome's `noUndeclaredDependencies` rule will warn you if your project imports a package that isn't listed in its `package.json`.
|
|
201
|
-
|
|
202
309
|
### Building
|
|
203
310
|
|
|
204
311
|
Your TypeScript project is configured with a `build` target (defined in `project.json`), which you can run via:
|
|
@@ -6,6 +6,7 @@ import { FileTree } from '@astrojs/starlight/components';
|
|
|
6
6
|
import Link from '@components/link.astro';
|
|
7
7
|
import CreateNxWorkspaceCommand from '@components/create-nx-workspace-command.astro';
|
|
8
8
|
import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
|
|
9
|
+
import InstallCommand from '@components/install-command.astro';
|
|
9
10
|
import NxCommands from '@components/nx-commands.astro';
|
|
10
11
|
import GeneratorParameters from '@components/generator-parameters.astro';
|
|
11
12
|
|
|
@@ -82,7 +83,11 @@ The default monorepo setup uses a [single version policy](https://nx.dev/concept
|
|
|
82
83
|
|
|
83
84
|
This means that all projects within your monorepo use the same version of dependencies by default, reducing issues related to packages in the same monorepo running into version mismatch issues.
|
|
84
85
|
|
|
85
|
-
From a Node perspective this means a single lockfile at the root with
|
|
86
|
+
From a Node perspective this means a single lockfile at the root, with dependencies installed once and linked into each project. Each Node project declares the runtime dependencies its source imports in its own `package.json`, while shared build/test tooling lives in the root `package.json` `devDependencies`. Add a project's runtime dependency by installing it into that project:
|
|
87
|
+
|
|
88
|
+
<InstallCommand pkg="some-npm-package" project="@my-scope/my-project" />
|
|
89
|
+
|
|
90
|
+
For package managers with catalog support ([pnpm](https://pnpm.io/catalogs), [yarn](https://yarnpkg.com/features/catalogs) and [bun](https://bun.com/docs/install/catalogs)), dependency versions are recorded in the catalog and referenced with the `catalog:` protocol, keeping a single source of truth for versions across every project's `package.json`. For npm workspaces, we recommend [syncpack](https://github.com/JamieMason/syncpack) to align versions declared across multiple `package.json` files.
|
|
86
91
|
|
|
87
92
|
From a Python perspective, this means a single `.venv` in the root of the monorepo with all dependencies installed into it. Each Python project has its own `pyproject.toml`, but the versions of those dependencies are managed by the UV workspace and subsequently written out to the `uv.lock` file in the root.
|
|
88
93
|
|
|
@@ -108,10 +113,12 @@ Run tests across all projects:
|
|
|
108
113
|
|
|
109
114
|
### Dev
|
|
110
115
|
|
|
111
|
-
|
|
116
|
+
Start all local development servers across your workspace:
|
|
112
117
|
|
|
113
118
|
<PackageManagerShortCommand commands={["dev"]} />
|
|
114
119
|
|
|
120
|
+
See the <Link path="guides/local-development">Local Development</Link> guide for more details.
|
|
121
|
+
|
|
115
122
|
### Sync
|
|
116
123
|
|
|
117
124
|
Run any [sync generators](https://nx.dev/concepts/sync-generators), which for example synchronise TypeScript project references (refer to the <Link path="guides/typescript-project">ts#project</Link> generator guide for more details):
|
|
@@ -181,7 +188,7 @@ export default {
|
|
|
181
188
|
} satisfies AwsNxPluginConfig;
|
|
182
189
|
```
|
|
183
190
|
|
|
184
|
-
- **`iac.provider`** — the default infrastructure-as-code provider (`cdk` or `terraform`) used by generators that emit infrastructure (e.g. `ts#infra`, `ts#
|
|
191
|
+
- **`iac.provider`** — the default infrastructure-as-code provider (`cdk` or `terraform`) used by generators that emit infrastructure (e.g. `ts#infra`, `ts#api`, `py#api`). Generators that accept an `--iac` flag default to `inherit`, which reads this value.
|
|
185
192
|
- **`containers.engine`** — the container CLI (`docker` or `finch`) baked into generated build/push/login commands. CDK image-asset builds also pick this up via the `CDK_DOCKER` environment variable. See the <Link path="guides/docker-bundling">Docker bundling guide</Link> for details.
|
|
186
193
|
|
|
187
194
|
You can edit either setting at any time — subsequent generator runs will pick up the new value.
|
|
@@ -15,7 +15,7 @@ A CDK construct is generated for your agent, named based on the `name` you chose
|
|
|
15
15
|
You can use this CDK construct in a CDK application:
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
import { MyProjectAgent } from '
|
|
18
|
+
import { MyProjectAgent } from '@my-scope/common-constructs';
|
|
19
19
|
|
|
20
20
|
export class ExampleStack extends Stack {
|
|
21
21
|
constructor(scope: Construct, id: string) {
|
|
@@ -69,7 +69,7 @@ By default, your Agent will be secured using IAM authentication, simply deploy i
|
|
|
69
69
|
<Infrastructure>
|
|
70
70
|
<Fragment slot="cdk">
|
|
71
71
|
```ts {5}
|
|
72
|
-
import { MyProjectAgent } from '
|
|
72
|
+
import { MyProjectAgent } from '@my-scope/common-constructs';
|
|
73
73
|
|
|
74
74
|
export class ExampleStack extends Stack {
|
|
75
75
|
constructor(scope: Construct, id: string) {
|
|
@@ -81,7 +81,7 @@ export class ExampleStack extends Stack {
|
|
|
81
81
|
You can grant access to invoke your agent on Bedrock AgentCore Runtime using the `grantInvokeAccess` method, for example:
|
|
82
82
|
|
|
83
83
|
```ts {8}
|
|
84
|
-
import { MyProjectAgent } from '
|
|
84
|
+
import { MyProjectAgent } from '@my-scope/common-constructs';
|
|
85
85
|
|
|
86
86
|
export class ExampleStack extends Stack {
|
|
87
87
|
constructor(scope: Construct, id: string) {
|
|
@@ -131,7 +131,7 @@ When you select `Cognito` authentication, the generator configures the agent to
|
|
|
131
131
|
The generated construct accepts an `identity` prop which configures Cognito authentication:
|
|
132
132
|
|
|
133
133
|
```ts {8}
|
|
134
|
-
import { MyProjectAgent, UserIdentity } from '
|
|
134
|
+
import { MyProjectAgent, UserIdentity } from '@my-scope/common-constructs';
|
|
135
135
|
|
|
136
136
|
export class ExampleStack extends Stack {
|
|
137
137
|
constructor(scope: Construct, id: string) {
|
|
@@ -149,7 +149,7 @@ The `UserIdentity` construct can be generated using the <Link path="/guides/reac
|
|
|
149
149
|
<Fragment slot="terraform">
|
|
150
150
|
The generated module accepts `user_pool_id` and `user_pool_client_ids` variables for Cognito authentication:
|
|
151
151
|
|
|
152
|
-
```terraform {
|
|
152
|
+
```terraform {11-12}
|
|
153
153
|
module "user_identity" {
|
|
154
154
|
source = "../../common/terraform/src/core/user-identity"
|
|
155
155
|
}
|
|
@@ -169,4 +169,8 @@ module "my_project_agent" {
|
|
|
169
169
|
|
|
170
170
|
:::note[Custom OIDC Providers]
|
|
171
171
|
If you require custom JWT authentication with a non-Cognito OIDC provider, you can modify the generated CDK construct or Terraform module for your agent directly. Note that the connection generator will only support `IAM` or `Cognito` authentication.
|
|
172
|
+
:::
|
|
173
|
+
|
|
174
|
+
:::caution[Security Best Practices]
|
|
175
|
+
When implementing your agent'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).
|
|
172
176
|
:::
|
|
@@ -12,7 +12,7 @@ You can obtain the runtime ARN from your infrastructure as follows:
|
|
|
12
12
|
<Fragment slot="cdk">
|
|
13
13
|
```ts {9}
|
|
14
14
|
import { CfnOutput } from 'aws-cdk-lib';
|
|
15
|
-
import { MyProjectAgent } from '
|
|
15
|
+
import { MyProjectAgent } from '@my-scope/common-constructs';
|
|
16
16
|
|
|
17
17
|
export class ExampleStack extends Stack {
|
|
18
18
|
constructor(scope: Construct, id: string) {
|
|
@@ -26,7 +26,7 @@ export class ExampleStack extends Stack {
|
|
|
26
26
|
```
|
|
27
27
|
</Fragment>
|
|
28
28
|
<Fragment slot="terraform">
|
|
29
|
-
```terraform {
|
|
29
|
+
```terraform {9-10}
|
|
30
30
|
# Agent
|
|
31
31
|
module "my_project_agent" {
|
|
32
32
|
# Relative path to the generated module in the common/terraform project
|
|
@@ -61,4 +61,25 @@ The Bedrock AgentCore Runtime dataplane URL for invoking the agent is as follows
|
|
|
61
61
|
https://bedrock-agentcore.<region>.amazonaws.com/runtimes/<url-encoded-arn>/invocations
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
:::tip[Invocation URL]
|
|
65
|
+
Your infrastructure can also output the full invocation URL directly, with the ARN encoding handled for you:
|
|
66
|
+
|
|
67
|
+
<Infrastructure>
|
|
68
|
+
<Fragment slot="cdk">
|
|
69
|
+
```ts
|
|
70
|
+
new CfnOutput(this, 'AgentUrl', {
|
|
71
|
+
value: agent.invocationUrl,
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
</Fragment>
|
|
75
|
+
<Fragment slot="terraform">
|
|
76
|
+
```terraform
|
|
77
|
+
output "agent_url" {
|
|
78
|
+
value = module.my_project_agent.invocation_url
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
</Fragment>
|
|
82
|
+
</Infrastructure>
|
|
83
|
+
:::
|
|
84
|
+
|
|
64
85
|
The exact way to invoke this URL depends upon the authentication method used.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Securing your Agent
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Agents act on untrusted input and can drive real actions through their tools, so it's worth considering security from the start. The following practices apply to the generated agent.
|
|
6
|
+
|
|
7
|
+
### Treat model input and output as untrusted
|
|
8
|
+
|
|
9
|
+
Prompts can contain adversarial instructions (prompt injection), and model output is non-deterministic — neither should be trusted in security-sensitive logic:
|
|
10
|
+
|
|
11
|
+
- Define strict input schemas for your tools, as in the generated example tool. Constrain values to what the tool actually needs (enums, length limits, numeric ranges) rather than accepting free-form strings.
|
|
12
|
+
- Never pass model output directly into shell commands, SQL queries, code evaluation, or rendered HTML without validation or encoding.
|
|
13
|
+
- Apply authorization checks in your tools and downstream services — don't rely on the system prompt to prevent the model from misusing a tool it has access to.
|
|
14
|
+
|
|
15
|
+
Strands' [Prompt Engineering](https://strandsagents.com/docs/user-guide/safety-security/prompt-engineering/) and [Responsible AI](https://strandsagents.com/docs/user-guide/safety-security/responsible-ai/) guides cover writing robust, safety-conscious system prompts.
|
|
16
|
+
|
|
17
|
+
### Scope tool permissions tightly
|
|
18
|
+
|
|
19
|
+
Grant the agent's IAM role only the permissions its tools need. The vended CDK constructs and Terraform modules expose `grant*` methods and scoped policies for this purpose — for example granting an agent access to invoke a specific API rather than attaching broad managed policies. Where a tool acts on behalf of a user, prefer authorizing the action using the calling user's identity (passed through via the request context) over the agent's own ambient permissions.
|
|
20
|
+
|
|
21
|
+
### Provide a kill switch
|
|
22
|
+
|
|
23
|
+
Because model behaviour can change in unexpected ways, plan for quickly disabling or swapping the model without a code change:
|
|
24
|
+
|
|
25
|
+
- Read the model ID from configuration (for example a `MODEL_ID` environment variable) so operators can switch or roll back to a different model by updating configuration.
|
|
26
|
+
- Gate the agent behind a feature flag so its AI functionality can be disabled entirely. When disabled, return a generic message rather than an error, and ensure the rest of your application degrades gracefully.
|
|
27
|
+
|
|
28
|
+
Document how to flip these controls in your operational runbook.
|
|
29
|
+
|
|
30
|
+
### Protect sensitive data
|
|
31
|
+
|
|
32
|
+
- Avoid logging prompts and completions, which may contain user data. The generated agent's model error logging hook logs error metadata only, not conversation content — keep this property when adding your own logging.
|
|
33
|
+
- Return generic error messages to users; log detailed errors server-side.
|
|
34
|
+
- Isolate conversation state between users and sessions, and authorize access to any persisted session data.
|
|
35
|
+
- Redact personally identifiable information (PII) from prompts and outputs — either with a Bedrock Guardrail sensitive information filter (below) or, for Strands agents, the approaches in the [PII Redaction](https://strandsagents.com/docs/user-guide/safety-security/pii-redaction/) guide.
|
|
36
|
+
|
|
37
|
+
### Amazon Bedrock Guardrails
|
|
38
|
+
|
|
39
|
+
[Amazon Bedrock Guardrails](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html) provide configurable content filters, denied topics, and sensitive information (PII) filters which are evaluated on model input and output. You can attach a guardrail to the model used by the generated agent:
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Access logging
|
|
3
|
+
---
|
|
4
|
+
import Infrastructure from '@components/infrastructure.astro';
|
|
5
|
+
|
|
6
|
+
For REST APIs, the generated infrastructure enables [access logging](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html) by default, writing one structured JSON line per request to a dedicated CloudWatch Logs group. The log group is encrypted with a customer-managed KMS key and retained for one year.
|
|
7
|
+
|
|
8
|
+
API Gateway writes access logs using an account-level CloudWatch Logs role. This role is configured on the `AWS::ApiGateway::Account` setting, which is a **singleton per region per account** — there is only one role for every REST API in the region. To manage this safely across multiple independently-deployed stacks, the generated infrastructure:
|
|
9
|
+
|
|
10
|
+
- Creates a shared CloudWatch Logs role and configures it on the account only when no working role is already set, so deployments never overwrite a role another stack owns.
|
|
11
|
+
- Leaves the account setting untouched on teardown, so destroying one stack never disables logging for other REST APIs in the region.
|
|
12
|
+
|
|
13
|
+
<Infrastructure>
|
|
14
|
+
<Fragment slot="cdk">
|
|
15
|
+
The account role is managed by the `ApiGatewayAccount` construct, a stack-scoped singleton resolved via `ApiGatewayAccount.ensure(scope)`. Each REST API's stage depends on it, and the role is configured by a Lambda-backed custom resource.
|
|
16
|
+
|
|
17
|
+
You can customise the access log format by passing `deployOptions` when constructing your API:
|
|
18
|
+
|
|
19
|
+
```ts {3-5}
|
|
20
|
+
const api = new MyApi(this, 'MyApi', {
|
|
21
|
+
integrations: MyApi.defaultIntegrations(this).build(),
|
|
22
|
+
deployOptions: {
|
|
23
|
+
accessLogFormat: AccessLogFormat.clf(),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
</Fragment>
|
|
28
|
+
<Fragment slot="terraform">
|
|
29
|
+
The account role is managed by the `core/api/api-gateway-account` module, which is instantiated by the generated API module. It configures the account idempotently and is never reset on `terraform destroy`.
|
|
30
|
+
|
|
31
|
+
You can customise the access log format by editing the `access_log_settings` block on the `aws_api_gateway_stage` resource in the generated API module.
|
|
32
|
+
</Fragment>
|
|
33
|
+
</Infrastructure>
|
|
@@ -8,7 +8,7 @@ If your solution includes a website you can configure its CloudFront distributio
|
|
|
8
8
|
You can call the API `restrictCorsTo` method with website constructs, CloudFront distributions, origin strings, or a mix of them.
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
|
-
import { MyApi, MyWebsite } from '
|
|
11
|
+
import { MyApi, MyWebsite } from '@my-scope/common-constructs';
|
|
12
12
|
|
|
13
13
|
export class ExampleStack extends Stack {
|
|
14
14
|
constructor(scope: Construct, id: string) {
|
|
@@ -9,7 +9,7 @@ Given a CloudFront domain name `<domain_name>`, within the Terraform module for
|
|
|
9
9
|
- a `cors_allow_origins` property, set to `["http://localhost:4200", "http://localhost:4300", "https://<domain name>"]`, for HTTP APIs. This restricts the API gateway CORS to this distribution and local host.
|
|
10
10
|
- an `ALLOWED_ORIGINS` environment variable, set to `"https://<domain_name>"`, for REST APIs. This sets the CloudFront distribution as the only permitted CORS origin (other than local host) in AWS Lambda integrations. Note that this restriction is not applied to preflight OPTIONS - please +1 [this GitHub issue](https://github.com/awslabs/nx-plugin-for-aws/issues/377) to help prioritise addressing this.
|
|
11
11
|
|
|
12
|
-
```hcl {
|
|
12
|
+
```hcl {6,9}
|
|
13
13
|
module "my_api" {
|
|
14
14
|
source = "../../common/terraform/src/app/apis/my-api"
|
|
15
15
|
|
|
@@ -69,7 +69,7 @@ api.integrations.sayHello.handler.addToRolePolicy(new PolicyStatement({
|
|
|
69
69
|
|
|
70
70
|
If your API uses the `shared` pattern, the shared router Lambda is exposed as `api.integrations.$router`:
|
|
71
71
|
|
|
72
|
-
```ts {
|
|
72
|
+
```ts {5}
|
|
73
73
|
const api = new MyApi(this, 'MyApi', {
|
|
74
74
|
integrations: MyApi.defaultIntegrations(this).build(),
|
|
75
75
|
});
|
|
@@ -172,6 +172,37 @@ module "my_api" {
|
|
|
172
172
|
</Fragment>
|
|
173
173
|
</Infrastructure>
|
|
174
174
|
|
|
175
|
+
#### Customising Options Per-Operation
|
|
176
|
+
|
|
177
|
+
<Infrastructure>
|
|
178
|
+
<Fragment slot="cdk">
|
|
179
|
+
To customise the options used to create the default integration for _specific_ operations (without affecting the others), you can use the `withOperationOptions` method. For example, if you would like to increase the Lambda function timeout for just one operation:
|
|
180
|
+
|
|
181
|
+
```ts {4-6}
|
|
182
|
+
const api = new MyApi(this, 'MyApi', {
|
|
183
|
+
integrations: MyApi.defaultIntegrations(this)
|
|
184
|
+
.withOperationOptions({
|
|
185
|
+
sayHello: {
|
|
186
|
+
timeout: Duration.seconds(60),
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
.build(),
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// The selected operations remain default integrations, so they're still typed accordingly:
|
|
193
|
+
api.integrations.sayHello.handler.addToRolePolicy(new PolicyStatement({ ... }));
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The options you specify are merged with the default integration options (and any options set via `withDefaultOptions`). Note that you cannot specify options for operations which you have replaced via `withOverrides`, since these no longer use the default integration.
|
|
197
|
+
|
|
198
|
+
You will encounter a type error if the same operation is targeted by both `withOperationOptions` and `withOverrides`, regardless of the order in which you call them.
|
|
199
|
+
|
|
200
|
+
</Fragment>
|
|
201
|
+
<Fragment slot="terraform">
|
|
202
|
+
To customise options for specific operations with Terraform, you need to edit the generated Terraform module to configure individual Lambda functions per operation (see the [Explicit Integrations](#explicit-integrations) section below).
|
|
203
|
+
</Fragment>
|
|
204
|
+
</Infrastructure>
|
|
205
|
+
|
|
175
206
|
#### Overriding Integrations
|
|
176
207
|
|
|
177
208
|
<Infrastructure>
|
|
@@ -609,7 +640,7 @@ Generated CDK API constructs support two integration patterns:
|
|
|
609
640
|
|
|
610
641
|
For example, setting `pattern` to `'shared'` creates a single function instead of one per integration:
|
|
611
642
|
|
|
612
|
-
```ts {
|
|
643
|
+
```ts {6}
|
|
613
644
|
// packages/common/constructs/src/app/apis/my-api.ts
|
|
614
645
|
export class MyApi<...> extends ... {
|
|
615
646
|
|
|
@@ -6,7 +6,7 @@ import Infrastructure from '@components/infrastructure.astro';
|
|
|
6
6
|
For REST APIs, the generated construct associates an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL with the API Gateway stage by default. The Web ACL uses the AWS managed default ruleset ([`AWSManagedRulesCommonRuleSet`](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-crs) and [`AWSManagedRulesKnownBadInputsRuleSet`](https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups-baseline.html#aws-managed-rule-groups-baseline-known-bad-inputs)), providing protection against common web exploits including the OWASP Top 10. WAF request logs are written to a CloudWatch Logs group.
|
|
7
7
|
|
|
8
8
|
:::caution[SizeRestrictions_BODY deviation from defaults]
|
|
9
|
-
The `SizeRestrictions_BODY` rule from `AWSManagedRulesCommonRuleSet` is overridden to `Count` rather than `Block`, since the rule's 8 KB limit is too restrictive for most APIs. Oversized requests will still be recorded as metrics so you can monitor them. See the [AWS WAF body size limits](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) guide for more details.
|
|
9
|
+
The `SizeRestrictions_BODY` rule from `AWSManagedRulesCommonRuleSet` is overridden to `Count` rather than `Block`, since the rule's 8 KB limit is too restrictive for most APIs. Oversized requests will still be recorded as metrics so you can monitor them. See the [AWS WAF body size limits](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-oversize-handling.html) guide for more details. API Gateway natively enforces its [maximum payload size of 10 MB](https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html), returning a `413` for larger requests.
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
You can edit the generated rest-api construct to add, remove, or adjust rules (for example, to add [rate-based rules](https://docs.aws.amazon.com/waf/latest/developerguide/waf-rule-statement-type-rate-based.html) or additional managed rule groups).
|
|
@@ -15,7 +15,7 @@ You can edit the generated rest-api construct to add, remove, or adjust rules (f
|
|
|
15
15
|
<Fragment slot="cdk">
|
|
16
16
|
To opt out (for example, to attach your own Web ACL), set `enableWaf` to `false`:
|
|
17
17
|
|
|
18
|
-
```ts {
|
|
18
|
+
```ts {3}
|
|
19
19
|
const api = new MyApi(this, 'MyApi', {
|
|
20
20
|
integrations: MyApi.defaultIntegrations(this).build(),
|
|
21
21
|
enableWaf: false,
|
|
@@ -25,7 +25,7 @@ const api = new MyApi(this, 'MyApi', {
|
|
|
25
25
|
<Fragment slot="terraform">
|
|
26
26
|
To opt out (for example, to attach your own Web ACL), set `enable_waf` to `false`:
|
|
27
27
|
|
|
28
|
-
```hcl {
|
|
28
|
+
```hcl {5}
|
|
29
29
|
module "my_api" {
|
|
30
30
|
source = "../../common/terraform/src/app/apis/my-api"
|
|
31
31
|
|
|
@@ -21,7 +21,7 @@ remoteAgent.grantInvokeAccess(myAgent);
|
|
|
21
21
|
The remote agent's AgentCore runtime ARN is automatically registered in the `agentcore` namespace of <Link path="guides/runtime-config">Runtime Configuration</Link> by the generated CDK construct, so the host agent can discover it at runtime.
|
|
22
22
|
</Fragment>
|
|
23
23
|
<Fragment slot="terraform">
|
|
24
|
-
```hcl title="packages/infra/src/main.tf" {
|
|
24
|
+
```hcl title="packages/infra/src/main.tf" {15-34}
|
|
25
25
|
module "remote_agent" {
|
|
26
26
|
source = "../../common/terraform/src/app/agents/remote-agent"
|
|
27
27
|
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
title: DynamoDB Local Development
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
The `connection` generator configures your project's `
|
|
5
|
+
The `connection` generator configures your project's `dev` target to depend on the DynamoDB project's `dev` target. DynamoDB Local will start automatically alongside your project when running `dev`.
|
|
6
6
|
|
|
7
|
-
The `
|
|
7
|
+
The `LOCAL_DEV=true` environment variable is set automatically, so `getDynamoDBClient()` and `resolveTableName()` connect to the local DynamoDB Local instance instead of AWS.
|
|
@@ -11,7 +11,7 @@ To allow Lambda functions to access the DynamoDB table, grant the necessary perm
|
|
|
11
11
|
Call `grantReadWriteData` on the table construct. This grants both the DynamoDB and KMS permissions required by the Lambda execution role:
|
|
12
12
|
|
|
13
13
|
```ts title="packages/infra/src/stacks/application-stack.ts"
|
|
14
|
-
import { MyTable } from '
|
|
14
|
+
import { MyTable } from '@my-scope/common-constructs';
|
|
15
15
|
|
|
16
16
|
const table = new MyTable(this, 'Table');
|
|
17
17
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Python DynamoDB Local Development
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The `connection` generator configures your project's `dev` target to depend on the DynamoDB project's `dev` target. DynamoDB Local will start automatically alongside your project when running `dev`.
|
|
6
|
+
|
|
7
|
+
The `LOCAL_DEV=true` environment variable is set automatically, so `is_local()` returns `True` and your PynamoDB entities connect to the local DynamoDB instance instead of AWS.
|
|
@@ -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.
|