@aws/nx-plugin-mcp 1.0.0-rc.37 → 1.0.0-rc.39

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.
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: Concepts
3
+ description: Key concepts.
4
+ ---
5
+ import Link from '@components/link.astro';
6
+ import FrameworkLogos from '@components/framework-logos.astro';
7
+
8
+ The `@aws/nx-plugin` is an [Nx](https://nx.dev/) plugin that provides a toolkit for building and deploying full-stack applications on AWS. It gives you a collection of [Generators](#generators) which scaffold production-ready application code _and_ the infrastructure to deploy it — type-safe, locally runnable, and ready to ship.
9
+
10
+ Rather than starting from a blank page, you (or your AI agent) pick the components you need — APIs, websites, authentication, AI agents, infrastructure — provide a few configuration options, and the plugin generates best-practice starter code. It even wires projects together for you (including updating existing files via AST transforms) to produce type-safe clients between your frontend and backend.
11
+
12
+ ## Built on Nx and its generators
13
+
14
+ [Nx](https://nx.dev) is a smart build framework for managing monorepos. It is language agnostic, letting TypeScript, Python, infrastructure and more live and build together in a single workspace. Its build system uses caching and dependency graph analysis to only rebuild what changed and run tasks in parallel, keeping testing, linting and building fast as your workspace grows.
15
+
16
+ Every piece of functionality in the `@aws/nx-plugin` is delivered as an Nx [Generator](https://nx.dev/features/generate-code) — automated scaffolding that produces consistent code structures from predefined templates. Generators can be invoked via the [Nx CLI](https://nx.dev/features/generate-code#invoke-generators), the [Nx Console IDE plugin](https://nx.dev/getting-started/editor-setup), or by your AI assistant through the <Link path="/get_started/building-with-ai">Nx Plugin for AWS MCP Server</Link>.
17
+
18
+ Because every component is a generator, you only add what you need, when you need it. Start with an API, add a website later, connect them when you're ready — each step is a single command.
19
+
20
+ ## Build with proven frameworks
21
+
22
+ The `@aws/nx-plugin` deliberately avoids building custom abstractions on top of the tools you already know. Instead of inventing bespoke frameworks, runtimes or wrappers, it scaffolds idiomatic code using established, widely-adopted open-source projects. This means your existing skills carry over directly, you can rely on the official documentation for each framework, and you're never locked into a layer that only this plugin understands.
23
+
24
+ The generated code stands on the shoulders of best-in-class frameworks, including:
25
+
26
+ <FrameworkLogos />
27
+
28
+ The plugin's value is in how these pieces are configured and connected together for AWS — not in replacing them.
29
+
30
+ ## Open for modification
31
+
32
+ All generated code is _your_ code. The `@aws/nx-plugin` is a build-time tool, not a runtime dependency — once a generator has run, the plugin is no longer in the picture. You can read every file it produced, commit it, and change it however you like.
33
+
34
+ This means:
35
+
36
+ - **No escape hatches.** There's no proprietary configuration surface to learn or wrestle with when you need to do something the generator didn't anticipate. You edit the generated code directly, the same way you would edit any code you wrote yourself.
37
+ - **No new layers of abstraction.** Generators emit plain, idiomatic code for the underlying frameworks. There's no wrapper API or magic indirection sitting between you and React, tRPC, FastAPI, CDK or any of the other tools — what you see is what runs.
38
+ - **The plugin isn't a dependency.** It generates code and steps out of the way. Your application doesn't import or rely on `@aws/nx-plugin` at runtime, so you're never blocked by it and never locked in.
39
+
40
+ If you don't like something in the generated code, you are free to modify it. Generators give you a head start, not a cage.
41
+
42
+ ## Minimal dependencies
43
+
44
+ The `@aws/nx-plugin` strives to keep the number of global dependencies to a minimum. What you need to get started boils down to which generators you invoke.
45
+
46
+ As an example, any TypeScript-based generator will only require [Node](https://nodejs.org/en/download) to be installed. For Python-based projects, [UV](https://docs.astral.sh/uv/) is the only requirement.
47
+
48
+ ## Type safety
49
+
50
+ The `@aws/nx-plugin` employs type-safety to simplify the developer experience via IDE completions, while also eliminating runtime errors which would otherwise only surface in a non type-safe implementation. As such, all components that are vended are type-safe by default.
51
+
52
+ Type safety flows across project boundaries: when you connect a website to an API, the generated client shares types with the backend, so a change to an API contract surfaces as a compile-time error in your frontend rather than a bug in production. Refactor with confidence.
@@ -0,0 +1,176 @@
1
+ ---
2
+ title: Add to an Existing Project
3
+ description: How to adopt @aws/nx-plugin in an existing Nx workspace or non-Nx monorepo.
4
+ ---
5
+ import { Steps, Aside, FileTree } from '@astrojs/starlight/components';
6
+ import Link from '@components/link.astro';
7
+ import Snippet from '@components/snippet.astro';
8
+ import Drawer from '@components/drawer.astro';
9
+ import NxCommands from '@components/nx-commands.astro';
10
+ import NxInitCommand from '@components/nx-init-command.astro';
11
+ import TsConfigBaseCompilerOptions from '@components/tsconfig-base-compiler-options.astro';
12
+ import GeneratorParameters from '@components/generator-parameters.astro';
13
+
14
+ Not every project starts with `pnpm create @aws/nx-workspace`. If you already have an [Nx workspace](https://nx.dev) — or a monorepo you can add Nx to — you can adopt `@aws/nx-plugin` incrementally without recreating your project.
15
+
16
+ <Aside type="tip">
17
+ You can use your agentic coding tool of choice to add the plugin for you, using the <Link path="get_started/building-with-ai">MCP server</Link>. Try the prompt:
18
+
19
+ > Add the Nx Plugin for AWS to this project.
20
+ </Aside>
21
+
22
+ ## Prerequisites
23
+
24
+ <Snippet name="prerequisites" />
25
+
26
+ <Aside type="caution" title="Before you start">
27
+ Save and commit all in-progress work first, so the changes made at each step can be reviewed — and reverted — at any point.
28
+ </Aside>
29
+
30
+ ## Adding Nx to a non-Nx project
31
+
32
+ If your project doesn't use Nx yet, add it first with [`nx init`](https://nx.dev/recipes/adopting-nx/adding-to-existing-project). This is a step Nx itself owns; the plugin builds on top of a working Nx workspace. It works on a plain package, an npm/pnpm/yarn/bun workspace, a Turborepo or a Lerna monorepo:
33
+
34
+ <NxInitCommand />
35
+
36
+ Follow the prompts to add Nx to your workspace. For more details refer to the [Nx Documentation](https://nx.dev/recipes/adopting-nx/adding-to-existing-project).
37
+
38
+ <Aside type="note" title="pnpm workspaces">
39
+ pnpm only runs install scripts for allow-listed packages, and `nx` needs its install script — without it, the install `nx init` performs can fail, leaving a `set this to true or false` placeholder in `pnpm-workspace.yaml`. Allow-list it before running `nx init`:
40
+
41
+ ```yaml title="pnpm-workspace.yaml"
42
+ allowBuilds:
43
+ - nx
44
+ ```
45
+ </Aside>
46
+
47
+ ### Non-Node projects (Python, Go, Java, Rust, …)
48
+
49
+ Nx and the plugin are distributed as npm packages, so a project with no Node.js tooling needs a minimal root `package.json` before `nx init` can do anything useful:
50
+
51
+ ```json title="package.json"
52
+ {
53
+ "name": "my-project",
54
+ "private": true,
55
+ "type": "module"
56
+ }
57
+ ```
58
+
59
+ Create that file, then run `nx init` and [add the plugin](#adding-the-plugin) as usual. Your existing language tooling is untouched — Nx projects generated by the plugin (including <Link path="guides/py-project">Python projects</Link>) live alongside your existing code, and you can wire your existing build into Nx incrementally.
60
+
61
+ To bring your existing projects under Nx, you have a few options depending on the language:
62
+
63
+ - **Languages with an official Nx plugin** — [Java (Gradle or Maven)](https://nx.dev/docs/technologies/java/introduction) and [.NET](https://nx.dev/docs/technologies/dotnet/introduction) have dedicated plugins that infer your projects' tasks automatically. Add the relevant one, e.g. `nx add @nx/gradle`, `nx add @nx/maven` or `nx add @nx/dotnet`.
64
+ - **Languages with a community plugin** — for example [Go](https://nx.dev/plugin-registry) (`@nx-go/nx-go`) or [Rust](https://nx.dev/plugin-registry) (`@monodon/rust`). Browse the [Nx Plugin Registry](https://nx.dev/plugin-registry) for others.
65
+ - **Any other language** — add a `project.json` to each project and define its targets to run your existing build commands, so `nx build <project>` (and `nx run-many`) drive them. See the <Link path="guides/workspace">workspace guide</Link> for how `project.json` and targets are set up.
66
+
67
+ ### Single-package projects
68
+
69
+ The plugin is designed for monorepos — it generates each project into its own directory under `packages/`. If you're starting from a **single-package project** (one `package.json` at the root with your source directly beneath it, no workspaces), move your existing package into `packages/` before adopting the plugin so your project sits alongside the ones the plugin generates:
70
+
71
+ <Steps>
72
+
73
+ 1. Create a `packages/<your-package>/` directory and move your source, `package.json` and `tsconfig.json` into it.
74
+ 2. Create a new root `package.json` that acts as the workspace manifest rather than a project itself:
75
+
76
+ ```json title="package.json"
77
+ {
78
+ "name": "<your-workspace>",
79
+ "private": true,
80
+ "type": "module"
81
+ }
82
+ ```
83
+
84
+ 3. Declare the workspace so your package manager discovers projects under `packages/`. For `pnpm`, add a `pnpm-workspace.yaml`:
85
+
86
+ ```yaml title="pnpm-workspace.yaml"
87
+ packages:
88
+ - packages/*
89
+ ```
90
+
91
+ For `npm`/`yarn`/`bun`, add a `workspaces` field to the root `package.json` instead:
92
+
93
+ ```json title="package.json"
94
+ {
95
+ "workspaces": ["packages/*"]
96
+ }
97
+ ```
98
+
99
+ 4. Run `nx init` (if you haven't), then [add the plugin](#adding-the-plugin).
100
+
101
+ </Steps>
102
+
103
+ <Aside type="note" title="Package manager">
104
+ The plugin's projects are generated under a `packages/` directory. `pnpm` reads workspace globs from `pnpm-workspace.yaml`; other package managers read the `workspaces` field of the root `package.json` — `init` updates whichever your workspace uses.
105
+ </Aside>
106
+
107
+ ## Adding the plugin
108
+
109
+ Use [`nx add`](https://nx.dev/nx-api/nx/documents/add), which installs the plugin at a version compatible with your Nx installation and then runs its `init` generator to configure your workspace:
110
+
111
+ <NxCommands commands={['add @aws/nx-plugin']} />
112
+
113
+ Once it completes, your workspace is ready — choose the generators you need and start generating projects.
114
+
115
+ ### What this generator configures
116
+
117
+ Adding the plugin makes the deterministic changes a workspace needs to run the plugin's generators. It preserves your workspace's module format: a workspace whose root `package.json` has `type: "module"` stays ESM, anything else stays CommonJS, and generated code follows suit. It does not overwrite existing files, and you may need to make some manual changes following this step depending on your existing configuration.
118
+
119
+ It creates or updates the following files:
120
+
121
+ <FileTree>
122
+ - aws-nx-plugin.config.mts records your chosen IaC provider (CDK or Terraform) and container engine; generators read `iac.provider` from here
123
+ - nx.json registers the sync generators (`@nx/js:typescript-sync` and `@aws/nx-plugin:ts#sync`) on the `compile` target so TypeScript project references stay in sync
124
+ - tsconfig.json a root TypeScript config referencing your workspace's projects, which Nx's TypeScript sync keeps up to date
125
+ - tsconfig.base.json the shared compiler options the plugin's TypeScript projects extend (see below for what it carries)
126
+ - pnpm-workspace.yaml (pnpm only) allow-lists the build scripts the plugin's dependencies need (`@swc/core`, `esbuild`, `nx`, `sharp`)
127
+ - package.json convenience scripts for common tasks, plus the `nx`, `@nx/js`, `@nx/workspace`, `typescript` and Biome dev dependencies
128
+ - biome.json default Biome formatter and linter configuration
129
+ - .mcp.json configures the MCP server for supported coding agents unless disabled (also .cursor/, .kiro/, .gemini/, .vscode/ and .codex/ equivalents)
130
+ </FileTree>
131
+
132
+ The <Link path="get_started/building-with-ai">MCP server</Link> configuration can be disabled with `--mcp=false`.
133
+
134
+ <Drawer title="tsconfig.base.json" trigger="Click here to see the compiler options a created tsconfig.base.json carries.">
135
+ The plugin's TypeScript projects rely on these compiler options. If a `tsconfig.base.json` already exists it is left as-is, so if you keep your own these are the options to align with:
136
+
137
+ <TsConfigBaseCompilerOptions />
138
+ </Drawer>
139
+
140
+ ### Options
141
+
142
+ <GeneratorParameters generator="init" />
143
+
144
+ ## Troubleshooting
145
+
146
+ #### `The workspace is out of sync`
147
+
148
+ TypeScript project references need syncing. `init` registers the sync generators; run:
149
+
150
+ <NxCommands commands={['sync']} />
151
+
152
+ #### `ERR_PNPM_IGNORED_BUILDS` during install
153
+
154
+ pnpm skips install scripts for packages that aren't allow-listed. `init` allow-lists the ones the plugin's tooling needs (`@swc/core`, `esbuild`, `nx`, `sharp`) in `pnpm-workspace.yaml`, but the block can fire during `nx add @aws/nx-plugin` itself — before `init` has run. Run `pnpm approve-builds` and approve the listed packages (or add them under `allowBuilds:`), then re-run the install.
155
+
156
+ #### `nx sync` hangs, or `plugin worker ... exited before the connection was established`
157
+
158
+ If two different `nx` versions are present in the same node_modules tree (run `npm ls nx` to confirm), their plugin-worker IPC deadlocks. The `init` generator pins the root `nx` devDependency to the version the plugin's own `@nx/*` packages resolve, but a later install of another `@nx/*` package at a different patch version can reintroduce the mismatch. Align every `nx` and `@nx/*` entry in your root `package.json` to a single version and reinstall.
159
+
160
+ #### `ts.readConfigFile is not a function`
161
+
162
+ Your workspace has TypeScript 7 installed, which [Nx does not yet support](https://nx.dev/docs/technologies/typescript/guides/typescript-7) — Nx's plugins rely on TypeScript's in-process compiler API, which TypeScript 7 no longer provides. Pin `typescript` in your root `package.json` to the version the plugin uses (the `init` generator installs a compatible version) and reinstall.
163
+
164
+ #### `Recursive task invocation detected`
165
+
166
+ Your **root** `package.json` is registered as an Nx project (it has an `"nx"` key, which `nx init` adds for a single-package repo) *and* carries a `build` script of `nx run-many --target build`. Nx then infers a `build` target on the root that calls itself. Move your source into `packages/<your-package>/` so the root becomes a workspace manifest rather than a project — see [Single-package projects](#single-package-projects). (Nx's own standalone presets avoid this by setting `"nx": { "includedScripts": [] }` on the root package; you can do the same as a quicker alternative.)
167
+
168
+ #### TypeScript errors in your **existing** projects after adding the plugin (`TS6059`, `TS7016`, `TS5011`, `NG4006`)
169
+
170
+ The plugin's own generated projects carry the TypeScript settings they need in their per-project `tsconfig.lib.json`, so they build regardless of your `tsconfig.base.json`. These errors show up instead in a **pre-existing project of yours** that inherits a `tsconfig.base.json` `init` created (with `composite`/`emitDeclarationOnly`/`nodenext`) but isn't compatible with those settings — for example, the Angular compiler rejects `emitDeclarationOnly` (`NG4006`), or a project that sets `outDir` without a `rootDir` now needs one (`TS5011`). Add per-project `tsconfig` overrides re-declaring the conflicting options for those projects (e.g. `"rootDir": "src"`), or point the plugin's projects and your projects at separate base configs.
171
+
172
+ `init` never rewrites an existing `tsconfig.base.json`, precisely so it can't silently break the projects that inherit from it — resolving these mismatches is a decision only you can make for your codebase.
173
+
174
+ <Aside type="note" title="ESM and CommonJS">
175
+ The module format is workspace-wide, read from the root `package.json` `type` field: `type: "module"` means ESM, anything else (including no `type` field) means CommonJS. `init` preserves whichever your workspace uses, and the plugin's TypeScript generators emit matching code. If you later want to switch, change the root `type` — but that's a migration of your existing code, not something `init` does for you.
176
+ </Aside>
@@ -0,0 +1,266 @@
1
+ ---
2
+ title: Quick Start Guide
3
+ description: A quick start on how to use @aws/nx-plugin.
4
+ ---
5
+ import { Steps } from '@astrojs/starlight/components';
6
+ import Link from '@components/link.astro';
7
+ import Snippet from '@components/snippet.astro';
8
+ import CreateNxWorkspaceCommand from '@components/create-nx-workspace-command.astro';
9
+ import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
10
+ import InstallCommand from '@components/install-command.astro';
11
+ import RunGenerator from '@components/run-generator.astro';
12
+ import NxCommands from '@components/nx-commands.astro';
13
+ import Infrastructure from '@components/infrastructure.astro';
14
+
15
+ This guide walks you through the basics of installing and using `@aws/nx-plugin` to rapidly build projects on AWS.
16
+
17
+ :::tip[Full-Stack Tutorial]
18
+ For a more in-depth tutorial for building a full-stack application, check out the <Link path="get_started/tutorials/dungeon-game/overview">Dungeon Adventure Tutorial</Link>.
19
+ :::
20
+
21
+ ## Prerequisites
22
+
23
+ The following global dependencies are needed before proceeding:
24
+
25
+ <Snippet name="prerequisites" />
26
+
27
+ ## Step 1: Initialize a New Nx Workspace
28
+
29
+ Run the following command to create an <Link path="guides/workspace">Nx workspace</Link> with the package manager of your choice:
30
+
31
+ <CreateNxWorkspaceCommand workspace="my-project" />
32
+
33
+ :::tip[Choosing an IaC Provider]
34
+ You will be prompted for your preferred infrastructure as code (IaC) provider, either [CDK](https://docs.aws.amazon.com/cdk/) or [Terraform](https://developer.hashicorp.com/terraform). You can skip the prompt by running the command with `--iac`, ie:
35
+
36
+ <Infrastructure>
37
+ <Fragment slot="cdk">
38
+ <CreateNxWorkspaceCommand workspace="my-project" iac="cdk" />
39
+ </Fragment>
40
+ <Fragment slot="terraform">
41
+ <CreateNxWorkspaceCommand workspace="my-project" iac="terraform" />
42
+ </Fragment>
43
+ </Infrastructure>
44
+ :::
45
+
46
+ Once complete, navigate to the project directory:
47
+
48
+ ```sh
49
+ cd my-project
50
+ ```
51
+
52
+ ## Step 2: Use Generators to Scaffold your Project
53
+
54
+ We'll add a tRPC API, React Website, Cognito Authentication, and CDK or Terraform Infrastructure in this quick-start guide. Depending on the type of project you're building, you can choose any combination of generators to quickly bootstrap your project. Check out the __Guides__ in the navigation bar to the left to see the full list of options.
55
+
56
+ ### Add a tRPC API
57
+
58
+ <RunGenerator generator="ts#api" requiredParameters={{ name: 'demo-api', framework: 'trpc', auth: 'iam' }} />
59
+
60
+ This will create the API inside the `packages/demo-api` folder.
61
+
62
+ ### Add a React Website
63
+
64
+ <RunGenerator generator="ts#website" requiredParameters={{ name: 'demo-website' }} />
65
+
66
+ This scaffolds a new React website in `packages/demo-website`.
67
+
68
+ ### Add Cognito Authentication
69
+
70
+ <RunGenerator generator="ts#website#auth" requiredParameters={{ project: '@my-project/demo-website', cognitoDomain: 'my-demo' }} />
71
+
72
+ This sets up the necessary infrastructure and React code to add Cognito Authentication to your website.
73
+
74
+ ### Connect Frontend to Backend
75
+
76
+ <RunGenerator generator="connection" requiredParameters={{ sourceProject: '@my-project/demo-website', targetProject: '@my-project/demo-api' }} />
77
+
78
+ This configures the necessary providers to ensure your website can call your tRPC API.
79
+
80
+ ### Add Infrastructure
81
+
82
+ Add the infrastructure project based on your chosen IAC provider.
83
+
84
+ <Infrastructure>
85
+ <Fragment slot="cdk">
86
+ <RunGenerator generator="ts#infra" requiredParameters={{ name: 'infra' }} />
87
+
88
+ This configures a CDK App which you can use to deploy your infrastructure on AWS.
89
+ </Fragment>
90
+ <Fragment slot="terraform">
91
+ <RunGenerator generator="terraform#project" requiredParameters={{ name: 'infra' }} />
92
+
93
+ This configures a Terraform project which you can use to deploy your infrastructure on AWS.
94
+ </Fragment>
95
+ </Infrastructure>
96
+
97
+ ## Step 3: Run your Website and API Locally
98
+
99
+ Use the following command to start local dev servers for your website and its connected APIs:
100
+
101
+ <PackageManagerShortCommand commands={["dev"]} />
102
+
103
+ Your website will be available at `http://localhost:4200`.
104
+
105
+ Changes to both your website and API will be reflected in real-time as both the local website and API servers will hot-reload.
106
+
107
+ ## Step 4: Define Cloud Resources and Deploy to AWS
108
+
109
+ <Infrastructure>
110
+ <Fragment slot="cdk">
111
+ Open `packages/infra/src/stacks/application-stack.ts` and add the following code:
112
+
113
+ ```typescript
114
+ import { Stack, StackProps } from 'aws-cdk-lib';
115
+ import { DemoApi, DemoWebsite, UserIdentity } from ':my-project/common-constructs';
116
+ import { Construct } from 'constructs';
117
+
118
+ export class ApplicationStack extends Stack {
119
+ constructor(scope: Construct, id: string, props?: StackProps) {
120
+ super(scope, id, props);
121
+
122
+ const identity = new UserIdentity(this, 'identity');
123
+ const api = new DemoApi(this, 'api', {
124
+ integrations: DemoApi.defaultIntegrations(this).build(),
125
+ });
126
+ api.grantInvokeAccess(identity.identityPool.authenticatedRole);
127
+
128
+ new DemoWebsite(this, 'website');
129
+ }
130
+ }
131
+ ```
132
+
133
+ This is all the CDK we need to write to deploy our full stack application.
134
+ </Fragment>
135
+ <Fragment slot="terraform">
136
+ Open `packages/infra/src/main.tf` and add the following code:
137
+
138
+ ```hcl
139
+ # Include metrics tracking for @aws/nx-plugin usage
140
+ module "metrics" {
141
+ source = "../../common/terraform/src/metrics"
142
+ }
143
+
144
+ # Deploy user identity
145
+ module "user_identity" {
146
+ source = "../../common/terraform/src/core/user-identity"
147
+ }
148
+
149
+ # Shared asset bucket — stages Lambda deployment zips for every lambda / API module
150
+ module "asset_bucket" {
151
+ source = "../../common/terraform/src/core/asset-bucket"
152
+ }
153
+
154
+ # Deploy API
155
+ module "demo_api" {
156
+ source = "../../common/terraform/src/app/apis/demo-api"
157
+
158
+ asset_bucket_name = module.asset_bucket.bucket_name
159
+ }
160
+
161
+ # Grant authenticated users access to invoke the API
162
+ resource "aws_iam_policy" "api_invoke_policy" {
163
+ name = "DemoApiInvokePolicy"
164
+ description = "Policy to allow authenticated users to invoke the API"
165
+
166
+ policy = jsonencode({
167
+ Version = "2012-10-17"
168
+ Statement = [
169
+ {
170
+ Effect = "Allow"
171
+ Action = "execute-api:Invoke"
172
+ Resource = "${module.demo_api.api_execution_arn}/*/*"
173
+ }
174
+ ]
175
+ })
176
+ }
177
+
178
+ resource "aws_iam_role_policy_attachment" "authenticated_api_access" {
179
+ role = module.user_identity.authenticated_role_name
180
+ policy_arn = aws_iam_policy.api_invoke_policy.arn
181
+ }
182
+
183
+ # Deploy website
184
+ provider "aws" {
185
+ alias = "us_east_1"
186
+ region = "us-east-1"
187
+ }
188
+
189
+ module "demo_website" {
190
+ source = "../../common/terraform/src/app/static-websites/demo-website"
191
+
192
+ providers = {
193
+ aws.us_east_1 = aws.us_east_1
194
+ }
195
+
196
+ depends_on = [module.user_identity, module.demo_api]
197
+ }
198
+ ```
199
+
200
+ This is all the Terraform we need to write to deploy our full stack application.
201
+ </Fragment>
202
+ </Infrastructure>
203
+
204
+ ### Build and Deploy the Infrastructure
205
+
206
+ Next, run the following command to build your project:
207
+
208
+ <PackageManagerShortCommand commands={["build"]} />
209
+
210
+ :::tip[Fixing Lint Errors]
211
+ If you encounter any lint errors, you can run the following command to automatically fix them.
212
+
213
+ <PackageManagerShortCommand commands={["lint"]} />
214
+ :::
215
+
216
+ Bootstrap your infrastructure:
217
+
218
+ <Infrastructure>
219
+ <Fragment slot="cdk">
220
+ <NxCommands commands={['bootstrap infra']} />
221
+
222
+ :::tip[Bootstrap Regions]
223
+ CDK bootstrapping is required for both your target deployment AWS region, and `us-east-1` to allow deployment of the AWS WAF WebACL for the website.
224
+ :::
225
+ </Fragment>
226
+ <Fragment slot="terraform">
227
+ <NxCommands commands={['bootstrap infra']} />
228
+
229
+ :::tip[One-Time Setup]
230
+ Terraform bootstrapping creates an S3 bucket to store your Terraform state files. This only needs to be done once per AWS account/region combination.
231
+ :::
232
+ </Fragment>
233
+ </Infrastructure>
234
+
235
+ Deploy your project:
236
+
237
+ <Infrastructure>
238
+ <Fragment slot="cdk">
239
+ <NxCommands commands={['deploy infra "my-project-sandbox/*"']} />
240
+ </Fragment>
241
+ <Fragment slot="terraform">
242
+ <NxCommands commands={['apply infra']} />
243
+
244
+ :::tip[Plan Before Apply]
245
+ This command will first run `terraform plan` to show you what changes will be made, then apply those changes to deploy your infrastructure.
246
+ :::
247
+ </Fragment>
248
+ </Infrastructure>
249
+
250
+ ## Step 5: Test the Website with Deployed Cloud Resources
251
+
252
+ <Steps>
253
+ 1. Fetch the `runtime-config.json` file:
254
+
255
+ <NxCommands commands={['run demo-website:load:runtime-config']} />
256
+
257
+ 2. Start the local website server
258
+
259
+ <NxCommands commands={['serve demo-website']} />
260
+ </Steps>
261
+
262
+ Your website will be available at `http://localhost:4200`, and will point to the resources you deployed for the API and authentication.
263
+
264
+ ---
265
+
266
+ Congratulations! 🎉 You have successfully built and deployed a full-stack application using `@aws/nx-plugin`!