@aws/nx-plugin-mcp 1.11.0 → 1.12.0

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 CHANGED
@@ -25,12 +25,14 @@ var __exportAll = (all, flags) => {
25
25
  return flags & 2 ? target : Object.preventExtensions(target);
26
26
  };
27
27
  var __copyProps = (to, from, except, desc) => {
28
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
29
- key = keys[i];
30
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
31
- get: ((k) => from[k]).bind(null, key),
32
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
33
- });
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
30
+ desc = __getOwnPropDesc(from, key);
31
+ __defProp(to, key, {
32
+ get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
33
+ enumerable: !desc || desc.enumerable
34
+ });
35
+ }
34
36
  }
35
37
  return to;
36
38
  };
@@ -22613,67 +22615,67 @@ const NX_VERSION = {
22613
22615
  "deepmerge-ts": "8.0.2",
22614
22616
  mysql2: "3.24.6",
22615
22617
  effect: "3.22.5",
22616
- "@aws-sdk/client-dynamodb": "3.1175.0",
22617
- "@aws-sdk/client-api-gateway": "3.1175.0",
22618
- "@aws-sdk/client-iam": "3.1175.0",
22619
- "@aws-sdk/client-bedrock-agentcore": "3.1175.0",
22620
- "@aws-sdk/client-bedrock-runtime": "3.1175.0",
22621
- "@aws-sdk/client-greengrassv2": "3.1175.0",
22622
- "@aws-sdk/client-s3": "3.1175.0",
22623
- "@aws-sdk/client-sts": "3.1175.0",
22624
- "@aws-sdk/client-cognito-identity-provider": "3.1175.0",
22625
- "@aws-sdk/credential-providers": "3.1175.0",
22626
- "@aws-sdk/credential-provider-cognito-identity": "3.972.84",
22627
- "@aws-sdk/client-secrets-manager": "3.1175.0",
22628
- "@aws-sdk/rds-signer": "3.1175.0",
22618
+ "@aws-sdk/client-dynamodb": "3.1179.0",
22619
+ "@aws-sdk/client-api-gateway": "3.1179.0",
22620
+ "@aws-sdk/client-iam": "3.1179.0",
22621
+ "@aws-sdk/client-bedrock-agentcore": "3.1179.0",
22622
+ "@aws-sdk/client-bedrock-runtime": "3.1179.0",
22623
+ "@aws-sdk/client-greengrassv2": "3.1179.0",
22624
+ "@aws-sdk/client-s3": "3.1179.0",
22625
+ "@aws-sdk/client-sts": "3.1179.0",
22626
+ "@aws-sdk/client-cognito-identity-provider": "3.1179.0",
22627
+ "@aws-sdk/credential-providers": "3.1179.0",
22628
+ "@aws-sdk/credential-provider-cognito-identity": "3.972.85",
22629
+ "@aws-sdk/client-secrets-manager": "3.1179.0",
22630
+ "@aws-sdk/rds-signer": "3.1179.0",
22629
22631
  "@smithy/server-apigateway": "0.3.5",
22630
22632
  "@smithy/server-node": "0.3.5",
22631
- "@aws-lambda-powertools/logger": "2.36.0",
22632
- "@aws-lambda-powertools/metrics": "2.36.0",
22633
- "@aws-lambda-powertools/parameters": "2.36.0",
22634
- "@aws-lambda-powertools/tracer": "2.36.0",
22635
- "@aws-lambda-powertools/parser": "2.36.0",
22636
- "@aws-sdk/client-appconfigdata": "3.1175.0",
22633
+ "@aws-lambda-powertools/logger": "2.37.0",
22634
+ "@aws-lambda-powertools/metrics": "2.37.0",
22635
+ "@aws-lambda-powertools/parameters": "2.37.0",
22636
+ "@aws-lambda-powertools/tracer": "2.37.0",
22637
+ "@aws-lambda-powertools/parser": "2.37.0",
22638
+ "@aws-sdk/client-appconfigdata": "3.1179.0",
22637
22639
  "@middy/core": "7.9.2",
22638
- "@nxlv/python": "23.5.0",
22640
+ "@nxlv/python": "23.6.0",
22639
22641
  "@nx-extend/terraform": "10.4.1",
22640
- nx: "24.0.6",
22641
- "@nx/devkit": "24.0.6",
22642
- "@nx/js": "24.0.6",
22643
- "@nx/react": "24.0.6",
22644
- "@nx/vite": "24.0.6",
22645
- "@nx/vitest": "24.0.6",
22646
- "@nx/workspace": "24.0.6",
22647
- "create-nx-workspace": "24.0.6",
22642
+ nx: "24.1.0",
22643
+ "@nx/devkit": "24.1.0",
22644
+ "@nx/js": "24.1.0",
22645
+ "@nx/react": "24.1.0",
22646
+ "@nx/vite": "24.1.0",
22647
+ "@nx/vitest": "24.1.0",
22648
+ "@nx/workspace": "24.1.0",
22649
+ "create-nx-workspace": "24.1.0",
22648
22650
  "@swc-node/register": "1.12.1",
22649
22651
  "@swc/core": "1.16.22",
22650
22652
  "@modelcontextprotocol/sdk": "1.32.2",
22651
22653
  "@modelcontextprotocol/client": "2.4.0",
22652
- "@modelcontextprotocol/inspector": "2.16.0",
22654
+ "@modelcontextprotocol/inspector": "2.17.0",
22653
22655
  "@ag-ui/a2ui-toolkit": "0.0.5",
22654
22656
  "@ag-ui/aws-strands": "1.0.2",
22655
22657
  "@ag-ui/client": "1.0.5",
22656
22658
  "@ag-ui/core": "1.0.5",
22657
22659
  "@ag-ui/encoder": "1.0.5",
22658
22660
  "agent-chat-cli": "0.3.0",
22659
- "@copilotkit/react-core": "1.90.0",
22661
+ "@copilotkit/react-core": "1.90.2",
22660
22662
  rxjs: "7.8.2",
22661
- "@strands-agents/sdk": "1.26.0",
22663
+ "@strands-agents/sdk": "1.27.0",
22662
22664
  "@tanstack/react-router": "1.170.46",
22663
- "@tanstack/router-plugin": "1.169.0",
22664
- "@tanstack/router-generator": "1.168.0",
22665
+ "@tanstack/router-plugin": "1.170.0",
22666
+ "@tanstack/router-generator": "1.169.0",
22665
22667
  "@tanstack/virtual-file-routes": "1.162.0",
22666
22668
  "@tanstack/router-utils": "1.163.0",
22667
- "@cloudscape-design/board-components": "3.0.250",
22668
- "@cloudscape-design/chat-components": "1.0.194",
22669
- "@cloudscape-design/components": "3.0.1421",
22669
+ "@cloudscape-design/board-components": "3.0.252",
22670
+ "@cloudscape-design/chat-components": "1.0.197",
22671
+ "@cloudscape-design/components": "3.0.1428",
22670
22672
  "@cloudscape-design/global-styles": "1.0.72",
22671
- "@tanstack/react-query": "5.108.2",
22672
- "@tanstack/react-query-devtools": "5.108.2",
22673
- "@trpc/tanstack-react-query": "11.29.7",
22674
- "@trpc/client": "11.29.7",
22675
- "@trpc/server": "11.29.7",
22676
- "@types/node": "26.6.6",
22673
+ "@tanstack/react-query": "5.108.4",
22674
+ "@tanstack/react-query-devtools": "5.108.4",
22675
+ "@trpc/tanstack-react-query": "11.32.2",
22676
+ "@trpc/client": "11.32.2",
22677
+ "@trpc/server": "11.32.2",
22678
+ "@types/node": "26.6.11",
22677
22679
  "@types/aws-lambda": "8.10.164",
22678
22680
  "@types/cors": "2.8.19",
22679
22681
  "@types/js-yaml": "4.0.9",
@@ -22684,10 +22686,10 @@ const NX_VERSION = {
22684
22686
  "@smithy/node-config-provider": "4.6.2",
22685
22687
  "@smithy/node-http-handler": "4.14.2",
22686
22688
  "@smithy/types": "4.20.0",
22687
- "@vitest/coverage-v8": "5.1.1",
22688
- "@vitest/ui": "5.1.1",
22689
+ "@vitest/coverage-v8": "5.1.2",
22690
+ "@vitest/ui": "5.1.2",
22689
22691
  "@astrojs/react": "6.0.6",
22690
- "@astrojs/starlight": "0.43.1",
22692
+ "@astrojs/starlight": "0.43.2",
22691
22693
  astro: "7.4.13",
22692
22694
  cookie: "2.0.2",
22693
22695
  aws4fetch: "1.0.20",
@@ -22705,7 +22707,7 @@ const NX_VERSION = {
22705
22707
  esbuild: "0.28.2",
22706
22708
  "event-source-polyfill": "1.0.31",
22707
22709
  "@types/event-source-polyfill": "1.0.5",
22708
- "@biomejs/biome": "2.6.8",
22710
+ "@biomejs/biome": "2.6.9",
22709
22711
  "@prisma/adapter-mariadb": "7.10.1",
22710
22712
  "@prisma/adapter-pg": "7.10.1",
22711
22713
  "@prisma/client": "7.10.1",
@@ -22718,7 +22720,7 @@ const NX_VERSION = {
22718
22720
  "@types/fs-extra": "11.0.4",
22719
22721
  "js-yaml": "4.3.2",
22720
22722
  mariadb: "3.5.5",
22721
- mise: "2026.11.12",
22723
+ mise: "2026.11.15",
22722
22724
  npm: "12.2.3",
22723
22725
  "npm-check-updates": "23.1.1",
22724
22726
  "oidc-client-ts": "3.5.0",
@@ -22727,25 +22729,25 @@ const NX_VERSION = {
22727
22729
  "react-oidc-context": "3.3.1",
22728
22730
  react: "19.3.1",
22729
22731
  "react-dom": "19.3.1",
22730
- rolldown: "1.3.3",
22732
+ rolldown: "1.3.4",
22731
22733
  "rolldown-plugin-dts": "0.30.2",
22732
22734
  shx: "0.4.0",
22733
22735
  "simple-git": "4.1.0",
22734
22736
  "source-map-support": "0.5.21",
22735
- "starlight-blog": "0.30.2",
22737
+ "starlight-blog": "0.31.0",
22736
22738
  tailwindcss: "4.3.5",
22737
22739
  "@tailwindcss/vite": "4.3.5",
22738
22740
  tsx: "4.23.15",
22739
- "lucide-react": "1.77.0",
22741
+ "lucide-react": "1.84.0",
22740
22742
  "radix-ui": "1.8.1",
22741
- shadcn: "4.23.0",
22743
+ shadcn: "4.23.1",
22742
22744
  "tw-animate-css": "1.4.0",
22743
- vite: "8.3.8",
22745
+ vite: "8.4.0",
22744
22746
  typescript: "6.0.3",
22745
- vitest: "5.1.1",
22747
+ vitest: "5.1.2",
22746
22748
  jsdom: "29.1.1",
22747
22749
  zod: "4.6.7",
22748
- ws: "8.23.0"
22750
+ ws: "8.23.1"
22749
22751
  }.nx;
22750
22752
  // ../nx-plugin/src/utils/commands.ts
22751
22753
  /**
@@ -56273,6 +56275,14 @@ const generatorsJsonEntries = {
56273
56275
  "guidePages": ["react-website-auth"],
56274
56276
  "hidden": true
56275
56277
  },
56278
+ "ts#verified-access": {
56279
+ "factory": "./src/ts/verified-access/generator",
56280
+ "schema": "./src/ts/verified-access/schema.json",
56281
+ "description": "Put an AWS Verified Access door in front of a private REST API",
56282
+ "metric": "g90",
56283
+ "experimental": true,
56284
+ "guidePages": ["ts-verified-access"]
56285
+ },
56276
56286
  "ts#react-website#runtime-config": {
56277
56287
  "factory": "./src/ts/react-website/runtime-config/generator",
56278
56288
  "schema": "./src/ts/react-website/runtime-config/schema.json",
@@ -940,11 +940,16 @@ aws cloudformation describe-stack-resources --stack-name <stack-name> \
940
940
 
941
941
  Then remove them with `aws logs delete-log-group --log-group-name <log-group-name>` and `aws kms schedule-key-deletion --key-id <key-id> --pending-window-in-days 7`, seven days being the shortest window KMS accepts.
942
942
 
943
+ API Gateway accepts one VPC link deletion every 30 seconds per account, and that quota cannot be raised. Every `http-ecs` API in a stack that uses the same VPC shares one VPC link, so a stack deletes a single link however many of these APIs it holds. Nothing is shared across a stack boundary, and a nested stack counts as its own stack, so stacks torn down at the same time in one account can still clash. If a stack ends in `DELETE_FAILED` on a VPC link, wait 30 seconds and delete the stack again.
944
+
945
+ Upgrading from a release that gave each API its own link needs one check, if the stack already deployed three or more of these APIs on one VPC. The next deploy keeps the first API's link and deletes the others in a single cleanup phase, so the second deletion goes out seconds after the first and API Gateway throttles it. The stack events then show `DELETE_FAILED` on a VPC link and on its security group, which cannot be deleted while the link still uses it, and the update takes about 20 minutes longer while CloudFormation retries both in the same cleanup. It deletes them on a later attempt and the update ends `UPDATE_COMPLETE`. Once it has completed, check the stack events, or the VPC links list in the API Gateway console, for a link still in `DELETE_FAILED`. Wait 30 seconds and delete any link in that state, then its security group. A link left behind counts against the ten-per-Region quota until it is gone; its security group does not.
946
+
943
947
  ### Limits
944
948
 
945
949
  - **Integration timeout.** API Gateway HTTP APIs cap an integration at about 30 seconds. An operation that takes longer than that fails at the gateway however long the container keeps working.
946
950
  - **No streaming.** Streaming operations need the `rest-lambda` infrastructure. An HTTP API cannot stream a response.
947
951
  - **Payload size.** Requests and responses follow API Gateway's 10 MB limit.
952
+ - **VPC links per Region.** API Gateway allows ten VPC links per account per Region, raisable through Service Quotas. APIs sharing a stack and a VPC share one link, so what counts against the quota is stacks and VPCs rather than APIs.
948
953
  - **One service for every operation.** `integrationPattern` is `shared`: there is one container service, and every route is routed to it. The option always resolves to `shared` for this infrastructure, and `isolated` is ignored with a warning.
949
954
 
950
955
  ### Cost
@@ -182,6 +182,13 @@ export class ApplicationStack extends Stack {
182
182
 
183
183
  The `UserIdentity` construct automatically adds the necessary <Link path="guides/react-website#runtime-configuration">Runtime Configuration</Link> to ensure that your website can point to the correct Cognito User Pool for authentication.
184
184
 
185
+ If your website is served from a URL other than a CloudFront distribution in the same stack, permit sign-in to redirect there with `addCallbackUrl`:
186
+
187
+ ```ts
188
+ const identity = new UserIdentity(this, 'Identity');
189
+ identity.addCallbackUrl('https://app.example.com');
190
+ ```
191
+
185
192
  :::note[SMS role retention]
186
193
  The User Pool is backed by an IAM role that Cognito assumes to send SMS messages. The role's removal policy mirrors the User Pool's — by default CDK's `UserPool` uses `RemovalPolicy.RETAIN`, so on `cdk destroy` both the User Pool and its SMS role are retained and will need to be cleaned up manually if no longer needed.
187
194
  :::
@@ -485,6 +485,61 @@ module "my_website" {
485
485
 
486
486
  You will also need to create DNS records (for example in Route 53) pointing your domain at the CloudFront distribution.
487
487
 
488
+ ### Hosting through API Gateway
489
+
490
+ Instead of CloudFront, you can serve your website through the routes of an existing REST API, on the API's own origin, with no CloudFront distribution and no cross-origin requests. This is supported with CDK only.
491
+
492
+ Generate the API first (with <Link path="guides/ts-smithy-api">`ts#smithy-api`</Link>, or with <Link path="guides/trpc">`ts#trpc-api`</Link> or <Link path="guides/fastapi">`py#fast-api`</Link> using REST infrastructure), then generate your website with `hosting` set to `api-gateway`:
493
+
494
+ <RunGenerator generator="ts#react-website" requiredParameters={{ name: 'my-website', hosting: 'api-gateway', apiProject: 'my-api' }} />
495
+
496
+ The generated website construct then extends `ApiGatewayStaticWebsite`, which adds these routes to the API:
497
+
498
+ - `GET /` and any path without a file extension return `index.html`, so routes of your app load directly.
499
+ - `GET /runtime-config.json` returns the <Link path="guides/react-website#runtime-configuration">runtime configuration</Link>.
500
+ - `GET /assets/{proxy+}` returns the files named by their content's hash, cached for a year.
501
+ - Any other path with a file extension returns that file from the bundle.
502
+
503
+ These routes need no authorization, while the API's operations keep theirs. For an API with IAM authorization, the resource policy allows anyone every `GET` except the API's own IAM operations, which still need an IAM grant. The API's Web ACL covers the website too.
504
+
505
+ The website is built with a relative Vite `base` (`./`), and the router's `basepath` comes from the page's `<base href>`. The construct deploys a copy of `index.html` for each path the API is reached at, such as `/prod/` on the execute-api URL or a custom domain's base path, and serves each request the copy for its domain. So one build serves every URL of the API.
506
+
507
+ Pass your API to the website:
508
+
509
+ ```diff lang="ts" title="packages/infra/src/stacks/application-stack.ts"
510
+ const identity = new UserIdentity(this, 'Identity');
511
+ const api = new MyApi(this, 'MyApi', {
512
+ integrations: MyApi.defaultIntegrations(this).build(),
513
+ });
514
+ api.grantInvokeAccess(identity.identityPool.authenticatedRole);
515
+ - new MyWebsite(this, 'MyWebsite');
516
+ + new MyWebsite(this, 'MyWebsite', { api });
517
+ ```
518
+
519
+ The User Pool's web client permits every URL the website is served at as a callback, so sign-in returns to the URL it started from.
520
+
521
+ #### Custom domains
522
+
523
+ The website is also served from each custom domain that maps the API, whether you set the API's `domainName`, call `addDomainName`, or map it with a `DomainName` of your own, before or after the website construct. On each domain it is served under the mapping's base path: at `https://app.example.com` for an empty base path, or at `https://example.com/app/` for `app`. The execute-api URL keeps serving it too.
524
+
525
+ - `url` is always the execute-api URL, such as `https://<api-id>.execute-api.<region>.amazonaws.com/prod/`. It exists for every API and does not depend on which domains you add. The stack output `WebsiteUrl` names it.
526
+ - `urls` lists every URL the website is served at: the execute-api URL first, then each custom domain sorted by domain name and base path. The stack output `WebsiteUrls` lists them, separated by spaces.
527
+
528
+ The construct never picks one domain over another. If you want a canonical domain, name it yourself, for example in an output of your own:
529
+
530
+ ```ts
531
+ new CfnOutput(this, 'AppUrl', { value: 'https://app.example.com' });
532
+ ```
533
+
534
+ #### Pitfalls
535
+
536
+ - The deployed website runs under a path such as `/prod/`, while the local dev server runs at the root. Link through the router or with relative URLs: a link starting with `/` works locally and breaks once deployed.
537
+ - The runtime configuration names one URL for the API, which the website calls from whichever URL it was loaded at. The API allows every origin by default. If you restrict its CORS origins with `restrictCorsTo`, include the origin of each of the website's `urls`.
538
+ - Keep `<base href="%BASE_URL%" />` in `index.html`. The construct writes the website's path there in each copy it deploys, and the build loads everything relative to it.
539
+ - The construct refuses to synthesise for an API with a `GET` operation at `/` or at a top-level path parameter such as `/{id}`, which would take the paths the website is served from.
540
+ - Switching an existing website from CloudFront replaces its CloudFront website construct only if you have not changed it. Otherwise the generator stops: move your changes aside, delete the construct, and run the generator again.
541
+ - If `RuntimeConfig`, `CognitoAuth`, `UserIdentity` or your API's construct was generated by an older version of the plugin, the generator stops and names it. Run `nx migrate @aws/nx-plugin`, apply the migrations, and run the generator again.
542
+
488
543
  ## Runtime Configuration
489
544
 
490
545
  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.
@@ -1058,11 +1058,16 @@ aws cloudformation describe-stack-resources --stack-name <stack-name> \
1058
1058
 
1059
1059
  Then remove them with `aws logs delete-log-group --log-group-name <log-group-name>` and `aws kms schedule-key-deletion --key-id <key-id> --pending-window-in-days 7`, seven days being the shortest window KMS accepts.
1060
1060
 
1061
+ API Gateway accepts one VPC link deletion every 30 seconds per account, and that quota cannot be raised. Every `http-ecs` API in a stack that uses the same VPC shares one VPC link, so a stack deletes a single link however many of these APIs it holds. Nothing is shared across a stack boundary, and a nested stack counts as its own stack, so stacks torn down at the same time in one account can still clash. If a stack ends in `DELETE_FAILED` on a VPC link, wait 30 seconds and delete the stack again.
1062
+
1063
+ Upgrading from a release that gave each API its own link needs one check, if the stack already deployed three or more of these APIs on one VPC. The next deploy keeps the first API's link and deletes the others in a single cleanup phase, so the second deletion goes out seconds after the first and API Gateway throttles it. The stack events then show `DELETE_FAILED` on a VPC link and on its security group, which cannot be deleted while the link still uses it, and the update takes about 20 minutes longer while CloudFormation retries both in the same cleanup. It deletes them on a later attempt and the update ends `UPDATE_COMPLETE`. Once it has completed, check the stack events, or the VPC links list in the API Gateway console, for a link still in `DELETE_FAILED`. Wait 30 seconds and delete any link in that state, then its security group. A link left behind counts against the ten-per-Region quota until it is gone; its security group does not.
1064
+
1061
1065
  ### Limits
1062
1066
 
1063
1067
  - **Integration timeout.** API Gateway HTTP APIs cap an integration at about 30 seconds. A procedure that takes longer than that fails at the gateway however long the container keeps working.
1064
1068
  - **No streaming.** tRPC subscriptions need the `rest-lambda` infrastructure. An HTTP API cannot stream a response.
1065
1069
  - **Payload size.** Requests and responses follow API Gateway's 10 MB limit.
1070
+ - **VPC links per Region.** API Gateway allows ten VPC links per account per Region, raisable through Service Quotas. APIs sharing a stack and a VPC share one link, so what counts against the quota is stacks and VPCs rather than APIs.
1066
1071
  - **One service for every operation.** `integrationPattern` is `shared`: there is one container service, and every route is routed to it. The option always resolves to `shared` for this infrastructure, and `isolated` is ignored with a warning.
1067
1072
 
1068
1073
  ### Cost
@@ -0,0 +1,103 @@
1
+ ---
2
+ title: Verified Access
3
+ description: Put an AWS Verified Access door in front of a private REST API
4
+ generator: ts#verified-access
5
+ ---
6
+
7
+ import { FileTree } from '@astrojs/starlight/components';
8
+ import Link from '@components/link.astro';
9
+ import RunGenerator from '@components/run-generator.astro';
10
+ import GeneratorParameters from '@components/generator-parameters.astro';
11
+
12
+ The Verified Access generator makes a REST API private to a VPC, and puts an [AWS Verified Access](https://docs.aws.amazon.com/verified-access/latest/ug/what-is-verified-access.html) endpoint (the door) in front of it, on a domain of your own. The API then has no public endpoint. Users sign in at the door with your Cognito User Pool, and the door applies a [Cedar](https://docs.aws.amazon.com/verified-access/latest/ug/auth-policies.html) policy before any request reaches the API, which still checks its own authorization.
13
+
14
+ Together with a website <Link path="guides/react-website#hosting-through-api-gateway">hosted through the API</Link>, this serves both the website and the API from the door, with no public endpoint for either.
15
+
16
+ ## Usage
17
+
18
+ Generate a REST API first, for example with <Link path="guides/ts-smithy-api">`ts#smithy-api`</Link>, and add <Link path="guides/react-website-auth">authentication</Link> to your website so the workspace has a User Pool. Then run:
19
+
20
+ <RunGenerator generator="ts#verified-access" requiredParameters={{ apiProject: 'my-api' }} />
21
+
22
+ ### Options
23
+
24
+ <GeneratorParameters generator="ts#verified-access" />
25
+
26
+ ## Generator Output
27
+
28
+ The generator adds a construct to your shared constructs. It supports CDK only.
29
+
30
+ <FileTree>
31
+
32
+ - packages/common/constructs/src/core
33
+ - verified-access.ts The door, its trust provider, Web ACL and DNS record, and the private custom domain it forwards to
34
+
35
+ </FileTree>
36
+
37
+ ## Infrastructure Usage
38
+
39
+ Add the door to your stack, after the API. It needs a VPC of yours to reach the private API from, such as an existing one you look up:
40
+
41
+ ```diff lang="ts" title="packages/infra/src/stacks/application-stack.ts"
42
+ +import { Vpc } from 'aws-cdk-lib/aws-ec2';
43
+ +import { HostedZone } from 'aws-cdk-lib/aws-route53';
44
+ import {
45
+ MyApi,
46
+ MyWebsite,
47
+ UserIdentity,
48
+ + VerifiedAccess,
49
+ } from '@my-scope/common-constructs';
50
+
51
+ const identity = new UserIdentity(this, 'Identity');
52
+ const api = new MyApi(this, 'MyApi', {
53
+ integrations: MyApi.defaultIntegrations(this).build(),
54
+ });
55
+ api.grantInvokeAccess(identity.identityPool.authenticatedRole);
56
+ + new VerifiedAccess(this, 'Door', {
57
+ + api,
58
+ + identity,
59
+ + vpc: Vpc.fromLookup(this, 'Vpc', { vpcId: 'vpc-0123456789abcdef0' }),
60
+ + hostedZone: HostedZone.fromHostedZoneAttributes(this, 'Zone', {
61
+ + hostedZoneId: 'Z0123456789EXAMPLE',
62
+ + zoneName: 'example.com',
63
+ + }),
64
+ + recordName: 'app',
65
+ + });
66
+ ```
67
+
68
+ The door makes the API private to an execute-api endpoint (`door.executeApiEndpoint`), and denies any call not made through it. It allows nothing itself, so the API's own grants still decide who may call what. It points the API's entry in the <Link path="guides/react-website#runtime-configuration">runtime configuration</Link> at `https://app.example.com/prod/`, and allows sign-in to return there.
69
+
70
+ The VPC needs a subnet in at least one Availability Zone that the execute-api endpoint can use. In it, the door creates:
71
+
72
+ - unless you pass an `endpoint`, an execute-api interface endpoint, with a security group that admits HTTPS from the door alone, so nothing else in the VPC can skip its sign-in;
73
+ - a security group for the Verified Access endpoint, allowed to the execute-api endpoint on port 443.
74
+
75
+ It also creates:
76
+
77
+ - a certificate for `app.example.com`, validated in the hosted zone;
78
+ - a Cognito client of its own, and an OIDC trust provider on your User Pool;
79
+ - a Verified Access instance, group and endpoint, with access logs and a regional Web ACL;
80
+ - a CNAME record for `app.example.com`, pointing at the endpoint;
81
+ - a private custom domain for the API's stage on `app.example.com`, reached through the endpoint.
82
+
83
+ ### Choosing the VPC
84
+
85
+ `vpc` is required: an existing VPC from `Vpc.fromLookup`, or one your stack creates. If it already has an execute-api endpoint, pass that as `endpoint`, and the door allows its own security group to it on port 443 instead of creating another. An endpoint the door creates has private DNS turned off, so other calls to API Gateway from the VPC are unchanged.
86
+
87
+ By default the door admits anyone whose email address the User Pool has verified. Pass a Cedar `policyDocument` to change that, referring to the user's claims as `context.cognito`.
88
+
89
+ This works with a website <Link path="guides/react-website#hosting-through-api-gateway">hosted through the API</Link>, which the door then serves with the API. Each adds its own statement to the stack, in any order.
90
+
91
+ ### Pitfalls
92
+
93
+ - The hosted zone must be a public zone delegated from its parent, so ACM can validate the certificate and browsers can resolve the door's domain.
94
+ - The first deploy takes about 20 minutes, most of it creating the Verified Access endpoint.
95
+ - Verified Access is charged per hour for each application endpoint, as well as per GB of traffic, whether or not it is used. See [AWS Verified Access pricing](https://aws.amazon.com/verified-access/pricing/).
96
+ - Each door is a Verified Access instance, and instances count against an [account quota](https://docs.aws.amazon.com/verified-access/latest/ug/verified-access-quotas.html).
97
+ - The User Pool requires MFA by default, so users set it up at their first sign-in at the door.
98
+ - The default policy refuses users whose email address the User Pool has not verified.
99
+ - A private API is reachable only through its VPC endpoint, so the website's `serve` target cannot call the deployed API. Use its <Link path="guides/react-website#dev-target">`dev` target</Link>, which runs the API's local server.
100
+ - A URL's `#fragment` is not sent to the server, so it is lost through the door's sign-in. The path and query are kept.
101
+ - A private API can be mapped only to a private custom domain name, which the door creates. So the door refuses, at synth, an API with a public custom domain name or base path mapping of its own.
102
+ - User Pools are retained when the stack is deleted, and have deletion protection on. Delete them by hand afterwards.
103
+ - If `UserIdentity`, your API's construct or the website's `useSigV4` hook was generated by an older version of the plugin, the generator stops and names it. Run `nx migrate @aws/nx-plugin`, apply the migrations, and run the generator again.
package/generators.json CHANGED
@@ -357,6 +357,14 @@
357
357
  "guidePages": ["react-website-auth"],
358
358
  "hidden": true
359
359
  },
360
+ "ts#verified-access": {
361
+ "factory": "./src/ts/verified-access/generator",
362
+ "schema": "./src/ts/verified-access/schema.json",
363
+ "description": "Put an AWS Verified Access door in front of a private REST API",
364
+ "metric": "g90",
365
+ "experimental": true,
366
+ "guidePages": ["ts-verified-access"]
367
+ },
360
368
  "ts#react-website#runtime-config": {
361
369
  "factory": "./src/ts/react-website/runtime-config/generator",
362
370
  "schema": "./src/ts/react-website/runtime-config/schema.json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -85,6 +85,17 @@
85
85
  "default": "inherit",
86
86
  "x-prompt": "Which provider would you like to manage your infrastructure? (default: inherit)"
87
87
  },
88
+ "hosting": {
89
+ "type": "string",
90
+ "description": "How the website is served: from CloudFront, or through the routes of an existing REST API, on the API's own origin. API Gateway hosting requires CDK.",
91
+ "enum": ["cloudfront", "api-gateway"],
92
+ "default": "cloudfront"
93
+ },
94
+ "apiProject": {
95
+ "type": "string",
96
+ "description": "The REST API project to serve the website through, when hosting is api-gateway.",
97
+ "x-dropdown": "projects"
98
+ },
88
99
  "preferInstallDependencies": {
89
100
  "type": "boolean",
90
101
  "description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "ts#verified-access",
4
+ "title": "ts#verified-access",
5
+ "x-label": "Verified Access",
6
+ "description": "Put an AWS Verified Access door in front of a REST API, made private to a VPC",
7
+ "type": "object",
8
+ "properties": {
9
+ "apiProject": {
10
+ "type": "string",
11
+ "description": "The REST API project to put behind the door",
12
+ "$default": {
13
+ "$source": "argv",
14
+ "index": 0
15
+ },
16
+ "x-prompt": "Select the REST API project to put behind the door",
17
+ "x-dropdown": "projects"
18
+ },
19
+ "iac": {
20
+ "type": "string",
21
+ "description": "The preferred IaC provider. Only CDK is supported. By default this is inherited from your initial selection.",
22
+ "enum": ["inherit", "cdk"],
23
+ "default": "inherit"
24
+ }
25
+ },
26
+ "required": ["apiProject"]
27
+ }