@aws/nx-plugin-mcp 1.0.0-rc.8 → 1.0.0-rc.80

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 (196) hide show
  1. package/bin/aws-nx-mcp.js +14210 -13550
  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 +1578 -0
  9. package/docs/get_started/tutorials/dungeon-game/2.mdx +245 -0
  10. package/docs/get_started/tutorials/dungeon-game/3.mdx +66 -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/upgrading.mdx +147 -0
  15. package/docs/guides/agentcore-gateway.mdx +490 -0
  16. package/docs/guides/agentcore-harness.mdx +275 -0
  17. package/docs/guides/astro-docs.mdx +8 -0
  18. package/docs/guides/connection/agentcore-gateway-agent.mdx +222 -0
  19. package/docs/guides/connection/agentcore-gateway-gateway.mdx +154 -0
  20. package/docs/guides/connection/agentcore-gateway-mcp.mdx +134 -0
  21. package/docs/guides/connection/py-agent-a2a.mdx +48 -16
  22. package/docs/guides/connection/py-agent-dynamodb.mdx +116 -0
  23. package/docs/guides/connection/py-agent-gateway.mdx +182 -0
  24. package/docs/guides/connection/py-agent-mcp.mdx +43 -14
  25. package/docs/guides/connection/py-agent-rdb.mdx +178 -0
  26. package/docs/guides/connection/py-fast-api-dynamodb.mdx +56 -0
  27. package/docs/guides/connection/py-fast-api-rdb.mdx +184 -0
  28. package/docs/guides/connection/py-mcp-server-dynamodb.mdx +116 -0
  29. package/docs/guides/connection/py-mcp-server-rdb.mdx +187 -0
  30. package/docs/guides/connection/react-agentcore-gateway.mdx +112 -0
  31. package/docs/guides/connection/react-agui.mdx +33 -14
  32. package/docs/guides/connection/react-fastapi.mdx +39 -3
  33. package/docs/guides/connection/react-py-agent.mdx +10 -16
  34. package/docs/guides/connection/react-smithy.mdx +5 -5
  35. package/docs/guides/connection/react-trpc.mdx +2 -2
  36. package/docs/guides/connection/react-ts-agent.mdx +9 -9
  37. package/docs/guides/connection/smithy-dynamodb.mdx +6 -6
  38. package/docs/guides/connection/smithy-rdb.mdx +10 -10
  39. package/docs/guides/connection/trpc-dynamodb.mdx +5 -5
  40. package/docs/guides/connection/trpc-rdb.mdx +6 -6
  41. package/docs/guides/connection/ts-agent-a2a.mdx +14 -11
  42. package/docs/guides/connection/ts-agent-dynamodb.mdx +5 -5
  43. package/docs/guides/connection/ts-agent-gateway.mdx +147 -0
  44. package/docs/guides/connection/ts-agent-mcp.mdx +12 -9
  45. package/docs/guides/connection/ts-agent-rdb.mdx +70 -25
  46. package/docs/guides/connection/ts-mcp-server-dynamodb.mdx +5 -5
  47. package/docs/guides/connection/ts-mcp-server-rdb.mdx +68 -18
  48. package/docs/guides/connection.mdx +122 -5
  49. package/docs/guides/docker-bundling.mdx +81 -12
  50. package/docs/guides/fastapi.mdx +252 -15
  51. package/docs/guides/local-development.mdx +87 -0
  52. package/docs/guides/nx-generator.mdx +4 -3
  53. package/docs/guides/nx-migration.mdx +165 -0
  54. package/docs/guides/py-agent.mdx +332 -55
  55. package/docs/guides/py-dynamodb.mdx +476 -0
  56. package/docs/guides/py-mcp-server.mdx +57 -2
  57. package/docs/guides/py-rdb.mdx +265 -0
  58. package/docs/guides/python-lambda-function.mdx +1 -1
  59. package/docs/guides/react-website-auth.mdx +104 -5
  60. package/docs/guides/react-website.mdx +413 -99
  61. package/docs/guides/runtime-config.mdx +1 -1
  62. package/docs/guides/security.mdx +75 -0
  63. package/docs/guides/smithy-project.mdx +167 -0
  64. package/docs/guides/terraform-project.mdx +2 -2
  65. package/docs/guides/trpc.mdx +54 -17
  66. package/docs/guides/ts-agent.mdx +207 -23
  67. package/docs/guides/ts-dcr-proxy.mdx +569 -0
  68. package/docs/guides/ts-dynamodb.mdx +66 -242
  69. package/docs/guides/ts-lambda-function.mdx +1 -1
  70. package/docs/guides/ts-mcp-server.mdx +111 -29
  71. package/docs/guides/ts-nx-plugin.mdx +4 -4
  72. package/docs/guides/ts-rdb.mdx +114 -468
  73. package/docs/guides/ts-smithy-api.mdx +259 -19
  74. package/docs/guides/typescript-infrastructure.mdx +46 -24
  75. package/docs/guides/typescript-project.mdx +134 -27
  76. package/docs/guides/workspace.mdx +10 -3
  77. package/docs/snippets/agent/architecture.mdx +1 -1
  78. package/docs/snippets/agent/bedrock-deployment.mdx +9 -5
  79. package/docs/snippets/agent/runtime-arn.mdx +23 -2
  80. package/docs/snippets/agent/securing-your-agent.mdx +39 -0
  81. package/docs/snippets/api/access-logging.mdx +38 -0
  82. package/docs/snippets/api/cors-configuration-cdk-note.mdx +1 -1
  83. package/docs/snippets/api/cors-configuration-terraform-note.mdx +1 -1
  84. package/docs/snippets/api/type-safe-api-integrations.mdx +69 -50
  85. package/docs/snippets/api/waf-configuration.mdx +3 -3
  86. package/docs/snippets/connection/a2a-infrastructure.mdx +1 -1
  87. package/docs/snippets/connection/dynamodb-local-development.mdx +2 -2
  88. package/docs/snippets/connection/lambda-dynamodb-access.mdx +1 -1
  89. package/docs/snippets/connection/py-dynamodb-local-development.mdx +7 -0
  90. package/docs/snippets/connection/py-lambda-rdb-ssl-requirements.mdx +7 -0
  91. package/docs/snippets/connection/rdb-api-infrastructure.mdx +51 -19
  92. package/docs/snippets/dynamodb/deploying-table.mdx +145 -0
  93. package/docs/snippets/dynamodb/encryption-options.mdx +168 -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/mcp/shared-constructs.mdx +4 -5
  103. package/docs/snippets/pdk-migration/example/01-migrate-api.mdx +7 -5
  104. package/docs/snippets/pdk-migration/example/02-migrate-website.mdx +29 -10
  105. package/docs/snippets/pdk-migration/example/03-migrate-infra.mdx +4 -4
  106. package/docs/snippets/pdk-migration/faq/type-safe-api.mdx +5 -111
  107. package/docs/snippets/prerequisites.mdx +1 -4
  108. package/docs/snippets/rdb/architecture.mdx +38 -0
  109. package/docs/snippets/rdb/cluster-instances.mdx +31 -0
  110. package/docs/snippets/rdb/deletion-protection.mdx +34 -0
  111. package/docs/snippets/rdb/deploying.mdx +187 -0
  112. package/docs/snippets/rdb/encryption-key-rotation.mdx +30 -0
  113. package/docs/snippets/rdb/engine-version.mdx +63 -0
  114. package/docs/snippets/rdb/infrastructure.mdx +35 -0
  115. package/docs/snippets/rdb/logging-mysql.mdx +5 -0
  116. package/docs/snippets/rdb/logging-postgres.mdx +5 -0
  117. package/docs/snippets/rdb/performance-insights.mdx +34 -0
  118. package/docs/snippets/rdb/rds-proxy.mdx +50 -0
  119. package/docs/snippets/rdb/removal-policy.mdx +57 -0
  120. package/docs/snippets/rdb/serverless-capacity.mdx +32 -0
  121. package/docs/snippets/recommended-prerequisites.mdx +10 -0
  122. package/docs/snippets/required-prerequisites.mdx +1 -4
  123. package/docs/snippets/runtime-config-app-id-note.mdx +8 -0
  124. package/docs/snippets/shared-constructs.mdx +1 -1
  125. package/docs/snippets/trivy-image-scan.mdx +37 -0
  126. package/generators.json +162 -10
  127. package/package.json +1 -1
  128. package/src/agentcore-gateway/agent-connection/schema.json +31 -0
  129. package/src/agentcore-gateway/gateway-connection/schema.json +31 -0
  130. package/src/agentcore-gateway/mcp-connection/schema.json +31 -0
  131. package/src/agentcore-gateway/react-connection/schema.json +31 -0
  132. package/src/agentcore-gateway/schema.json +72 -0
  133. package/src/agentcore-harness/schema.json +53 -0
  134. package/src/connection/schema.json +5 -0
  135. package/src/infra/app/schema.json +5 -0
  136. package/src/init/schema.json +35 -0
  137. package/src/internal/test-matrix/schema.json +21 -0
  138. package/src/license/schema.json +5 -0
  139. package/src/preset/schema.json +16 -5
  140. package/src/py/agent/a2a-connection/schema.json +5 -0
  141. package/src/py/agent/gateway-connection/schema.json +31 -0
  142. package/src/py/agent/mcp-connection/schema.json +5 -0
  143. package/src/py/agent/react-connection/schema.json +5 -0
  144. package/src/py/agent/schema.json +15 -1
  145. package/src/py/api/schema.json +5 -0
  146. package/src/py/dynamodb/agent-connection/schema.json +27 -0
  147. package/src/py/dynamodb/fast-api-connection/schema.json +23 -0
  148. package/src/py/dynamodb/mcp-server-connection/schema.json +27 -0
  149. package/src/py/dynamodb/schema.json +76 -0
  150. package/src/py/fast-api/react/schema.json +5 -0
  151. package/src/py/fast-api/schema.json +6 -0
  152. package/src/py/lambda-function/schema.json +6 -1
  153. package/src/py/mcp-server/schema.json +6 -0
  154. package/src/py/project/schema.json +6 -0
  155. package/src/py/rdb/agent-connection/schema.json +27 -0
  156. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  157. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  158. package/src/py/rdb/schema.json +78 -0
  159. package/src/smithy/project/schema.json +28 -1
  160. package/src/smithy/react-connection/schema.json +5 -0
  161. package/src/smithy/ts/api/schema.json +6 -0
  162. package/src/terraform/project/schema.json +5 -0
  163. package/src/trpc/backend/schema.json +6 -0
  164. package/src/trpc/react/schema.json +5 -0
  165. package/src/ts/agent/a2a-connection/schema.json +5 -0
  166. package/src/ts/agent/gateway-connection/schema.json +31 -0
  167. package/src/ts/agent/mcp-connection/schema.json +5 -0
  168. package/src/ts/agent/react-connection/schema.json +5 -0
  169. package/src/ts/agent/schema.json +14 -0
  170. package/src/ts/api/schema.json +5 -0
  171. package/src/ts/astro-docs/schema.json +3 -3
  172. package/src/ts/dcr-proxy/schema.json +44 -0
  173. package/src/ts/docs/schema.json +3 -3
  174. package/src/ts/dynamodb/agent-connection/schema.json +5 -0
  175. package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
  176. package/src/ts/dynamodb/schema.json +26 -2
  177. package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
  178. package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
  179. package/src/ts/lambda-function/schema.json +5 -0
  180. package/src/ts/lib/schema.json +5 -0
  181. package/src/ts/mcp-server/schema.json +6 -0
  182. package/src/ts/nx-generator/schema.json +5 -0
  183. package/src/ts/nx-migration/schema.json +63 -0
  184. package/src/ts/nx-plugin/schema.json +5 -0
  185. package/src/ts/rdb/agent-connection/schema.json +5 -0
  186. package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
  187. package/src/ts/rdb/schema.json +7 -1
  188. package/src/ts/rdb/smithy-connection/schema.json +5 -0
  189. package/src/ts/rdb/trpc-connection/schema.json +5 -0
  190. package/src/ts/react-website/app/schema.json +12 -6
  191. package/src/ts/react-website/cognito-auth/schema.json +5 -0
  192. package/src/ts/react-website/runtime-config/schema.json +5 -0
  193. package/src/ts/website/app/schema.json +11 -6
  194. package/src/ts/website/auth/schema.json +5 -0
  195. /package/docs/snippets/connection/{lambda-rdb-ssl-requirements.mdx → ts-lambda-rdb-ssl-requirements.mdx} +0 -0
  196. /package/docs/snippets/connection/{mcp-server-rdb-ssl-requirements.mdx → ts-mcp-server-rdb-ssl-requirements.mdx} +0 -0
@@ -70,7 +70,7 @@ Generated constructs automatically write relevant configuration to the `connecti
70
70
  The `RuntimeConfig` CDK construct is a stage-scoped singleton. Use `set()` to write a key into a namespace:
71
71
 
72
72
  ```ts title="packages/infra/src/stacks/application-stack.ts"
73
- import { RuntimeConfig } from ':my-scope/common-constructs';
73
+ import { RuntimeConfig } from '@my-scope/common-constructs';
74
74
 
75
75
  const rc = RuntimeConfig.ensure(this);
76
76
 
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: Security
3
+ description: Security features included in projects generated by the Nx Plugin for AWS
4
+ ---
5
+
6
+ import Link from '@components/link.astro';
7
+
8
+ :::caution[Reporting Security Issues]
9
+ To report a potential security issue in the Nx Plugin for AWS itself, please refer to [SECURITY.md](https://github.com/awslabs/nx-plugin-for-aws/blob/main/SECURITY.md) — do not create a public GitHub issue.
10
+ :::
11
+
12
+ ## Security Controls
13
+
14
+ Projects scaffolded by the Nx Plugin for AWS include a number of security controls out of the box. This page provides an overview of those controls and links to the relevant guides for more detail.
15
+
16
+ ### Infrastructure Scanning
17
+
18
+ Infrastructure projects are configured with [Checkov](https://www.checkov.io/) as part of the `build` target, so insecure infrastructure configuration fails the build:
19
+
20
+ - CDK projects synthesize CloudFormation templates which are scanned by Checkov. See <Link path="/guides/typescript-infrastructure#security-testing">Security Testing</Link> for details.
21
+ - Terraform projects run Checkov directly against your Terraform code. See <Link path="/guides/terraform-project">Terraform Projects</Link>.
22
+
23
+ Where vended infrastructure suppresses a Checkov rule, the suppression is scoped to the specific resource and annotated with a justification. The shared `suppressRules` helper requires a reason for every suppression, and we recommend following the same practice in your own code. See <Link path="/guides/typescript-infrastructure#suppressing-checkov-checks">Suppressing Checkov Checks</Link>.
24
+
25
+ ### Container Image Scanning
26
+
27
+ Projects which build container images (for example agents, MCP servers, and database migration images) include a `trivy` target which scans images for HIGH and CRITICAL vulnerabilities, exiting non-zero on findings. See <Link path="/guides/docker-bundling">Docker Bundling</Link> for details, including how to suppress findings with a `.trivyignore` file.
28
+
29
+ ### Credential Scanning
30
+
31
+ Workspaces include [git-secrets](https://github.com/awslabs/git-secrets) pre-commit hooks which scan staged files for AWS credential patterns, preventing accidental commits of access keys and other sensitive values. See the <Link path="/guides/workspace#git-secrets">Git Secrets</Link> section of the workspace guide.
32
+
33
+ ### Authentication
34
+
35
+ APIs, agents, and MCP servers use AWS IAM (SigV4) authentication by default:
36
+
37
+ - <Link path="/guides/trpc">tRPC</Link>, <Link path="/guides/fastapi">FastAPI</Link>, and <Link path="/guides/ts-smithy-api">Smithy</Link> APIs default to IAM authentication, with Cognito and custom authorizers available as options. The vended custom authorizer stub denies requests by default.
38
+ - <Link path="/guides/ts-agent">Agents</Link> and <Link path="/guides/ts-mcp-server">MCP servers</Link> deployed to Amazon Bedrock AgentCore Runtime use IAM (SigV4) authentication by default, with JWT-based Cognito authentication as an option.
39
+ - The <Link path="/guides/react-website-auth">website auth generator</Link> vends an Amazon Cognito user pool with multi-factor authentication (MFA) required, a strong password policy, and deletion protection enabled.
40
+
41
+ ### Encryption
42
+
43
+ Vended infrastructure encrypts data in transit and at rest:
44
+
45
+ - Websites are served via CloudFront with HTTP redirected to HTTPS, and a response headers policy including HTTP Strict Transport Security (HSTS), a Content Security Policy, and other <Link path="/guides/react-website#security-headers">security headers</Link>. A WAF with AWS managed rules is associated with the distribution.
46
+ - S3 buckets block all public access, enforce SSL-only access via bucket policies, are encrypted (KMS with key rotation for website content), and deliver server access logs to CloudWatch log groups encrypted with customer-managed KMS keys, where they can be queried with Logs Insights and alarmed on.
47
+ - API access logs are written to CloudWatch log groups encrypted with customer-managed KMS keys with rotation enabled.
48
+ - <Link path="/guides/ts-rdb">Aurora databases</Link> enable storage encryption with a customer-managed KMS key, generate credentials in AWS Secrets Manager (never hardcoded), and support automatic credential rotation.
49
+
50
+ ### Least Privilege
51
+
52
+ Vended CDK constructs and Terraform modules follow least privilege:
53
+
54
+ - Constructs expose `grant*` methods (for example `grantInvokeAccess` on APIs and agents, `grantConnect` on databases) so consumers grant only the access they need.
55
+ - IAM policies in vended infrastructure are scoped to specific resources and actions. Where a wildcard resource is required by the AWS service (for example `ecr:GetAuthorizationToken`), it is limited to those actions and scoped with conditions where supported.
56
+
57
+ ### Dependency Licensing
58
+
59
+ The <Link path="/guides/license">license generator</Link> configures automated license header management and dependency license checking against an allowlist of approved licenses, helping you catch problematic transitive dependencies before they ship.
60
+
61
+ ## Responsibility
62
+
63
+ Security and compliance is a shared responsibility. AWS describes this through the [Shared Responsibility Model](https://aws.amazon.com/compliance/shared-responsibility-model/), which distinguishes between security *of* the cloud (the responsibility of AWS) and security *in* the cloud (your responsibility as the customer).
64
+
65
+ The Nx Plugin for AWS helps you address parts of your side of that model. Its generators vend secure foundations and encode AWS best practices within the scope of the code they produce — the controls described above. This reduces the effort required to build securely, but it does not transfer ownership of security to the plugin.
66
+
67
+ **You own the code that is generated into your workspace and remain responsible for its security.** Once vended, generated code is yours to modify, extend, and operate, and it must be treated the same as any other code you author.
68
+
69
+ In particular:
70
+
71
+ - **The scope of the plugin is limited to its generators.** The plugin has no knowledge of your application's business logic, data classification, threat model, or regulatory obligations, and cannot make decisions that depend on them.
72
+ - **Authentication is configured, but authorization is not.** APIs are protected with authentication by default (for example IAM/SigV4), but the plugin cannot determine *which* authenticated principals should be permitted to perform *which* operations on *which* resources. Fine-grained authorization depends on your business logic and must be designed, implemented, and tested by you.
73
+ - **Generated code is a starting point, not a finished product.** As you add functionality, you introduce security considerations the plugin cannot anticipate — input validation, data handling, secrets management, dependency choices, and integrations with other systems.
74
+
75
+ Accordingly, you should review generated code and the applications you build on top of it in line with your own organisation's security policies, standards, and review processes, and subject them to the same threat modelling, security testing, and approval gates you apply to any production workload. The controls vended by the plugin are intended to complement those processes, not to replace them.
@@ -0,0 +1,167 @@
1
+ ---
2
+ title: Smithy Projects
3
+ description: Reference documentation for the Smithy project generator
4
+ generator: smithy#project
5
+ ---
6
+ import { FileTree, Steps } from '@astrojs/starlight/components';
7
+ import RunGenerator from '@components/run-generator.astro';
8
+ import Link from '@components/link.astro';
9
+ import GeneratorParameters from '@components/generator-parameters.astro';
10
+ import NxCommands from '@components/nx-commands.astro';
11
+ import OptionFilter from '@components/option-filter.astro';
12
+
13
+ [Smithy](https://smithy.io/) is an interface definition language for describing services and the data they exchange. The Smithy project generator creates a project containing a Smithy model.
14
+
15
+ There are two kinds of Smithy project:
16
+
17
+ - **Service** (`--type=service`) — a model which defines a service and its operations. This is what the <Link path="guides/ts-smithy-api">`ts#api --framework=smithy` generator</Link> creates for you alongside a TypeScript implementation.
18
+ - **Shape library** (`--type=shapes`) — a model which defines reusable shapes but no service. Connect a shape library to your Smithy projects to share shapes between them, rather than duplicating the definitions in each.
19
+
20
+ :::tip
21
+ If you want an API with an implementation, use the <Link path="guides/ts-smithy-api">`ts#api` generator</Link> instead. It creates a Smithy model project _and_ a TypeScript server which implements it.
22
+ :::
23
+
24
+ ## Usage
25
+
26
+ ### Generate a Smithy Project
27
+
28
+ <RunGenerator generator="smithy#project" requiredParameters={{ name: 'my-shapes' }} />
29
+
30
+ ### Options
31
+
32
+ <GeneratorParameters generator="smithy#project" />
33
+
34
+ ## Generator Output
35
+
36
+ <OptionFilter when={{ type: 'shapes' }} description="Shape library: a model with no service">
37
+
38
+ ### Shape Library
39
+
40
+ <FileTree>
41
+
42
+ - my-shapes
43
+ - src
44
+ - main.smithy Your shared shape definitions
45
+ - smithy-build.json Smithy build configuration
46
+ - project.json Project configuration and build targets
47
+
48
+ </FileTree>
49
+
50
+ A shape library defines shapes and nothing else:
51
+
52
+ ```smithy
53
+ $version: "2.0"
54
+
55
+ namespace com.example
56
+
57
+ structure Customer {
58
+ @required
59
+ id: String
60
+
61
+ name: String
62
+ email: String
63
+ }
64
+ ```
65
+
66
+ Since a shape library has no service, its `smithy-build.json` configures no code generation — building it validates the model and assembles it into a single JSON model file at `dist/<my-shapes>/build/model.json`.
67
+
68
+ </OptionFilter>
69
+
70
+ <OptionFilter when={{ type: 'service' }} description="Service: a model which defines a service and its operations">
71
+
72
+ ### Service
73
+
74
+ <FileTree>
75
+
76
+ - my-service
77
+ - src
78
+ - main.smithy Your service definition
79
+ - operations
80
+ - echo.smithy An example operation
81
+ - smithy-build.json Smithy build configuration, including code generation
82
+ - ssdk.rolldown.config.mjs Bundles the generated TypeScript Server SDK
83
+ - project.json Project configuration and build targets
84
+
85
+ </FileTree>
86
+
87
+ A service model defines a service shape and the operations it exposes:
88
+
89
+ ```smithy
90
+ $version: "2.0"
91
+
92
+ namespace com.example
93
+
94
+ use aws.protocols#restJson1
95
+
96
+ @title("MyService")
97
+ @restJson1
98
+ service MyService {
99
+ version: "1.0.0"
100
+ operations: [
101
+ Echo
102
+ ]
103
+ }
104
+ ```
105
+
106
+ Building a service project generates an OpenAPI specification and a TypeScript Server SDK into `dist/<my-service>/build/`.
107
+
108
+ </OptionFilter>
109
+
110
+ ## Building
111
+
112
+ Smithy projects build with the [Smithy CLI](https://smithy.io/2.0/guides/smithy-cli/index.html), which validates your model:
113
+
114
+ <NxCommands commands={['build my-shapes']} />
115
+
116
+ On macOS and Linux the CLI is resolved by [mise](https://mise.jdx.dev/), which the build fetches on demand, so there is nothing to install — it downloads and caches the pinned version the first time you build. On Windows it is a prerequisite you install yourself — see <Link path="guides/ts-smithy-api#building-on-windows">Building on Windows</Link>.
117
+
118
+ ## Depending on a Shape Library
119
+
120
+ Building a shape library writes an assembled model to `dist/<my-shapes>/build/model.json`. This single file contains every shape the library defines, along with any it depends on, so a consumer only ever declares the libraries it references directly.
121
+
122
+ To depend on a shape library from another Smithy project, make two changes to the consuming project:
123
+
124
+ <Steps>
125
+
126
+ 1. Add the library's built model to `imports` in the consuming project's `smithy-build.json`. Paths are relative to that file, so the number of `../` segments matches how deeply the consuming project is nested — three for `packages/my-api/model` below:
127
+
128
+ ```json ins={4}
129
+ {
130
+ "version": "1.0",
131
+ "sources": ["src/"],
132
+ "imports": ["../../../dist/packages/my-shapes/build/model.json"],
133
+ ...
134
+ }
135
+ ```
136
+
137
+ 2. Add the library's `build` target as a dependency of the consuming project's `compile` target in its `project.json`, so the model exists before the consumer builds:
138
+
139
+ ```json ins={4}
140
+ {
141
+ "targets": {
142
+ "compile": {
143
+ "dependsOn": ["@my-scope/my-shapes:build"],
144
+ ...
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ </Steps>
151
+
152
+ Your model can now reference the library's shapes with `use`:
153
+
154
+ ```smithy
155
+ $version: "2.0"
156
+
157
+ namespace com.example.api
158
+
159
+ use com.example.shared#Customer
160
+
161
+ structure GetCustomerOutput {
162
+ @required
163
+ customer: Customer
164
+ }
165
+ ```
166
+
167
+ Shape libraries can depend on other shape libraries the same way. Since each library's built model already contains its own dependencies, you only need to repeat these steps for the libraries you reference directly. A library reached by more than one path is resolved once — Smithy ignores duplicate but equivalent shape definitions.
@@ -84,7 +84,7 @@ Application projects include full deployment capabilities with remote state mana
84
84
 
85
85
  You can start writing your Terraform infrastructure inside `src/main.tf`, for example:
86
86
 
87
- ```diff title="src/main.tf" {2-4}
87
+ ```diff title="src/main.tf" {16-19}
88
88
  -locals {
89
89
  - account_id = data.aws_caller_identity.current.account_id
90
90
  - aws_region = data.aws_region.current.id
@@ -108,7 +108,7 @@ You can start writing your Terraform infrastructure inside `src/main.tf`, for ex
108
108
 
109
109
  ### Cross project dependencies
110
110
 
111
- If you wanted to execute a module from a seperate project (lib), you could do so as follows:
111
+ If you wanted to execute a module from a separate project (lib), you could do so as follows:
112
112
 
113
113
  ```
114
114
  module "lib_module" {
@@ -1,12 +1,14 @@
1
1
  ---
2
2
  title: tRPC
3
3
  description: Reference documentation for tRPC
4
- generator: ts#trpc-api
4
+ generator: ts#api
5
5
  when:
6
6
  framework: [trpc]
7
7
  infra: [rest-lambda, http-lambda]
8
8
  ---
9
- import { FileTree, Tabs, TabItem } from '@astrojs/starlight/components';
9
+ import { FileTree, Tabs, TabItem, CardGrid } from '@astrojs/starlight/components';
10
+ import Astro from '@astrojs/react';
11
+ import ConnectionCard from '@components/connection-card.astro';
10
12
  import Link from '@components/link.astro';
11
13
  import RunGenerator from '@components/run-generator.astro';
12
14
  import GeneratorParameters from '@components/generator-parameters.astro';
@@ -25,11 +27,11 @@ The tRPC API generator creates a new tRPC API with AWS CDK or Terraform infrastr
25
27
 
26
28
  You can generate a new tRPC API in two ways:
27
29
 
28
- <RunGenerator generator="ts#trpc-api" />
30
+ <RunGenerator generator="ts#api" requiredParameters={{ framework: 'trpc' }} />
29
31
 
30
32
  ### Options
31
33
 
32
- <GeneratorParameters generator="ts#trpc-api" />
34
+ <GeneratorParameters generator="ts#api" />
33
35
 
34
36
  <Snippet name="api/api-choice-note" />
35
37
 
@@ -64,6 +66,7 @@ The generator will create the following project structure in the `<directory>/<a
64
66
  - client
65
67
  - index.ts Type-safe client for machine-to-machine API calls
66
68
  - tsconfig.json TypeScript configuration
69
+ - package.json Project manifest defining the project's package name and dependencies
67
70
  - project.json Project configuration and build targets
68
71
 
69
72
  </FileTree>
@@ -138,7 +141,7 @@ The example `echo` procedure is generated for you in `src/procedures/echo.ts`:
138
141
  export const echo = publicProcedure
139
142
  .input(EchoInputSchema)
140
143
  .output(EchoOutputSchema)
141
- .query((opts) => ({ result: opts.input.message }));
144
+ .query((opts) => ({ message: opts.input.message }));
142
145
  ```
143
146
 
144
147
  To break down the above:
@@ -463,7 +466,7 @@ export const createIdentityPlugin = () => {
463
466
  </OptionFilter>
464
467
 
465
468
  <OptionFilter when={{ auth: 'cognito' }} description="Identity middleware example for Cognito-authenticated APIs">
466
- When you deploy with `auth: 'cognito'`, the API Gateway Cognito User Pools authorizer verifies the JWT that the caller supplies in the `Authorization` header and places the verified claims on the Lambda event at `event.requestContext.authorizer.claims`. Our middleware just reads those claims — no extra AWS SDK calls, no manual JWT verification.
469
+ When you deploy with `auth: 'cognito'`, the API Gateway Cognito authorizer verifies the JWT that the caller supplies in the `Authorization` header and places the verified claims on the Lambda event. Our middleware just reads those claims — no extra AWS SDK calls, no manual JWT verification.
467
470
 
468
471
  First, we define what we'll add to the context:
469
472
 
@@ -478,7 +481,7 @@ export interface IIdentityContext {
478
481
 
479
482
  Note that we define an additional _optional_ property on the context. tRPC manages ensuring that this is defined in procedures which have correctly configured this middleware.
480
483
 
481
- Next, the middleware itself. The generator wires the authorizer to accept ID tokens, so `cognito:username` is the canonical username claim; we fall back to `username` for access tokens in case you reconfigure the authorizer:
484
+ Next, the middleware itself:
482
485
 
483
486
  ```ts
484
487
  import { initTRPC, TRPCError } from '@trpc/server';
@@ -503,7 +506,7 @@ export const createIdentityPlugin = () => {
503
506
  | undefined;
504
507
 
505
508
  const sub = claims?.sub;
506
- const username = claims?.['cognito:username'] ?? claims?.username;
509
+ const username = claims?.username;
507
510
 
508
511
  if (!sub || !username) {
509
512
  throw new TRPCError({
@@ -541,14 +544,14 @@ export const me = publicProcedure
541
544
  }));
542
545
  ```
543
546
 
544
- :::tip[Verifying the token]
545
- You don't need `aws-jwt-verify` or any other JWT-verification library here — the API Gateway Cognito User Pools authorizer has already verified the signature, issuer, audience, and expiry by the time your Lambda runs. If any of those checks fail, API Gateway returns `401 Unauthorized` and your handler is never invoked.
547
+ :::tip[No token verification required]
548
+ You don't need `aws-jwt-verify` or any other JWT-verification library here — the API Gateway Cognito User Pools authorizer has already verified the signature, issuer, scopes, and expiry by the time your Lambda runs. If any of those checks fail, API Gateway returns `401 Unauthorized` and your handler is never invoked.
546
549
  :::
547
550
  </OptionFilter>
548
551
 
549
552
  ## Deploying your tRPC API
550
553
 
551
- The tRPC API generator creates CDK or Terraform infrastructure as code based on your selected `iacProvider`. You can use this to deploy your tRPC API.
554
+ The tRPC API generator creates CDK or Terraform infrastructure as code based on your selected `iac`. You can use this to deploy your tRPC API.
552
555
 
553
556
  <Infrastructure>
554
557
  <Fragment slot="cdk">
@@ -556,7 +559,7 @@ The CDK construct for deploying your API lives in the `common/constructs` folder
556
559
 
557
560
  <OptionFilter when={{ auth: ['iam', 'custom'] }} description="CDK usage for IAM or Custom authentication">
558
561
  ```ts {6-8}
559
- import { MyApi } from ':my-scope/common-constructs';
562
+ import { MyApi } from '@my-scope/common-constructs';
560
563
 
561
564
  export class ExampleStack extends Stack {
562
565
  constructor(scope: Construct, id: string) {
@@ -574,8 +577,8 @@ When using `Custom` auth, the construct creates a Lambda Authorizer internally f
574
577
  </OptionFilter>
575
578
 
576
579
  <OptionFilter when={{ auth: 'cognito' }} description="CDK usage with Cognito authentication — pass the identity construct">
577
- ```ts {6,9}
578
- import { MyApi, UserIdentity } from ':my-scope/common-constructs';
580
+ ```ts {6,10}
581
+ import { MyApi, UserIdentity } from '@my-scope/common-constructs';
579
582
 
580
583
  export class ExampleStack extends Stack {
581
584
  constructor(scope: Construct, id: string) {
@@ -630,7 +633,7 @@ module "my_api" {
630
633
  </OptionFilter>
631
634
 
632
635
  <OptionFilter when={{ auth: 'cognito' }} description="Terraform usage with Cognito authentication — supply user pool and client">
633
- ```hcl {1-3, 8-9}
636
+ ```hcl {1-3, 8, 10-11}
634
637
  module "asset_bucket" {
635
638
  source = "../../common/terraform/src/core/asset-bucket"
636
639
  }
@@ -726,12 +729,18 @@ When using `Custom` auth, your API is protected by a Lambda Authorizer that **de
726
729
  <Snippet name="api/waf-configuration" parentHeading="WAF" />
727
730
  </OptionFilter>
728
731
 
732
+ <OptionFilter when={{ infra: 'rest-lambda' }} description="Access logging — REST APIs log requests to CloudWatch by default">
733
+ ### Access logging
734
+
735
+ <Snippet name="api/access-logging" parentHeading="Access logging" />
736
+ </OptionFilter>
737
+
729
738
  ### Integrations
730
739
 
731
740
  <Snippet name="api/type-safe-api-integrations" parentHeading="Integrations" />
732
741
 
733
742
  :::tip[CDK Type-Safe Integrations]
734
- If you selected CDK for your `iacProvider`, when you add or remove a procedure in your tRPC API, these changes will be reflected immediately in the CDK construct without the need to rebuild.
743
+ If you selected CDK for your `iac`, when you add or remove a procedure in your tRPC API, these changes will be reflected immediately in the CDK construct without the need to rebuild.
735
744
  :::
736
745
 
737
746
  <OptionFilter when={{ auth: 'iam' }} description="Granting API invoke access — IAM-authenticated APIs only">
@@ -805,7 +814,7 @@ This will automatically reload when you make changes to your API.
805
814
  You can create a tRPC client to invoke your API in a type-safe manner. If you are calling your tRPC API from another backend, you can use the client in `src/client/index.ts`, for example:
806
815
 
807
816
  ```ts
808
- import { createMyApiClient } from ':my-scope/my-api';
817
+ import { createMyApiClient } from '@my-scope/my-api';
809
818
 
810
819
  const client = createMyApiClient({ url: 'https://my-api-url.example.com/' });
811
820
 
@@ -817,3 +826,31 @@ If you are calling your API from a React website, consider using the <Link path=
817
826
  ## More Information
818
827
 
819
828
  For more information about tRPC, please refer to the [tRPC documentation](https://trpc.io/docs).
829
+
830
+ ## Connections
831
+
832
+ Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
833
+
834
+ <CardGrid>
835
+ <ConnectionCard
836
+ title="React to tRPC"
837
+ description="Call a tRPC API from a React website"
838
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-trpc`}
839
+ source="react"
840
+ target="trpc"
841
+ />
842
+ <ConnectionCard
843
+ title="tRPC API to Relational Database"
844
+ description="Connect a tRPC API to an Aurora relational database"
845
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-rdb`}
846
+ source="trpc"
847
+ target="aurora"
848
+ />
849
+ <ConnectionCard
850
+ title="tRPC API to TypeScript DynamoDB"
851
+ description="Connect a tRPC API to a DynamoDB table"
852
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/trpc-dynamodb`}
853
+ source="trpc"
854
+ target="dynamodb"
855
+ />
856
+ </CardGrid>