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
    2. verify with uv python list --only-installed

Create an Nx workspace with the package manager of your choice, and open the directory it creates:

Create your workspace@aws/nx-workspace

pnpm create @aws/nx-workspace my-project
Build your command3

Required

Terminal window
cd my-project

You are prompted to choose your infrastructure as code provider, either CDK or Terraform.

We’ll build a full-stack application: a tRPC API, a React website, Cognito authentication, and CDK or Terraform infrastructure. Ask an AI assistant to scaffold it for you, or run the generators yourself — both routes reach the same workspace.

  1. Open the workspace in your AI coding assistant.

    New workspaces come with the plugin’s MCP server already configured for Kiro, Claude Code, Cursor, Gemini CLI, GitHub Copilot and OpenAI Codex, so your assistant can look up the plugin’s generators and run them without any setup.

  2. Ask for the application:

    Prompt

    Create a tRPC API called demo-api, and a React website called demo-website. Add Cognito authentication to the website, connect the website to the API, and add an infrastructure project called infra. Then instantiate the generated infrastructure components so the website and API deploy, granting authenticated users access to the API.

    Your assistant discovers the generators through the MCP server and runs them, in the order their dependencies need. Review the changes it makes, then carry on at Step 3.

Run the generators that scaffold the application. Use the button below to copy them all, or run each one yourself as described beneath the diagram.

Loading the diagram…

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.

Run this generator@aws/nx-plugin:ts#api

pnpm nx g @aws/nx-plugin:ts#api --no-interactive
Options for this step2

Required

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

Run this generator@aws/nx-plugin:ts#website

pnpm nx g @aws/nx-plugin:ts#website --no-interactive
Options for this step1

Required

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

Run this generator@aws/nx-plugin:ts#website#auth

pnpm nx g @aws/nx-plugin:ts#website#auth --no-interactive
Options for this step1

Required

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

Run this generator@aws/nx-plugin:connection

pnpm nx g @aws/nx-plugin:connection --no-interactive
Options for this step2

Required

Required

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

Add the infrastructure project based on your chosen IAC provider.

Run this generator@aws/nx-plugin:ts#infra

pnpm nx g @aws/nx-plugin:ts#infra --no-interactive
Options for this step1

Required

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.

Try it: call the API from your website

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 {
DemoApi,
DemoWebsite,
UserIdentity,
} from '@my-project/common-constructs';
import { Stack, StackProps } from 'aws-cdk-lib';
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.

To sign in, you will need to create a user in the Cognito user pool.

Click here for instructions using the AWS CLI

Your website is also served from CloudFront. Open its distribution domain name (which is printed to your terminal after deployment) to use the version running entirely on AWS.

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

When you have finished, delete the resources you deployed to avoid ongoing costs:

Terminal window
pnpm nx destroy-sandbox infra

To remove bootstrap resources, follow below:

Delete the bootstrap stack in every region you bootstrapped, including us-east-1. This removes the bootstrap roles and the container image repository:

Terminal window
aws cloudformation delete-stack --stack-name CDKToolkit --region <region>