@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
@@ -1,12 +1,14 @@
1
1
  ---
2
2
  title: React Website
3
3
  description: Reference documentation for a React Website
4
- generator: ts#react-website
4
+ generator: ts#website
5
5
  when:
6
6
  framework:
7
7
  - react
8
8
  ---
9
- import { FileTree, Steps } from '@astrojs/starlight/components';
9
+ import { FileTree, Steps, 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';
@@ -16,12 +18,12 @@ import Infrastructure from '@components/infrastructure.astro';
16
18
  import Snippet from '@components/snippet.astro';
17
19
  import OptionFilter from '@components/option-filter.astro';
18
20
 
19
- This generator creates a new [React](https://react.dev/) website with [Cloudscape](http://cloudscape.design/) configured by default, along with the AWS CDK or Terraform infrastructure to deploy your website to the cloud as a static website hosted in [S3](https://aws.amazon.com/s3/), served by [CloudFront](https://aws.amazon.com/cloudfront/) and protected by [WAF](https://aws.amazon.com/waf/).
21
+ This generator creates a new [React](https://react.dev/) website with [shadcn/ui](https://ui.shadcn.com/) configured by default, along with the AWS CDK or Terraform infrastructure to deploy your website to the cloud as a static website hosted in [S3](https://aws.amazon.com/s3/), served by [CloudFront](https://aws.amazon.com/cloudfront/) and protected by [WAF](https://aws.amazon.com/waf/).
20
22
 
21
23
  The generated application uses [Vite](https://vite.dev/) as the build tool and bundler. It uses [TanStack Router](https://tanstack.com/router/v1) for type-safe routing.
22
24
 
23
25
  :::note[UX Provider]
24
- The default `uxProvider` is [Cloudscape](http://cloudscape.design/). You can also select [shadcn/ui](https://ui.shadcn.com/) or `None` (bring your own component library).
26
+ The default `ux` is [shadcn/ui](https://ui.shadcn.com/). You can also select [Cloudscape](http://cloudscape.design/) or `none` (bring your own component library).
25
27
  :::
26
28
 
27
29
  ## Usage
@@ -30,7 +32,7 @@ The default `uxProvider` is [Cloudscape](http://cloudscape.design/). You can als
30
32
 
31
33
  You can generate a new React Website in two ways:
32
34
 
33
- <RunGenerator generator="ts#website" />
35
+ <RunGenerator generator="ts#website" requiredParameters={{ framework: 'react' }} />
34
36
 
35
37
  ### Options
36
38
 
@@ -57,6 +59,7 @@ The generator will create the following project structure in the `<directory>/<n
57
59
  - tsconfig.json Base TypeScript configuration for source and tests
58
60
  - tsconfig.app.json TypeScript configuration for source code
59
61
  - tsconfig.spec.json TypeScript configuration for tests
62
+ - package.json Project manifest defining the project's package name and dependencies
60
63
  </FileTree>
61
64
 
62
65
  :::note[Without TanStack Router]
@@ -67,7 +70,7 @@ If you opted not to use [TanStack Router](https://tanstack.com/router/v1), you w
67
70
 
68
71
  <Snippet name="shared-constructs" />
69
72
 
70
- The generator creates infrastructure as code for deploying your website based on your selected `iacProvider`:
73
+ The generator creates infrastructure as code for deploying your website based on your selected `iac`:
71
74
 
72
75
  <Infrastructure>
73
76
  <Fragment slot="cdk">
@@ -126,7 +129,7 @@ waf -> cloudfront
126
129
  cloudfront -> s3
127
130
  ```
128
131
 
129
- ## Implementing your React Website
132
+ ## Implementing your Website
130
133
 
131
134
  The [React documentation](https://react.dev/learn) is a good place to start to learn the basics of building with React.
132
135
 
@@ -177,28 +180,343 @@ export const MyComponent = () => {
177
180
 
178
181
  For more details, check out the [TanStack Router](https://tanstack.com/router/latest/docs/framework/react/overview) documentation.
179
182
 
183
+ ## Deploying your Website
184
+
185
+ The React website generator creates CDK or Terraform infrastructure as code based on your selected `iac`. You can use this to deploy your website.
186
+
187
+ <Infrastructure>
188
+ <Fragment slot="cdk">
189
+ To deploy your website, we recommend using the <Link path="guides/typescript-infrastructure">`ts#infra` generator</Link> to create a CDK application.
190
+
191
+ You can use the CDK construct generated for you in `packages/common/constructs` to deploy your website.
192
+
193
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {3, 9}
194
+ import { Stack } from 'aws-cdk-lib';
195
+ import { Construct } from 'constructs';
196
+ import { MyWebsite } from '@my-scope/common-constructs';
197
+
198
+ export class ApplicationStack extends Stack {
199
+ constructor(scope: Construct, id: string) {
200
+ super(scope, id);
201
+
202
+ new MyWebsite(this, 'MyWebsite');
203
+ }
204
+ }
205
+ ```
206
+
207
+ This sets up:
208
+
209
+ 1. An S3 bucket for hosting your static website files
210
+ 2. CloudFront distribution for global content delivery
211
+ 3. WAF Web ACL for security protection
212
+ 4. Origin Access Control for secure S3 access
213
+ 5. Automatic deployment of website files and runtime configuration
214
+ </Fragment>
215
+ <Fragment slot="terraform">
216
+ To deploy your website, we recommend using the <Link path="/guides/terraform-project">`terraform#project` generator</Link> to create a Terraform project.
217
+
218
+ You can use the Terraform module generated for you in `packages/common/terraform` to deploy your website.
219
+
220
+ ```hcl title="packages/infra/src/main.tf" {3}
221
+ # Deploy website
222
+ module "my_website" {
223
+ source = "../../common/terraform/src/app/static-websites/my-website"
224
+
225
+ providers = {
226
+ aws.us_east_1 = aws.us_east_1
227
+ }
228
+ }
229
+ ```
230
+
231
+ This sets up:
232
+
233
+ 1. An S3 bucket for hosting your static website files
234
+ 2. CloudFront distribution for global content delivery
235
+ 3. WAF Web ACL for security protection (deployed in us-east-1)
236
+ 4. Origin Access Control for secure S3 access
237
+ 5. Automatic deployment of website files and runtime configuration
238
+
239
+ :::note[WAF Provider Region]
240
+ The `aws.us_east_1` provider is required for CloudFront and WAF resources, which must be deployed in the us-east-1 region. Make sure your Terraform configuration includes this provider:
241
+
242
+ ```hcl title="packages/infra/src/providers.tf"
243
+ provider "aws" {
244
+ alias = "us_east_1"
245
+ region = "us-east-1"
246
+ }
247
+ ```
248
+ :::
249
+ </Fragment>
250
+ </Infrastructure>
251
+
252
+ ### Security Headers
253
+
254
+ The CloudFront distribution applies a response headers policy that sets `Strict-Transport-Security`, `X-Content-Type-Options`, `X-Frame-Options: DENY`, `Referrer-Policy` and a `Content-Security-Policy` on all responses.
255
+
256
+ A default `Content-Security-Policy` is enforced. It restricts scripts and framing to mitigate XSS and clickjacking, while permitting HTTPS and WSS connections so the website can call AWS service endpoints (such as API Gateway, Cognito and Bedrock AgentCore) whose URLs are only known at deploy time. To adjust the policy (for example to tighten `connect-src` to your specific origins), edit the `content_security_policy` value in your generated `static-website.ts` (CDK) or `static-website.tf` (Terraform).
257
+
258
+ `runtime-config.json` is served with `Cache-Control: no-cache` so that browsers always fetch the latest configuration after a redeploy, rather than using a stale cached copy.
259
+
260
+ ### WAF
261
+
262
+ The CloudFront distribution is protected by an [AWS WAFv2](https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html) Web ACL 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.
263
+
264
+ <Infrastructure>
265
+ <Fragment slot="cdk">
266
+ To opt out, set `enableWaf` to `false` when you create your website:
267
+
268
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {10,15-18}
269
+ import { Stack } from 'aws-cdk-lib';
270
+ import { Construct } from 'constructs';
271
+ import { MyWebsite, suppressRules } from '@my-scope/common-constructs';
272
+
273
+ export class ApplicationStack extends Stack {
274
+ constructor(scope: Construct, id: string) {
275
+ super(scope, id);
276
+
277
+ const website = new MyWebsite(this, 'MyWebsite', {
278
+ enableWaf: false,
279
+ });
280
+
281
+ // Disabling WAF fails the checkov CKV_AWS_68 check ("CloudFront
282
+ // Distribution should have WAF enabled"). Suppress it explicitly.
283
+ suppressRules(
284
+ website.cloudFrontDistribution,
285
+ ['CKV_AWS_68'],
286
+ 'WAF is intentionally disabled for this distribution',
287
+ );
288
+ }
289
+ }
290
+ ```
291
+
292
+ :::caution[Suppress CKV_AWS_68 when disabling WAF]
293
+ Disabling WAF means the synthesized CloudFront distribution has no Web ACL associated, which fails the `checkov` security scan with `CKV_AWS_68: "CloudFront Distribution should have WAF enabled"` unless suppressed as shown above.
294
+ :::
295
+ </Fragment>
296
+ <Fragment slot="terraform">
297
+ To opt out, set `enable_waf` to `false`:
298
+
299
+ ```hcl title="packages/infra/src/main.tf" {7}
300
+ module "my_website" {
301
+ source = "../../common/terraform/src/app/static-websites/my-website"
302
+
303
+ providers = {
304
+ aws.us_east_1 = aws.us_east_1
305
+ }
306
+ enable_waf = false
307
+ }
308
+ ```
309
+ </Fragment>
310
+ </Infrastructure>
311
+
312
+ ### Bucket Encryption
313
+
314
+ The website bucket, the CloudFront distribution log bucket, and the CloudWatch Logs group receiving their server access logs are encrypted with a customer-managed [AWS KMS](https://aws.amazon.com/kms/) key by default. This key is created for you automatically, with key rotation enabled.
315
+
316
+ <Infrastructure>
317
+ <Fragment slot="cdk">
318
+ If you want to use a different encryption configuration, pass the `encryption`, `encryptionKey` and `enableKeyRotation` props when you create your website:
319
+
320
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {11}
321
+ import { Stack } from 'aws-cdk-lib';
322
+ import { Construct } from 'constructs';
323
+ import { BucketEncryption } from 'aws-cdk-lib/aws-s3';
324
+ import { MyWebsite } from '@my-scope/common-constructs';
325
+
326
+ export class ApplicationStack extends Stack {
327
+ constructor(scope: Construct, id: string) {
328
+ super(scope, id);
329
+
330
+ new MyWebsite(this, 'MyWebsite', {
331
+ encryption: BucketEncryption.S3_MANAGED,
332
+ });
333
+ }
334
+ }
335
+ ```
336
+
337
+ :::caution[Suppress CKV_AWS_158 when using S3_MANAGED]
338
+ Choosing `BucketEncryption.S3_MANAGED` means the access log group is no longer KMS encrypted, which fails the `checkov` security scan with `CKV_AWS_158`. Suppress it:
339
+
340
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
341
+ import { LogGroup } from 'aws-cdk-lib/aws-logs';
342
+ import { suppressRules } from '@my-scope/common-constructs';
343
+
344
+ suppressRules(
345
+ website,
346
+ ['CKV_AWS_158'],
347
+ 'Access log group is not KMS encrypted when encryption is S3_MANAGED',
348
+ (c) => c instanceof LogGroup,
349
+ );
350
+ ```
351
+ :::
352
+
353
+ To use your own KMS key instead of one created automatically, pass `encryptionKey`:
354
+
355
+ ```ts {2}
356
+ new MyWebsite(this, 'MyWebsite', {
357
+ encryptionKey: myKey,
358
+ });
359
+ ```
360
+
361
+ :::caution[Imported keys need their own permissions]
362
+ A key imported via `Key.fromKeyArn` must already grant the CloudWatch Logs, S3 and CloudFront service principals the permissions they need in its own key policy. `addToResourcePolicy` is a no-op on an imported key, so this construct can't grant them for you, and `cdk synth` won't warn you - the failure only shows up at deploy time. A key created in the same app (`new Key(this, 'WebsiteKey')`) doesn't have this problem, since CDK can update its policy directly.
363
+ :::
364
+
365
+ `enableKeyRotation` (default `true`) only applies to the automatically created key, i.e. when `encryption` is `BucketEncryption.KMS` (the default) and no `encryptionKey` is supplied:
366
+
367
+ ```ts {2}
368
+ new MyWebsite(this, 'MyWebsite', {
369
+ enableKeyRotation: false,
370
+ });
371
+ ```
372
+
373
+ :::caution[Suppress CKV_AWS_7 when disabling key rotation]
374
+ Disabling key rotation on the automatically created key fails the `checkov` security scan with `CKV_AWS_7`. Suppress it:
375
+
376
+ ```ts title="packages/infra/src/stacks/application-stack.ts"
377
+ import { Key } from 'aws-cdk-lib/aws-kms';
378
+ import { suppressRules } from '@my-scope/common-constructs';
379
+
380
+ suppressRules(
381
+ website,
382
+ ['CKV_AWS_7'],
383
+ 'Key rotation is managed externally',
384
+ (c) => c instanceof Key,
385
+ );
386
+ ```
387
+ :::
388
+ </Fragment>
389
+ <Fragment slot="terraform">
390
+ If you want to use a different encryption configuration, set the `encryption`, `kms_key_arn`, `create_kms_key` and `enable_key_rotation` variables:
391
+
392
+ ```hcl title="packages/infra/src/main.tf" {7}
393
+ module "my_website" {
394
+ source = "../../common/terraform/src/app/static-websites/my-website"
395
+
396
+ providers = {
397
+ aws.us_east_1 = aws.us_east_1
398
+ }
399
+ encryption = "S3_MANAGED"
400
+ }
401
+ ```
402
+
403
+ :::caution[Checkov: S3_MANAGED]
404
+ Choosing `S3_MANAGED` fails the `checkov` security scan with `CKV_AWS_145` on the website and distribution log buckets. The vended `test` target doesn't accept a `--config-file`, but `checkov` auto-discovers a `.checkov.yaml` in its working directory, so drop one in `packages/infra/src`:
405
+
406
+ ```yaml title="packages/infra/src/.checkov.yaml"
407
+ skip-check:
408
+ - CKV_AWS_145
409
+ ```
410
+ :::
411
+
412
+ To use your own KMS key instead of one created automatically, pass `kms_key_arn` and set `create_kms_key` to `false`:
413
+
414
+ ```hcl title="packages/infra/src/main.tf" {7-8}
415
+ module "my_website" {
416
+ source = "../../common/terraform/src/app/static-websites/my-website"
417
+
418
+ providers = {
419
+ aws.us_east_1 = aws.us_east_1
420
+ }
421
+ kms_key_arn = aws_kms_key.website.arn
422
+ create_kms_key = false
423
+ }
424
+ ```
425
+
426
+ A customer-supplied key must already grant the CloudWatch Logs, S3 and CloudFront service principals the permissions they need in its own key policy.
427
+
428
+ `enable_key_rotation` (default `true`) only applies to the automatically created key, i.e. when `encryption` is `"KMS"` (the default) and `create_kms_key` is `true`:
429
+
430
+ ```hcl title="packages/infra/src/main.tf" {7}
431
+ module "my_website" {
432
+ source = "../../common/terraform/src/app/static-websites/my-website"
433
+
434
+ providers = {
435
+ aws.us_east_1 = aws.us_east_1
436
+ }
437
+ enable_key_rotation = false
438
+ }
439
+ ```
440
+
441
+ :::caution[Checkov: key rotation disabled]
442
+ Disabling key rotation on the automatically created key fails the `checkov` security scan with `CKV_AWS_7`. Add it to the same `.checkov.yaml`:
443
+
444
+ ```yaml title="packages/infra/src/.checkov.yaml"
445
+ skip-check:
446
+ - CKV_AWS_7
447
+ ```
448
+ :::
449
+ </Fragment>
450
+ </Infrastructure>
451
+
452
+ ### Custom Domain & TLS
453
+
454
+ By default the distribution uses the default CloudFront domain name (`*.cloudfront.net`) and its default certificate, which does not support enforcing a minimum TLS version of 1.2. To serve your website from your own domain, supply an [ACM certificate](https://docs.aws.amazon.com/acm/latest/userguide/acm-overview.html) (which must reside in `us-east-1` for use with CloudFront) and your domain names. A minimum TLS version of 1.2 is then enforced for viewers:
455
+
456
+ <Infrastructure>
457
+ <Fragment slot="cdk">
458
+ Pass the `certificate` and `domainNames` props when you create your website:
459
+
460
+ ```ts title="packages/infra/src/stacks/application-stack.ts" {11-13}
461
+ import { Stack } from 'aws-cdk-lib';
462
+ import { Construct } from 'constructs';
463
+ import { Certificate } from 'aws-cdk-lib/aws-certificatemanager';
464
+ import { MyWebsite } from '@my-scope/common-constructs';
465
+
466
+ export class ApplicationStack extends Stack {
467
+ constructor(scope: Construct, id: string) {
468
+ super(scope, id);
469
+
470
+ new MyWebsite(this, 'MyWebsite', {
471
+ domainNames: ['www.example.com'],
472
+ certificate: Certificate.fromCertificateArn(this, 'Cert',
473
+ 'arn:aws:acm:us-east-1:123456789012:certificate/...'),
474
+ });
475
+ }
476
+ }
477
+ ```
478
+ </Fragment>
479
+ <Fragment slot="terraform">
480
+ Set the `custom_domain_names` and `acm_certificate_arn` variables:
481
+
482
+ ```hcl title="packages/infra/src/main.tf" {7-8}
483
+ module "my_website" {
484
+ source = "../../common/terraform/src/app/static-websites/my-website"
485
+
486
+ providers = {
487
+ aws.us_east_1 = aws.us_east_1
488
+ }
489
+ custom_domain_names = ["www.example.com"]
490
+ acm_certificate_arn = "arn:aws:acm:us-east-1:123456789012:certificate/..."
491
+ }
492
+ ```
493
+ </Fragment>
494
+ </Infrastructure>
495
+
496
+ You will also need to create DNS records (for example in Route 53) pointing your domain at the CloudFront distribution.
497
+
180
498
  ## Runtime Configuration
181
499
 
182
- Configuration from your infrastructure is provided to your website via <Link href="guides/runtime-config">Runtime Configuration</Link>. This allows your website to access details such as API URLs which are not known until your application is deployed.
500
+ Configuration from your infrastructure is provided to your website via <Link path="guides/runtime-config">Runtime Configuration</Link>. This allows your website to access details such as API URLs which are not known until your application is deployed.
183
501
 
184
502
  ### Infrastructure
185
503
 
186
504
  <Infrastructure>
187
505
  <Fragment slot="cdk">
188
- The `RuntimeConfig` CDK construct can be used to add and retrieve configuration in your CDK infrastructure. The CDK constructs generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#trpc-api`</Link> and <Link path="guides/fastapi">`py#fast-api`</Link>) will automatically add appropriate values to the `RuntimeConfig`.
506
+ The `RuntimeConfig` CDK construct can be used to add and retrieve configuration in your CDK infrastructure. The CDK constructs generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#api`</Link> and <Link path="guides/fastapi">`py#api`</Link>) will automatically add appropriate values to the `RuntimeConfig`.
189
507
 
190
508
  Your website CDK construct will deploy the `connection` namespace of the runtime configuration as a `runtime-config.json` file to the root of your S3 bucket.
191
509
 
192
510
  ```ts title="packages/infra/src/stacks/application-stack.ts"
193
511
  import { Stack } from 'aws-cdk-lib';
194
512
  import { Construct } from 'constructs';
195
- import { MyWebsite, MyApi } from ':my-scope/common-constructs';
513
+ import { MyWebsite, MyApi } from '@my-scope/common-constructs';
196
514
 
197
515
  export class ApplicationStack extends Stack {
198
516
  constructor(scope: Construct, id: string) {
199
517
  super(scope, id);
200
518
 
201
- // Website can be declared at any point — runtime config is resolved lazily
519
+ // Website can be declared at any point, since runtime config is resolved lazily
202
520
  new MyWebsite(this, 'MyWebsite');
203
521
 
204
522
  // Automatically adds values to the RuntimeConfig
@@ -214,11 +532,11 @@ With CDK, the website construct can be declared at any point in your stack. Runt
214
532
  :::
215
533
  </Fragment>
216
534
  <Fragment slot="terraform">
217
- With Terraform, runtime configuration is managed through the runtime-config modules. The Terraform modules generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#trpc-api`</Link> and <Link path="guides/fastapi">`py#fast-api`</Link>) will automatically add appropriate values to the runtime configuration.
535
+ With Terraform, runtime configuration is managed through the runtime-config modules. The Terraform modules generated by `@aws/nx-plugin` generators (such as <Link path="guides/trpc">`ts#api`</Link> and <Link path="guides/fastapi">`py#api`</Link>) will automatically add appropriate values to the runtime configuration.
218
536
 
219
537
  Your website Terraform module will deploy the `connection` namespace of the runtime configuration as a `runtime-config.json` file to the root of your S3 bucket.
220
538
 
221
- ```hcl title="packages/infra/src/main.tf" {18-19}
539
+ ```hcl title="packages/infra/src/main.tf" {20-21}
222
540
  module "asset_bucket" {
223
541
  source = "../../common/terraform/src/core/asset-bucket"
224
542
  }
@@ -272,26 +590,30 @@ For details on how runtime configuration is stored in AWS AppConfig and how serv
272
590
 
273
591
  When running the [local development server](#local-development-server), you will need a `runtime-config.json` file in your `public` directory in order for your local website to know the backend URLs, identity configuration, etc.
274
592
 
275
- Your website project is configured with a `load:runtime-config` target which you can use to pull down the `runtime-config.json` file from a deployed application:
593
+ Your website project is configured with a `load-runtime-config` target which you can use to pull down the `runtime-config.json` file from a deployed application:
276
594
 
277
- <NxCommands commands={['run <my-website>:"load:runtime-config"']} />
595
+ <NxCommands commands={['load-runtime-config <my-website>']} />
278
596
 
279
597
  :::note[Custom Stage Names]
280
598
  <Infrastructure>
281
599
  <Fragment slot="cdk">
282
- If you change the prefix for your stage names in your infrastructure project's `src/main.ts`, you will need to update the `load:runtime-config` target in your website's `project.json` file accordingly.
600
+ If you change the prefix for your stage names in your infrastructure project's `src/main.ts`, you will need to update the `load-runtime-config` target in your website's `project.json` file accordingly.
283
601
 
284
- Additionally it's worth noting that the `load:runtime-config` target assumes a single stage of your application is deployed to the environment you have AWS credentials for. You will need to adjust the command if you deploy multiple stages to the same account and region.
602
+ Additionally it's worth noting that the `load-runtime-config` target assumes a single stage of your application is deployed to the environment you have AWS credentials for. You will need to adjust the command if you deploy multiple stages to the same account and region.
285
603
  </Fragment>
286
604
  <Fragment slot="terraform">
287
- For Terraform projects, the `load:runtime-config` target copies the `runtime-config.json` file that was created after your most recent local `terraform apply`.
605
+ For Terraform projects, the `load-runtime-config` target copies the `runtime-config.json` file that was created after your most recent local `terraform apply`.
288
606
  </Fragment>
289
607
  </Infrastructure>
290
608
  :::
291
609
 
292
610
  ## Local Development Server
293
611
 
294
- You can run a local development server using either the `serve` or `serve-local` target.
612
+ The canonical command for local development is `dev`, which starts your website (and any local servers for APIs you've connected it to) with one command:
613
+
614
+ <NxCommands commands={['dev <my-website>']} />
615
+
616
+ The `serve` target is also available for when you need to control how much of your application runs locally versus pointing at deployed AWS infrastructure. For a broader overview of local development across connected projects, including how `dev` behaves for projects with multiple components, see the <Link path="guides/local-development">Local Development</Link> guide.
295
617
 
296
618
  ### Serve Target
297
619
 
@@ -303,46 +625,50 @@ You can run this target with the following command:
303
625
 
304
626
  This target is useful for working on website changes while pointing to "real" deployed APIs and other infrastructure.
305
627
 
306
- ### Serve Local Target
628
+ ### Dev Target
307
629
 
308
- The `serve-local` target starts a local development server for your website (with [Vite `MODE`](https://vite.dev/guide/env-and-mode) set to `serve-local`), as well as starting any local servers for APIs you have connected your website to via the <Link path="/guides/connection">Connection generator</Link>.
630
+ The `dev` target starts a local development server for your website (with [Vite `MODE`](https://vite.dev/guide/env-and-mode) set to `local-dev`), as well as starting any local servers for APIs you have connected your website to via the <Link path="/guides/connection">Connection generator</Link>.
309
631
 
310
632
  When your local website server is run via this target, `runtime-config.json` is automatically overridden to point to your locally running API urls.
311
633
 
312
634
  You can run this target with the following command:
313
635
 
314
- <NxCommands commands={['serve-local <my-website>']} />
636
+ <NxCommands commands={['dev <my-website>']} />
315
637
 
316
638
  This target is useful when you are working across your website and API and wish to quickly iterate without deploying your infrastructure.
317
639
 
318
- :::note[`dev` script]
319
- If no `dev` script exists in your root `package.json` when this generator runs, a `dev` script is added that invokes `serve-local` for the generated website, meaning you can also start the local development server with:
640
+ :::note[Workspace `dev` script]
641
+ Your workspace's root `package.json` includes a `dev` script that runs the `dev` target for every project that has one:
320
642
 
321
643
  <PackageManagerShortCommand commands={["dev"]} />
322
644
 
323
- This makes the first React website you generate the default `dev` target for the workspace. Subsequent websites do not overwrite the existing `dev` script — you can invoke their `serve-local` targets directly, or update the script manually.
645
+ This starts the local development server for your website (and any other projects with a `dev` target) in one command. To run just this website, use its own `dev` target (e.g. `nx dev <my-website>`).
324
646
  :::
325
647
 
326
648
  :::warning[Mock Authentication]
327
649
  When run in this mode and no `runtime-config.json` is present, if you have configured Cognito Authentication (via the <Link path="/guides/react-website-auth">`ts#website#auth` generator</Link>), login will be skipped and requests to your local servers will not include authentication headers.
328
650
 
329
- To enable login and authentication for `serve-local`, deploy your infrastructure and load runtime config.
651
+ To enable login and authentication for `dev`, deploy your infrastructure and load runtime config.
330
652
  :::
331
653
 
332
- :::tip[Serve-Local Behavior]
333
- When running with `serve-local`, you can specify any environment variables required by your APIs to point to other deployed AWS resources, for example:
654
+ :::tip[Dev Behavior]
655
+ When running with `dev`, you can specify any environment variables required by your APIs to point to other deployed AWS resources, for example:
334
656
 
335
- <NxCommands env={{DYNAMODB_TABLE_NAME: 'xxxxx'}} commands={['serve-local <my-website>']} />
657
+ <NxCommands env={{DYNAMODB_TABLE_NAME: 'xxxxx'}} commands={['dev <my-website>']} />
336
658
 
337
659
  Note that your local API servers will run with the AWS credentials you have configured locally.
338
660
  :::
339
661
 
340
662
  ## Building
341
663
 
342
- You can build your website using the `build` target. This use Vite to create a production bundle in the root `dist/packages/<my-website>/bundle` directory, as well as type-checking, compiling and linting your website.
664
+ You can build your website using the `build` target. This runs the `bundle`, `compile`, `test` and `lint` targets, type-checking, bundling, testing and linting your website.
343
665
 
344
666
  <NxCommands commands={['build <my-website>']} />
345
667
 
668
+ The `bundle` target uses Vite to create a production bundle in the root `dist/packages/<my-website>/bundle` directory. This is the deployable artifact consumed by your website infrastructure. You can run it on its own:
669
+
670
+ <NxCommands commands={['bundle <my-website>']} />
671
+
346
672
  ## Testing
347
673
 
348
674
  Testing your website is much like writing tests in a standard TypeScript project, so please refer to the <Link path="guides/typescript-project#testing">TypeScript project guide</Link> for more details.
@@ -353,72 +679,60 @@ You can run your tests using the `test` target:
353
679
 
354
680
  <NxCommands commands={['test <my-website>']} />
355
681
 
356
- ## Deploying Your Website
357
-
358
- The React website generator creates CDK or Terraform infrastructure as code based on your selected `iacProvider`. You can use this to deploy your website.
359
-
360
- <Infrastructure>
361
- <Fragment slot="cdk">
362
- To deploy your website, we recommend using the <Link path="guides/typescript-infrastructure">`ts#infra` generator</Link> to create a CDK application.
363
-
364
- You can use the CDK construct generated for you in `packages/common/constructs` to deploy your website.
365
-
366
- ```ts title="packages/infra/src/stacks/application-stack.ts" {3, 9}
367
- import { Stack } from 'aws-cdk-lib';
368
- import { Construct } from 'constructs';
369
- import { MyWebsite } from ':my-scope/common-constructs';
370
-
371
- export class ApplicationStack extends Stack {
372
- constructor(scope: Construct, id: string) {
373
- super(scope, id);
374
-
375
- new MyWebsite(this, 'MyWebsite');
376
- }
377
- }
378
- ```
379
-
380
- This sets up:
381
-
382
- 1. An S3 bucket for hosting your static website files
383
- 2. CloudFront distribution for global content delivery
384
- 3. WAF Web ACL for security protection
385
- 4. Origin Access Control for secure S3 access
386
- 5. Automatic deployment of website files and runtime configuration
387
- </Fragment>
388
- <Fragment slot="terraform">
389
- To deploy your website, we recommend using the <Link path="guides/terraform-infrastructure">`terraform#project` generator</Link> to create a Terraform project.
390
-
391
- You can use the Terraform module generated for you in `packages/common/terraform` to deploy your website.
392
-
393
- ```hcl title="packages/infra/src/main.tf" {3}
394
- # Deploy website
395
- module "my_website" {
396
- source = "../../common/terraform/src/app/static-websites/my-website"
397
-
398
- providers = {
399
- aws.us_east_1 = aws.us_east_1
400
- }
401
- }
402
- ```
403
-
404
- This sets up:
405
-
406
- 1. An S3 bucket for hosting your static website files
407
- 2. CloudFront distribution for global content delivery
408
- 3. WAF Web ACL for security protection (deployed in us-east-1)
409
- 4. Origin Access Control for secure S3 access
410
- 5. Automatic deployment of website files and runtime configuration
411
-
412
- :::note[WAF Provider Region]
413
- The `aws.us_east_1` provider is required for CloudFront and WAF resources, which must be deployed in the us-east-1 region. Make sure your Terraform configuration includes this provider:
414
-
415
- ```hcl title="packages/infra/src/providers.tf"
416
- provider "aws" {
417
- alias = "us_east_1"
418
- region = "us-east-1"
419
- }
420
- ```
421
- :::
422
- </Fragment>
423
- </Infrastructure>
424
-
682
+ ## Connections
683
+
684
+ Use the <Link path="guides/connection">`connection`</Link> generator to integrate this project with others in your workspace. The following connections involve this project:
685
+
686
+ <CardGrid>
687
+ <ConnectionCard
688
+ title="React to tRPC"
689
+ description="Call a tRPC API from a React website"
690
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-trpc`}
691
+ source="react"
692
+ target="trpc"
693
+ />
694
+ <ConnectionCard
695
+ title="React to FastAPI"
696
+ description="Call a Python FastAPI from a React website"
697
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-fastapi`}
698
+ source="react"
699
+ target="fastapi"
700
+ />
701
+ <ConnectionCard
702
+ title="React to Smithy API"
703
+ description="Call a Smithy API from a React website"
704
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-smithy`}
705
+ source="react"
706
+ target="smithy"
707
+ />
708
+ <ConnectionCard
709
+ title="React to Python Agent"
710
+ description="Call a Python Agent from a React website"
711
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-py-agent`}
712
+ source="react"
713
+ target="strands"
714
+ targetBadge="python"
715
+ />
716
+ <ConnectionCard
717
+ title="React to TypeScript Agent"
718
+ description="Call a TypeScript Agent from a React website"
719
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-ts-agent`}
720
+ source="react"
721
+ target="strands"
722
+ targetBadge="typescript"
723
+ />
724
+ <ConnectionCard
725
+ title="React to AG-UI Agent"
726
+ description="Call an Agent exposing the AG-UI protocol from a React website via CopilotKit"
727
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agui`}
728
+ source="react"
729
+ target="copilotkit"
730
+ />
731
+ <ConnectionCard
732
+ title="React Website to AgentCore Gateway"
733
+ description="Connect a React website to agents through an AgentCore Gateway"
734
+ href={`/nx-plugin-for-aws/${Astro.currentLocale || 'en'}/guides/connection/react-agentcore-gateway`}
735
+ source="react"
736
+ target="agentcore"
737
+ />
738
+ </CardGrid>