Skip to content

Quick Start Guide

This guide walks you through the basics of installing and using @aws/nx-plugin to rapidly build projects on AWS.

The following global dependencies are needed before proceeding:

  • Git
  • Node >= 22 (We recommend using something like NVM to manage your node versions)
    • verify by running node --version
  • UV >= 0.5.29
    1. install Python 3.14 by running: uv python install 3.14.0
    2. verify with uv python list --only-installed

Run the following command to create an Nx workspace with the package manager of your choice:

Terminal window
pnpm create @aws/nx-workspace my-project

Once complete, navigate to the project directory:

Terminal window
cd my-project

Step 2: Use Generators to Scaffold your Project

Section titled “Step 2: Use Generators to Scaffold your Project”

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 Generators in the navigation bar to the left to see the full list of options, or try the graph builder to construct your workspace visually.

As a shortcut, you can use the button below to copy the commands to scaffold the full application.

Loading the diagram…

Otherwise, follow the steps below to run each generator yourself.

Terminal window
pnpm nx g @aws/nx-plugin:ts#api --name=demo-api --framework=trpc --auth=iam --no-interactive
You can also perform a dry-run to see what files would be changed
Terminal window
pnpm nx g @aws/nx-plugin:ts#api --name=demo-api --framework=trpc --auth=iam --no-interactive --dry-run

This will create the API inside the packages/demo-api folder.

Terminal window
pnpm nx g @aws/nx-plugin:ts#website --name=demo-website --no-interactive
You can also perform a dry-run to see what files would be changed
Terminal window
pnpm nx g @aws/nx-plugin:ts#website --name=demo-website --no-interactive --dry-run

This scaffolds a new React website in packages/demo-website.

Terminal window
pnpm nx g @aws/nx-plugin:ts#website#auth --project=@my-project/demo-website --cognitoDomain=my-demo --no-interactive
You can also perform a dry-run to see what files would be changed
Terminal window
pnpm nx g @aws/nx-plugin:ts#website#auth --project=@my-project/demo-website --cognitoDomain=my-demo --no-interactive --dry-run

This sets up the necessary infrastructure and React code to add Cognito Authentication to your website.

Terminal window
pnpm nx g @aws/nx-plugin:connection --sourceProject=@my-project/demo-website --targetProject=@my-project/demo-api --no-interactive
You can also perform a dry-run to see what files would be changed
Terminal window
pnpm nx g @aws/nx-plugin:connection --sourceProject=@my-project/demo-website --targetProject=@my-project/demo-api --no-interactive --dry-run

This configures the necessary providers to ensure your website can call your tRPC API.

Add the infrastructure project based on your chosen IAC provider.

Terminal window
pnpm nx g @aws/nx-plugin:ts#infra --name=infra --no-interactive
You can also perform a dry-run to see what files would be changed
Terminal window
pnpm nx g @aws/nx-plugin:ts#infra --name=infra --no-interactive --dry-run

This configures a CDK App which you can use to deploy your infrastructure on AWS.

Use the following command to start local dev servers for your website and its connected APIs:

Terminal window
pnpm dev

Your website will be available at http://localhost:4200.

Changes to both your website and API will be reflected in real-time as both the local website and API servers will hot-reload.

Step 4: Define Cloud Resources and Deploy to AWS

Section titled “Step 4: Define Cloud Resources and Deploy to AWS”

Open packages/infra/src/stacks/application-stack.ts and add the following code:

import { Stack, StackProps } from 'aws-cdk-lib';
import { DemoApi, DemoWebsite, UserIdentity } from '@my-project/common-constructs';
import { Construct } from 'constructs';
export class ApplicationStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const identity = new UserIdentity(this, 'identity');
const api = new DemoApi(this, 'api', {
integrations: DemoApi.defaultIntegrations(this).build(),
});
api.grantInvokeAccess(identity.identityPool.authenticatedRole);
new DemoWebsite(this, 'website');
}
}

This is all the CDK we need to write to deploy our full stack application.

Next, run the following command to build your project:

Terminal window
pnpm build

Bootstrap your infrastructure:

Terminal window
pnpm nx bootstrap infra

Deploy your project:

Terminal window
pnpm nx deploy-sandbox infra

Step 5: Test the Website with Deployed Cloud Resources

Section titled “Step 5: Test the Website with Deployed Cloud Resources”
  1. Fetch the runtime-config.json file:

    Terminal window
    pnpm nx load-runtime-config demo-website
  2. Start the local website server

    Terminal window
    pnpm nx serve demo-website

Your website will be available at http://localhost:4200, and will point to the resources you deployed for the API and authentication.


Congratulations! 🎉 You have successfully built and deployed a full-stack application using @aws/nx-plugin!