Deploy with Nx Plugin for AWS
Nx is a build system and monorepo tool for managing multi-project workspaces. The Nx Plugin for AWS extends Nx with generators that scaffold Strands agents, APIs, React websites, MCP servers, and more with infrastructure as code, packaging, and deployment configuration out of the box. It supports both Python and TypeScript, with a choice of AWS CDK or Terraform for infrastructure management.
Using the Nx Plugin for AWS means you don’t need to manually configure Dockerfiles, infrastructure definitions, or deployment pipelines — the generators handle this for you, but give you flexibility to modify the generated code to suit your needs.
Prerequisites
Section titled “Prerequisites”- Node.js (v22 or later)
- A package manager: pnpm, yarn, npm, or bun
- UV (for Python agents)
- AWS CLI configured with credentials
- Terraform CLI (if using Terraform as your IaC provider)
Step 1: Create an Nx Workspace
Section titled “Step 1: Create an Nx Workspace”Create a new Nx workspace using the @aws/nx-plugin preset:
pnpm create @aws/nx-workspace my-agent-projectYou will be prompted to choose an infrastructure as code (IaC) provider — either CDK or Terraform. This choice is the default for all infrastructure generated within the workspace. See the Quick Start Guide for more details.
Step 2: Add a Strands Agent
Section titled “Step 2: Add a Strands Agent”First, generate a Python project to host your agent:
pnpm nx g @aws/nx-plugin:py#projectThen add a Strands agent to the project:
pnpm nx g @aws/nx-plugin:py#agentFollow the prompts to select your project, agent name, authentication method, and compute type. For full details on the generator options and output, see the Python Strands Agent guide.
First, generate a TypeScript project to host your agent:
pnpm nx g @aws/nx-plugin:ts#projectThen add a Strands agent to the project:
pnpm nx g @aws/nx-plugin:ts#agentFollow the prompts to select your project, agent name, authentication method, and compute type. For full details on the generator options and output, see the TypeScript Strands Agent guide.
The generator scaffolds your agent code, infrastructure definitions, a Dockerfile, and deployment configuration targeting Amazon Bedrock AgentCore Runtime.
Step 3: Add Infrastructure
Section titled “Step 3: Add Infrastructure”Generate an infrastructure project for your chosen IaC provider:
pnpm nx g @aws/nx-plugin:ts#infra --name infraThen open packages/infra/src/stacks/application-stack.ts and instantiate the generated construct for your agent:
import { Stack, StackProps } from 'aws-cdk-lib';import { MyAgent } from ':my-agent-project/common-constructs';import { Construct } from 'constructs';
export class ApplicationStack extends Stack { constructor(scope: Construct, id: string, props?: StackProps) { super(scope, id, props);
new MyAgent(this, 'MyAgent'); }}Replace MyAgent with the construct name generated for your agent (based on the name you chose in Step 2).
pnpm nx g @aws/nx-plugin:terraform#project --name infraThen open packages/infra/src/main.tf and add the generated module for your agent:
module "my_agent" { source = "../../common/terraform/src/app/agents/my-agent"}Replace my-agent with the module name generated for your agent (based on the name you chose in Step 2).
Step 4: Build and Deploy
Section titled “Step 4: Build and Deploy”Build all projects in the workspace:
pnpm buildThen deploy:
pnpm nx deploy infraThe Nx Plugin handles containerizing your agent, provisioning the required AWS resources, and deploying to Amazon Bedrock AgentCore Runtime. Follow the Quick Start Guide for a full walkthrough of the build and deploy workflow.