Skip to content

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.

Create a new Nx workspace using the @aws/nx-plugin preset:

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

You 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.

First, generate a Python project to host your agent:

Terminal window
pnpm nx g @aws/nx-plugin:py#project

Then add a Strands agent to the project:

Terminal window
pnpm nx g @aws/nx-plugin:py#agent

Follow 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.

The generator scaffolds your agent code, infrastructure definitions, a Dockerfile, and deployment configuration targeting Amazon Bedrock AgentCore Runtime.

Generate an infrastructure project for your chosen IaC provider:

Terminal window
pnpm nx g @aws/nx-plugin:ts#infra --name infra

Then 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).

Build all projects in the workspace:

Terminal window
pnpm build

Then deploy:

Terminal window
pnpm nx deploy infra

The 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.