@aws/nx-plugin-mcp 1.0.0-rc.95 → 1.0.0-rc.97
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 +61 -14
- package/docs/get_started/existing-project.mdx +6 -3
- package/docs/get_started/quick-start.mdx +8 -0
- package/docs/get_started/tutorials/dungeon-game/1.mdx +12 -14
- package/docs/get_started/tutorials/dungeon-game/2.mdx +10 -2
- package/docs/get_started/tutorials/dungeon-game/3.mdx +4 -0
- package/docs/get_started/tutorials/dungeon-game/4.mdx +2 -2
- package/docs/guides/agentcore-gateway.mdx +4 -2
- package/docs/guides/agentcore-harness.mdx +2 -1
- package/docs/guides/astro-docs.mdx +25 -7
- package/docs/guides/connection/py-agent-a2a.mdx +2 -0
- package/docs/guides/connection/py-agent-dynamodb.mdx +1 -1
- package/docs/guides/connection/py-agent-gateway.mdx +3 -0
- package/docs/guides/connection/py-agent-mcp.mdx +18 -4
- package/docs/guides/connection/py-agent-rdb.mdx +5 -4
- package/docs/guides/connection/py-fast-api-dynamodb.mdx +1 -1
- package/docs/guides/connection/py-fast-api-rdb.mdx +7 -2
- package/docs/guides/connection/py-mcp-server-dynamodb.mdx +1 -1
- package/docs/guides/connection/py-mcp-server-rdb.mdx +6 -6
- package/docs/guides/connection/react-agui.mdx +34 -25
- package/docs/guides/connection/react-fastapi.mdx +114 -116
- package/docs/guides/connection/react-py-agent.mdx +4 -0
- package/docs/guides/connection/react-smithy.mdx +152 -98
- package/docs/guides/connection/react-trpc.mdx +13 -6
- package/docs/guides/connection/smithy-dynamodb.mdx +2 -8
- package/docs/guides/connection/smithy-rdb.mdx +3 -6
- package/docs/guides/connection/trpc-rdb.mdx +6 -6
- package/docs/guides/connection/ts-agent-a2a.mdx +4 -4
- package/docs/guides/connection/ts-agent-dynamodb.mdx +13 -11
- package/docs/guides/connection/ts-agent-gateway.mdx +2 -0
- package/docs/guides/connection/ts-agent-mcp.mdx +19 -7
- package/docs/guides/connection/ts-agent-rdb.mdx +2 -2
- package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +11 -7
- package/docs/guides/connection/ts-mcp-server-rdb.mdx +4 -3
- package/docs/guides/docker-bundling.mdx +23 -3
- package/docs/guides/fastapi.mdx +16 -5
- package/docs/guides/py-agent.mdx +129 -54
- package/docs/guides/py-mcp-server.mdx +3 -1
- package/docs/guides/py-rdb.mdx +13 -4
- package/docs/guides/python-lambda-function.mdx +8 -8
- package/docs/guides/python-project.mdx +28 -25
- package/docs/guides/react-website-auth.mdx +8 -8
- package/docs/guides/react-website.mdx +46 -27
- package/docs/guides/runtime-config.mdx +24 -4
- package/docs/guides/security.mdx +1 -1
- package/docs/guides/terraform-project.mdx +8 -2
- package/docs/guides/trpc.mdx +96 -12
- package/docs/guides/ts-agent.mdx +17 -3
- package/docs/guides/ts-dcr-proxy.mdx +24 -6
- package/docs/guides/ts-lambda-function.mdx +7 -1
- package/docs/guides/ts-mcp-server.mdx +45 -15
- package/docs/guides/ts-rdb.mdx +9 -2
- package/docs/guides/ts-smithy-api.mdx +76 -7
- package/docs/guides/typescript-infrastructure.mdx +24 -10
- package/docs/guides/typescript-project.mdx +12 -5
- package/docs/guides/workspace.mdx +21 -9
- package/docs/snippets/api/type-safe-api-integrations.mdx +2 -0
- package/docs/snippets/connection/a2a-infrastructure.mdx +3 -0
- package/docs/snippets/connection/infra-project-prerequisite.mdx +8 -0
- package/docs/snippets/connection/strands-agent-rdb-ssl-requirements.mdx +1 -1
- package/docs/snippets/connection/ts-lambda-rdb-ssl-requirements.mdx +1 -1
- package/docs/snippets/connection/ts-mcp-server-rdb-ssl-requirements.mdx +1 -1
- package/docs/snippets/required-prerequisites.mdx +1 -1
- package/package.json +1 -1
- package/src/init/schema.json +5 -0
- package/src/py/project/schema.json +3 -1
|
@@ -38,9 +38,13 @@ The generator will add the following files to your project:
|
|
|
38
38
|
- \<project-name>
|
|
39
39
|
- src/
|
|
40
40
|
- \<lambda-function>.ts Function implementation
|
|
41
|
+
- rolldown.config.ts [Bundling](#bundling) configuration for the function
|
|
42
|
+
- .gitignore Ignores the temporary configs Rolldown writes
|
|
41
43
|
|
|
42
44
|
</FileTree>
|
|
43
45
|
|
|
46
|
+
The generator also adds a `bundle` target to the project's `project.json`, and the Powertools, Middy and Zod runtime dependencies the handler imports to its `package.json`.
|
|
47
|
+
|
|
44
48
|
If the `functionPath` option is provided, the generator will add the handler to the specified path within the project source directory:
|
|
45
49
|
|
|
46
50
|
<FileTree>
|
|
@@ -78,6 +82,7 @@ The main function implementation is in `<function-name>.ts`. Here's an example:
|
|
|
78
82
|
```typescript
|
|
79
83
|
import { parser } from '@aws-lambda-powertools/parser/middleware';
|
|
80
84
|
import { EventBridgeSchema } from '@aws-lambda-powertools/parser/schemas';
|
|
85
|
+
import { z } from 'zod';
|
|
81
86
|
import middy from '@middy/core';
|
|
82
87
|
import { Tracer } from '@aws-lambda-powertools/tracer';
|
|
83
88
|
import { captureLambdaHandler } from '@aws-lambda-powertools/tracer/middleware';
|
|
@@ -85,7 +90,8 @@ import { injectLambdaContext } from '@aws-lambda-powertools/logger/middleware';
|
|
|
85
90
|
import { Logger } from '@aws-lambda-powertools/logger';
|
|
86
91
|
import { Metrics } from '@aws-lambda-powertools/metrics';
|
|
87
92
|
import { logMetrics } from '@aws-lambda-powertools/metrics/middleware';
|
|
88
|
-
import {
|
|
93
|
+
import type { Context } from 'aws-lambda';
|
|
94
|
+
export type { Context };
|
|
89
95
|
|
|
90
96
|
process.env.POWERTOOLS_METRICS_NAMESPACE = 'MyFunction';
|
|
91
97
|
process.env.POWERTOOLS_SERVICE_NAME = 'MyFunction';
|
|
@@ -88,16 +88,20 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
88
88
|
import { z } from 'zod';
|
|
89
89
|
|
|
90
90
|
export const registerMyTool = (server: McpServer) => {
|
|
91
|
-
server.registerTool(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
server.registerTool(
|
|
92
|
+
'toolName',
|
|
93
|
+
{
|
|
94
|
+
description: 'tool description',
|
|
95
|
+
// Input schema using Zod
|
|
96
|
+
inputSchema: { param1: z.string(), param2: z.number() },
|
|
97
|
+
},
|
|
95
98
|
async ({ param1, param2 }) => {
|
|
96
99
|
// Tool implementation
|
|
100
|
+
const result = `${param1} ${param2}`;
|
|
97
101
|
return {
|
|
98
|
-
content: [{ type:
|
|
102
|
+
content: [{ type: 'text' as const, text: result }],
|
|
99
103
|
};
|
|
100
|
-
}
|
|
104
|
+
},
|
|
101
105
|
);
|
|
102
106
|
};
|
|
103
107
|
```
|
|
@@ -123,20 +127,46 @@ Resources provide context to the AI assistant. Like tools, each resource lives i
|
|
|
123
127
|
```typescript title="resources/my-resource.ts"
|
|
124
128
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
125
129
|
|
|
130
|
+
const fetchSomeData = async (): Promise<string> => 'some dynamic context';
|
|
131
|
+
|
|
126
132
|
export const registerMyResource = (server: McpServer) => {
|
|
127
133
|
const exampleContext = 'some context to return';
|
|
128
134
|
|
|
129
|
-
server.registerResource(
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
server.registerResource(
|
|
136
|
+
'resource-name',
|
|
137
|
+
'example://resource',
|
|
138
|
+
{},
|
|
139
|
+
async (uri) => ({
|
|
140
|
+
contents: [{ uri: uri.href, text: exampleContext }],
|
|
141
|
+
}),
|
|
142
|
+
);
|
|
132
143
|
|
|
133
144
|
// Dynamic resource
|
|
134
|
-
server.registerResource(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
145
|
+
server.registerResource(
|
|
146
|
+
'dynamic-resource',
|
|
147
|
+
'dynamic://resource',
|
|
148
|
+
{},
|
|
149
|
+
async (uri) => {
|
|
150
|
+
const data = await fetchSomeData();
|
|
151
|
+
return {
|
|
152
|
+
contents: [{ uri: uri.href, text: data }],
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Register it inside `createServer` in `server.ts` the same way as a tool:
|
|
160
|
+
|
|
161
|
+
```typescript title="server.ts" {6}
|
|
162
|
+
import { registerMyResource } from './resources/my-resource.js';
|
|
163
|
+
|
|
164
|
+
export const createServer = async () => {
|
|
165
|
+
const server = new McpServer({ name: 'my-server', version: '1.0.0' });
|
|
166
|
+
|
|
167
|
+
registerMyResource(server);
|
|
168
|
+
|
|
169
|
+
return server;
|
|
140
170
|
};
|
|
141
171
|
```
|
|
142
172
|
|
package/docs/guides/ts-rdb.mdx
CHANGED
|
@@ -45,11 +45,18 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
45
45
|
- create-db-user-handler.ts Lambda handler used to create the application database user during deployment
|
|
46
46
|
- migration-handler.ts Lambda handler used to run database migrations during deployment
|
|
47
47
|
- .gitignore Git ignore entries including generated Prisma client output
|
|
48
|
+
- .trivyignore Vulnerability IDs to suppress when scanning the migration image
|
|
48
49
|
- config.json Local development connection details and runtime config key
|
|
49
50
|
- Dockerfile Container image definition for the migration handler
|
|
50
51
|
- package.json Project manifest defining the project's package name and dependencies
|
|
51
52
|
- project.json Project configuration and build targets
|
|
52
53
|
- prisma.config.ts Configuration for Prisma CLI
|
|
54
|
+
- README.md Project readme
|
|
55
|
+
- rolldown.config.ts Bundler configuration invoked by the `bundle` target
|
|
56
|
+
- tsconfig.json TypeScript project references
|
|
57
|
+
- tsconfig.lib.json TypeScript configuration for the library build
|
|
58
|
+
- tsconfig.spec.json TypeScript configuration for tests
|
|
59
|
+
- vitest.config.mts Vitest configuration
|
|
53
60
|
</FileTree>
|
|
54
61
|
|
|
55
62
|
Local development scripts are shared across all database projects and generated into `packages/common/scripts/`:
|
|
@@ -264,7 +271,7 @@ module "api" {
|
|
|
264
271
|
source = "..."
|
|
265
272
|
...
|
|
266
273
|
|
|
267
|
-
|
|
274
|
+
env = {
|
|
268
275
|
NODE_EXTRA_CA_CERTS = "/var/runtime/ca-cert.pem"
|
|
269
276
|
}
|
|
270
277
|
}
|
|
@@ -342,7 +349,7 @@ export const listExampleTable = publicProcedure
|
|
|
342
349
|
|
|
343
350
|
**Option 2: tRPC middleware**
|
|
344
351
|
|
|
345
|
-
If you are using the
|
|
352
|
+
If you are using the <Link path="guides/connection/trpc-rdb#using-the-middleware">middleware pattern</Link>, add the `$disconnect()` call to the middleware so all procedures built on it are covered automatically:
|
|
346
353
|
|
|
347
354
|
```ts title="packages/api/src/middleware/db.ts"
|
|
348
355
|
import { getPrisma } from '@my-scope/db';
|
|
@@ -18,6 +18,8 @@ import PackageManagerShortCommand from '@components/package-manager-short-comman
|
|
|
18
18
|
import Infrastructure from '@components/infrastructure.astro';
|
|
19
19
|
import Snippet from '@components/snippet.astro';
|
|
20
20
|
import OptionFilter from '@components/option-filter.astro';
|
|
21
|
+
import InstallCommand from '@components/install-command.astro';
|
|
22
|
+
import { TS_VERSIONS } from '../../../../../../packages/nx-plugin/src/utils/versions';
|
|
21
23
|
|
|
22
24
|
[Smithy](https://smithy.io/) is a protocol-agnostic interface definition language for authoring APIs in a model driven fashion.
|
|
23
25
|
|
|
@@ -46,7 +48,6 @@ The generator creates two related projects in the `<directory>/<api-name>` direc
|
|
|
46
48
|
<FileTree>
|
|
47
49
|
|
|
48
50
|
- **model/** Smithy model project
|
|
49
|
-
- package.json Project manifest defining the project's package name and dependencies
|
|
50
51
|
- project.json Project configuration and build targets
|
|
51
52
|
- smithy-build.json Smithy build configuration
|
|
52
53
|
- ssdk.rolldown.config.mjs Bundles the generated TypeScript Server SDK
|
|
@@ -55,9 +56,15 @@ The generator creates two related projects in the `<directory>/<api-name>` direc
|
|
|
55
56
|
- operations/
|
|
56
57
|
- echo.smithy Example operation definition
|
|
57
58
|
- **backend/** TypeScript backend implementation
|
|
59
|
+
- package.json Project manifest defining the project's package name and dependencies
|
|
58
60
|
- project.json Project configuration and build targets
|
|
59
61
|
- rolldown.config.ts Bundle configuration
|
|
62
|
+
- tsconfig.json TypeScript configuration
|
|
63
|
+
- tsconfig.lib.json TypeScript configuration for the library sources
|
|
64
|
+
- tsconfig.spec.json TypeScript configuration for the tests
|
|
65
|
+
- vitest.config.mts Vitest configuration
|
|
60
66
|
- src/
|
|
67
|
+
- index.ts Package entrypoint
|
|
61
68
|
- handler.ts AWS Lambda handler
|
|
62
69
|
- local-server.ts Local development server
|
|
63
70
|
- service.ts Service implementation
|
|
@@ -91,7 +98,7 @@ The common infrastructure as code project is structured as follows:
|
|
|
91
98
|
</FileTree>
|
|
92
99
|
|
|
93
100
|
:::note[Generated Project]
|
|
94
|
-
This project is generated using the
|
|
101
|
+
This project is generated using the <Link path="/guides/typescript-project">`ts#project`</Link> generator and therefore configures the same build targets.
|
|
95
102
|
:::
|
|
96
103
|
</Fragment>
|
|
97
104
|
<Fragment slot="terraform">
|
|
@@ -110,7 +117,7 @@ This project is generated using the [`ts#project`](guides/typescript-project) ge
|
|
|
110
117
|
</FileTree>
|
|
111
118
|
|
|
112
119
|
:::note[Generated Project]
|
|
113
|
-
This project is generated using the
|
|
120
|
+
This project is generated using the <Link path="/guides/terraform-project">`terraform#project`</Link> generator and therefore configures the same build targets.
|
|
114
121
|
:::
|
|
115
122
|
</Fragment>
|
|
116
123
|
</Infrastructure>
|
|
@@ -475,7 +482,9 @@ export interface ServiceContext {
|
|
|
475
482
|
Next, write the resolver in `src/identity.ts`. It throws `UnauthorizedError` when the caller cannot be determined. The implementation depends on your selected `auth` method:
|
|
476
483
|
|
|
477
484
|
<OptionFilter when={{ auth: 'iam' }} description="Identity resolution for IAM-authenticated APIs">
|
|
478
|
-
For `IAM` authentication, we look up the caller in Cognito using the sub extracted from the API Gateway event:
|
|
485
|
+
For `IAM` authentication, we look up the caller in Cognito using the sub extracted from the API Gateway event. The lookup uses the Cognito Identity Provider client, which is not a dependency of a generated Smithy backend, so install it into the backend project first:
|
|
486
|
+
|
|
487
|
+
<InstallCommand pkg={`@aws-sdk/client-cognito-identity-provider@${TS_VERSIONS['@aws-sdk/client-cognito-identity-provider']}`} project="@my-scope/my-api" projectDir="packages/my-api/backend" />
|
|
479
488
|
|
|
480
489
|
```ts
|
|
481
490
|
import { CognitoIdentityProvider } from '@aws-sdk/client-cognito-identity-provider';
|
|
@@ -498,7 +507,9 @@ export const getIdentity = async (
|
|
|
498
507
|
}
|
|
499
508
|
|
|
500
509
|
if (!sub) {
|
|
501
|
-
throw new UnauthorizedError({
|
|
510
|
+
throw new UnauthorizedError({
|
|
511
|
+
message: 'Unable to determine calling user',
|
|
512
|
+
});
|
|
502
513
|
}
|
|
503
514
|
|
|
504
515
|
const { Users } = await cognito.listUsers({
|
|
@@ -509,7 +520,9 @@ export const getIdentity = async (
|
|
|
509
520
|
});
|
|
510
521
|
|
|
511
522
|
if (!Users || Users.length !== 1) {
|
|
512
|
-
throw new UnauthorizedError({
|
|
523
|
+
throw new UnauthorizedError({
|
|
524
|
+
message: `No user found with subjectId ${sub}`,
|
|
525
|
+
});
|
|
513
526
|
}
|
|
514
527
|
|
|
515
528
|
return { sub, username: Users[0].Username! };
|
|
@@ -536,7 +549,9 @@ export const getIdentity = async (
|
|
|
536
549
|
const username = claims?.username;
|
|
537
550
|
|
|
538
551
|
if (!sub || !username) {
|
|
539
|
-
throw new UnauthorizedError({
|
|
552
|
+
throw new UnauthorizedError({
|
|
553
|
+
message: 'Unable to determine calling user',
|
|
554
|
+
});
|
|
540
555
|
}
|
|
541
556
|
|
|
542
557
|
return { sub, username };
|
|
@@ -562,6 +577,17 @@ const httpResponse = await serviceHandler.handle(httpRequest, {
|
|
|
562
577
|
});
|
|
563
578
|
```
|
|
564
579
|
|
|
580
|
+
`getIdentity` is a required field on `ServiceContext`, and as the [caution above](#service-context) notes the context is constructed in **both** entrypoints — so `src/local-server.ts` needs it too. There is no API Gateway authorizer in front of the local server, so supply a stub identity for local development:
|
|
581
|
+
|
|
582
|
+
```ts {5} ins={5}
|
|
583
|
+
const httpResponse = await serviceHandler.handle(httpRequest, {
|
|
584
|
+
tracer,
|
|
585
|
+
logger,
|
|
586
|
+
metrics,
|
|
587
|
+
getIdentity: async () => ({ sub: 'local', username: 'local' }),
|
|
588
|
+
});
|
|
589
|
+
```
|
|
590
|
+
|
|
565
591
|
We can now use the resolved identity in an operation, for example in `src/operations/echo.ts`:
|
|
566
592
|
|
|
567
593
|
```ts
|
|
@@ -801,6 +827,49 @@ output "lambda_function_name" {
|
|
|
801
827
|
|
|
802
828
|
### Integrations
|
|
803
829
|
|
|
830
|
+
<Infrastructure>
|
|
831
|
+
<Fragment slot="cdk">
|
|
832
|
+
:::caution[Operation names are camelCase in CDK]
|
|
833
|
+
Smithy operations are declared in PascalCase (`Echo`), and your backend exports them under that name. The CDK integration keys are the **camelCase** form of the same name, so an operation `Echo` is `echo` everywhere in your stack:
|
|
834
|
+
|
|
835
|
+
```ts
|
|
836
|
+
const api = new MyApi(this, 'MyApi', {
|
|
837
|
+
integrations: MyApi.defaultIntegrations(this)
|
|
838
|
+
// `Echo` in the model, `echo` here
|
|
839
|
+
.withOperationOptions({ echo: { timeout: Duration.seconds(60) } })
|
|
840
|
+
.build(),
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
api.integrations.echo.handler.addToRolePolicy(...);
|
|
844
|
+
```
|
|
845
|
+
:::
|
|
846
|
+
</Fragment>
|
|
847
|
+
<Fragment slot="terraform">
|
|
848
|
+
:::note[Operation names are camelCase in Terraform]
|
|
849
|
+
The generated module's operation-keyed outputs and its `operations.json` use the **camelCase** form of the Smithy operation name, so a Smithy operation `Echo` is keyed `echo`:
|
|
850
|
+
|
|
851
|
+
```hcl
|
|
852
|
+
# `Echo` in the model, `echo` here
|
|
853
|
+
resource "aws_iam_role_policy" "echo_permissions" {
|
|
854
|
+
name = "echo-additional-permissions"
|
|
855
|
+
role = module.my_api.lambda_execution_role_names["echo"]
|
|
856
|
+
|
|
857
|
+
policy = jsonencode({
|
|
858
|
+
Version = "2012-10-17"
|
|
859
|
+
Statement = [
|
|
860
|
+
{
|
|
861
|
+
Effect = "Allow"
|
|
862
|
+
Action = ["s3:GetObject"]
|
|
863
|
+
Resource = "arn:aws:s3:::my-bucket/*"
|
|
864
|
+
}
|
|
865
|
+
]
|
|
866
|
+
})
|
|
867
|
+
}
|
|
868
|
+
```
|
|
869
|
+
:::
|
|
870
|
+
</Fragment>
|
|
871
|
+
</Infrastructure>
|
|
872
|
+
|
|
804
873
|
<Snippet name="api/type-safe-api-integrations" parentHeading="Integrations" />
|
|
805
874
|
|
|
806
875
|
#### Code Generation
|
|
@@ -44,7 +44,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
44
44
|
|
|
45
45
|
</FileTree>
|
|
46
46
|
|
|
47
|
-
If you
|
|
47
|
+
If you generate with `--stageConfig=true`, the generator also creates two shared packages for centralized credential management (if they don't already exist):
|
|
48
48
|
|
|
49
49
|
<FileTree>
|
|
50
50
|
|
|
@@ -53,12 +53,17 @@ If you set the `stageConfig` option, the generator also creates two shared packa
|
|
|
53
53
|
- src
|
|
54
54
|
- stages.types.ts Type definitions for stage credentials and config
|
|
55
55
|
- stages.config.ts Your stage-to-credential mappings (edit this)
|
|
56
|
+
- resolve-stage.ts The `resolveStage` lookup your `main.ts` imports
|
|
56
57
|
- index.ts Re-exports for importing from other packages
|
|
58
|
+
- README.md
|
|
57
59
|
- scripts Centralized deploy/destroy scripts
|
|
58
60
|
- src
|
|
59
|
-
- infra
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
- infra
|
|
62
|
+
- infra-deploy.ts Deploy bin script
|
|
63
|
+
- infra-destroy.ts Destroy bin script
|
|
64
|
+
- index.ts Re-exports for importing from other packages
|
|
65
|
+
- stage-credentials/ Shared logic (credential lookup, CDK command building)
|
|
66
|
+
- README.md
|
|
62
67
|
|
|
63
68
|
</FileTree>
|
|
64
69
|
|
|
@@ -164,7 +169,11 @@ export class ApplicationStage extends Stage {
|
|
|
164
169
|
### Stage Credential Configuration
|
|
165
170
|
|
|
166
171
|
:::note[Staged Configuration]
|
|
167
|
-
This section applies when you generate with `stageConfig
|
|
172
|
+
This section applies when you generate with `stageConfig`:
|
|
173
|
+
|
|
174
|
+
<NxCommands commands={['g @aws/nx-plugin:ts#infra --name=infra --stageConfig=true']} />
|
|
175
|
+
|
|
176
|
+
Without it, the generator produces a simpler setup where you manage AWS credentials yourself (e.g., by exporting `AWS_PROFILE` before deploying).
|
|
168
177
|
:::
|
|
169
178
|
|
|
170
179
|
When you have multiple stages targeting different AWS accounts, managing credentials manually can be error-prone, especially as the number of stages grows.
|
|
@@ -263,8 +272,13 @@ Shared stages (under `shared.stages`) apply to any infra project in the workspac
|
|
|
263
272
|
|
|
264
273
|
Project-specific stages (under `projects['packages/infra'].stages`) only apply to that project. When both exist for the same stage name, the project-specific entry takes priority.
|
|
265
274
|
|
|
266
|
-
:::
|
|
267
|
-
|
|
275
|
+
:::note[Commit Stage Config]
|
|
276
|
+
If you wish to commit `stages.config.ts` so the team shares a single source of truth for stage credentials, credential scanning may flag any AWS Account IDs specified in this file. You can suppress this in `.gitallowed` as follows:
|
|
277
|
+
|
|
278
|
+
```text title=".gitallowed"
|
|
279
|
+
# Allow AWS Account IDs in the stage configuration
|
|
280
|
+
stages\.config\.ts:[0-9]+:.*[0-9]{12}
|
|
281
|
+
```
|
|
268
282
|
:::
|
|
269
283
|
|
|
270
284
|
### API Infrastructure
|
|
@@ -382,7 +396,7 @@ Your project has three deploy targets, each suited to a different situation:
|
|
|
382
396
|
| Target | Use it for |
|
|
383
397
|
| ---------------- | ------------------------------------------------------------------------------------------------------ |
|
|
384
398
|
| `deploy-sandbox` | Deploying your own sandbox stage during development. No stage argument needed. Uses express mode. |
|
|
385
|
-
| `deploy` | Deploying any stage, by naming the stage or stacks you want.
|
|
399
|
+
| `deploy` | Deploying any stage, by naming the stage or stacks you want. Waits for full stabilization. |
|
|
386
400
|
| `deploy-ci` | Deploying from a CI/CD pipeline, using a pre-synthesized cloud assembly. Waits for full stabilization. |
|
|
387
401
|
|
|
388
402
|
`deploy-sandbox` and `deploy` depend on `^assemble`, so they build the artifacts they are about to deploy and nothing else. `deploy-ci` deploys an assembly your pipeline already built, so it has no build dependencies at all.
|
|
@@ -419,7 +433,7 @@ You can specify any stage so long as it is defined in `main.ts`. To deploy an in
|
|
|
419
433
|
|
|
420
434
|
<NxCommands commands={['deploy <my-infra> <my-infra>-sandbox/Application']} />
|
|
421
435
|
|
|
422
|
-
Since this target can name any stage, including your production one, it waits for full resource stabilization
|
|
436
|
+
Since this target can name any stage, including your production one, it waits for full resource stabilization. Pass `--express` to opt into express mode for a stage you are iterating on.
|
|
423
437
|
|
|
424
438
|
## Deploying to AWS in a CI/CD Pipeline
|
|
425
439
|
|
|
@@ -427,7 +441,7 @@ Use the `deploy-ci` target if you are deploying to AWS as part of a CI/CD pipeli
|
|
|
427
441
|
|
|
428
442
|
<NxCommands commands={['deploy-ci <my-infra> my-stage/*']} />
|
|
429
443
|
|
|
430
|
-
This target
|
|
444
|
+
This target deploys a pre-synthesized cloud assembly rather than synthesizing on the fly, avoiding potential non-determinism from package version changes and ensuring that every pipeline stage deploys using the same cloud assembly. Like `deploy`, it waits for every resource to fully stabilize before reporting success, and unlike `deploy` it accepts no `--express` opt-out.
|
|
431
445
|
|
|
432
446
|
## Tearing Down AWS Infrastructure
|
|
433
447
|
|
|
@@ -34,6 +34,7 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
34
34
|
|
|
35
35
|
- src TypeScript source code
|
|
36
36
|
- index.ts
|
|
37
|
+
- README.md
|
|
37
38
|
- package.json Project manifest defining the project's package name and dependencies
|
|
38
39
|
- project.json Project configuration and build targets
|
|
39
40
|
- tsconfig.json Base TypeScript configuration for this project (extends workspace root tsconfig.base.json)
|
|
@@ -54,6 +55,10 @@ You will also notice some changes to the following files in your workspace root:
|
|
|
54
55
|
- nx.json Nx configuration is updated to configure the @nx/js/typescript plugin for your project
|
|
55
56
|
- tsconfig.base.json a TypeScript alias is set up for your project so that it can be imported by other projects in your workspace
|
|
56
57
|
- tsconfig.json a TypeScript project reference is added for your project
|
|
58
|
+
- vitest.config.mts the shared Vitest configuration your project's own vitest.config.mts extends (created by the first TypeScript project)
|
|
59
|
+
- package.json shared build and test tooling is added
|
|
60
|
+
- pnpm-workspace.yaml the project is added to the workspace, and dependency versions to the [catalog](#catalogs) (the equivalent file for your package manager)
|
|
61
|
+
- .gitignore build and test output paths are ignored
|
|
57
62
|
|
|
58
63
|
</FileTree>
|
|
59
64
|
|
|
@@ -270,11 +275,14 @@ You can achieve this by adding a target such as the following to your `project.j
|
|
|
270
275
|
...
|
|
271
276
|
"bundle": {
|
|
272
277
|
"cache": true,
|
|
278
|
+
"inputs": ["default"],
|
|
273
279
|
"executor": "nx:run-commands",
|
|
274
280
|
"outputs": ["{workspaceRoot}/dist/packages/my-library/bundle"],
|
|
275
281
|
"options": {
|
|
276
|
-
"command": "rolldown -c rolldown.config.ts"
|
|
277
|
-
|
|
282
|
+
"command": "rolldown -c rolldown.config.ts",
|
|
283
|
+
"cwd": "{projectRoot}"
|
|
284
|
+
},
|
|
285
|
+
"dependsOn": ["compile"]
|
|
278
286
|
},
|
|
279
287
|
},
|
|
280
288
|
}
|
|
@@ -288,12 +296,14 @@ import { defineConfig } from 'rolldown';
|
|
|
288
296
|
|
|
289
297
|
export default defineConfig([
|
|
290
298
|
{
|
|
299
|
+
tsconfig: 'tsconfig.lib.json',
|
|
291
300
|
input: 'src/index.ts',
|
|
292
301
|
output: {
|
|
293
302
|
file: '../../dist/packages/my-library/bundle/index.js',
|
|
294
303
|
format: 'cjs',
|
|
295
304
|
codeSplitting: false,
|
|
296
305
|
},
|
|
306
|
+
platform: 'node',
|
|
297
307
|
},
|
|
298
308
|
]);
|
|
299
309
|
```
|
|
@@ -366,13 +376,10 @@ Vitest provides Jest-like syntax for defining tests, with utilities such as `des
|
|
|
366
376
|
import { sayHello } from './hello.js';
|
|
367
377
|
|
|
368
378
|
describe('sayHello', () => {
|
|
369
|
-
|
|
370
379
|
it('should greet the caller', () => {
|
|
371
380
|
expect(sayHello('Darth Vader')).toBe('Hello, Darth Vader!');
|
|
372
381
|
});
|
|
373
|
-
|
|
374
382
|
});
|
|
375
|
-
|
|
376
383
|
```
|
|
377
384
|
|
|
378
385
|
For more details about how to write tests, and features such as mocking dependencies, refer to the [Vitest documentation](https://vitest.dev/guide/#writing-tests)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
title: Workspace
|
|
3
3
|
description: Reference documentation for workspaces
|
|
4
4
|
---
|
|
5
|
-
import { FileTree } from '@astrojs/starlight/components';
|
|
5
|
+
import { Aside, 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';
|
|
@@ -29,6 +29,7 @@ When you create a new workspace with `@aws/nx-plugin`, the preset generator sets
|
|
|
29
29
|
- tsconfig.base.json Root TypeScript configuration
|
|
30
30
|
- aws-nx-plugin.config.mts Nx Plugin for AWS configuration
|
|
31
31
|
- .git-secrets/ Vendored git-secrets bash script for credential scanning
|
|
32
|
+
- .gitallowed Patterns git-secrets treats as false positives
|
|
32
33
|
- .husky/ Git hooks
|
|
33
34
|
- .mcp.json Nx Plugin for AWS MCP server configuration for Claude Code
|
|
34
35
|
- .cursor/mcp.json ...and for Cursor
|
|
@@ -167,21 +168,26 @@ New workspaces are configured with [Biome](https://biomejs.dev/) for static anal
|
|
|
167
168
|
|
|
168
169
|
### Git Secrets
|
|
169
170
|
|
|
170
|
-
|
|
171
|
+
Workspaces are set up with [git-secrets](https://github.com/awslabs/git-secrets) pre-commit hooks that scan staged files for AWS credential patterns before each commit. This prevents accidentally committing access keys, secret keys, and other sensitive values.
|
|
172
|
+
|
|
173
|
+
The script is vendored into the workspace at `.git-secrets/git-secrets` and run by the `.husky/pre-commit` hook, so there is nothing to install — but it is not on your `PATH`, so invoke it by path rather than as `git secrets`.
|
|
171
174
|
|
|
172
175
|
#### Suppressing False Positives
|
|
173
176
|
|
|
174
177
|
Patterns in git-secrets use [egrep-compatible regular expressions](https://github.com/awslabs/git-secrets#options-for-add). If git-secrets blocks a commit that does not contain real credentials:
|
|
175
178
|
|
|
176
179
|
```sh
|
|
177
|
-
# Allow a specific regex pattern
|
|
178
|
-
git
|
|
180
|
+
# Allow a specific regex pattern (-a is the allowed flag)
|
|
181
|
+
bash .git-secrets/git-secrets --add -a -- 'my-regex-pattern'
|
|
182
|
+
|
|
183
|
+
# Allow a literal string, escaping special characters (-l is the literal flag)
|
|
184
|
+
bash .git-secrets/git-secrets --add -a -l -- 'my-literal+string'
|
|
179
185
|
|
|
180
|
-
#
|
|
181
|
-
git
|
|
186
|
+
# List what is currently allowed
|
|
187
|
+
git config --get-all secrets.allowed
|
|
182
188
|
```
|
|
183
189
|
|
|
184
|
-
|
|
190
|
+
These are recorded in your local git config, so they apply only to your own clone. To share a suppression with your team, add it to the `.gitallowed` file at the repository root instead — one egrep-compatible regex per line, matched against `<path>:<line-number>:<line-contents>`:
|
|
185
191
|
|
|
186
192
|
```text title=".gitallowed"
|
|
187
193
|
# Allow test fixtures
|
|
@@ -194,7 +200,7 @@ For full details on managing patterns, see the [git-secrets documentation](https
|
|
|
194
200
|
|
|
195
201
|
## Nx Plugin for AWS Configuration
|
|
196
202
|
|
|
197
|
-
The workspace ships with an `aws-nx-plugin.config.mts` file at the root. Generators read this file to pick sensible defaults so you don't have to pass the same flags every time
|
|
203
|
+
The workspace ships with an `aws-nx-plugin.config.mts` file at the root. Generators read this file to pick sensible defaults so you don't have to pass the same flags every time:
|
|
198
204
|
|
|
199
205
|
```typescript
|
|
200
206
|
// aws-nx-plugin.config.mts
|
|
@@ -207,10 +213,16 @@ export default {
|
|
|
207
213
|
containers: {
|
|
208
214
|
engine: 'docker', // or 'finch'
|
|
209
215
|
},
|
|
216
|
+
packageManager: {
|
|
217
|
+
catalogs: true, // or false
|
|
218
|
+
},
|
|
210
219
|
} satisfies AwsNxPluginConfig;
|
|
211
220
|
```
|
|
212
221
|
|
|
213
222
|
- **`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.
|
|
214
223
|
- **`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.
|
|
224
|
+
- **`packageManager.catalogs`** — whether generators record dependency versions in the package manager's catalog and reference them with the `catalog:` protocol (see [Single Version Policy](#single-version-policy)). Set it to `false` to have generators write direct version ranges into each project's `package.json` instead. It has no effect on npm, which has no catalog.
|
|
225
|
+
|
|
226
|
+
The <Link path="guides/license">license generator</Link> adds a `license` key to this same file to configure its own behaviour.
|
|
215
227
|
|
|
216
|
-
You can edit
|
|
228
|
+
You can edit any setting at any time — subsequent generator runs will pick up the new value.
|
|
@@ -66,6 +66,8 @@ const api = new MyApi(this, 'MyApi', {
|
|
|
66
66
|
|
|
67
67
|
api.integrations.$router.handler.addEnvironment('LOG_LEVEL', 'DEBUG');
|
|
68
68
|
```
|
|
69
|
+
|
|
70
|
+
Note that `$router` is no longer available if you override every operation via `withOverrides`, since no operation is left using the default router integration.
|
|
69
71
|
</Fragment>
|
|
70
72
|
<Fragment slot="terraform">
|
|
71
73
|
With the `isolated` pattern, the module's outputs are maps keyed by operation name, so you can reach a single operation's resources. For example, to grant one operation's Lambda function extra permissions:
|
|
@@ -3,9 +3,12 @@ title: A2A Connection Infrastructure
|
|
|
3
3
|
---
|
|
4
4
|
import Link from '@components/link.astro';
|
|
5
5
|
import Infrastructure from '@components/infrastructure.astro';
|
|
6
|
+
import Snippet from '@components/snippet.astro';
|
|
6
7
|
|
|
7
8
|
After running the connection generator, you need to grant the host agent permission to invoke the remote A2A agent.
|
|
8
9
|
|
|
10
|
+
<Snippet name="connection/infra-project-prerequisite" />
|
|
11
|
+
|
|
9
12
|
<Infrastructure>
|
|
10
13
|
<Fragment slot="cdk">
|
|
11
14
|
```ts title="packages/infra/src/stacks/application-stack.ts" {5}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Infrastructure Project Prerequisite
|
|
3
|
+
---
|
|
4
|
+
import Link from '@components/link.astro';
|
|
5
|
+
|
|
6
|
+
:::note[Infrastructure project required]
|
|
7
|
+
The agent, MCP server and Gateway generators vend their constructs and modules into `packages/common`, but they do not create an application to deploy them from — so `packages/infra` does not exist until you generate it. Run the <Link path="guides/typescript-infrastructure">`ts#infra`</Link> generator (CDK) or the <Link path="guides/terraform-project">`terraform#project`</Link> generator (Terraform) before editing the file below.
|
|
8
|
+
:::
|
|
@@ -5,5 +5,5 @@ title: Required Prerequisites
|
|
|
5
5
|
- [Node >= 22](https://nodejs.org/en/download) (We recommend using something like [NVM](https://github.com/nvm-sh/nvm) to manage your node versions)
|
|
6
6
|
- verify by running `node --version`
|
|
7
7
|
- [UV >= 0.5.29](https://docs.astral.sh/uv/getting-started/installation/)
|
|
8
|
-
1. install Python 3.14 by running: `uv python install 3.14
|
|
8
|
+
1. install Python 3.14 by running: `uv python install 3.14`
|
|
9
9
|
2. verify with `uv python list --only-installed`
|
package/package.json
CHANGED
package/src/init/schema.json
CHANGED
|
@@ -13,6 +13,11 @@
|
|
|
13
13
|
"x-priority": "important",
|
|
14
14
|
"x-prompt": "Which provider would you like to manage your infrastructure?"
|
|
15
15
|
},
|
|
16
|
+
"gitSecrets": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"description": "Whether to configure git-secrets to prevent committing AWS credentials.",
|
|
19
|
+
"default": true
|
|
20
|
+
},
|
|
16
21
|
"mcp": {
|
|
17
22
|
"type": "boolean",
|
|
18
23
|
"description": "Whether to configure the Nx Plugin for AWS MCP server for use by coding agents.",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
"type": "string",
|
|
33
33
|
"description": "Whether the project is an application or library",
|
|
34
34
|
"default": "application",
|
|
35
|
-
"enum": ["application", "library"]
|
|
35
|
+
"enum": ["application", "library"],
|
|
36
|
+
"x-priority": "important",
|
|
37
|
+
"x-prompt": "What type of Python project would you like to create?"
|
|
36
38
|
},
|
|
37
39
|
"moduleName": {
|
|
38
40
|
"type": "string",
|