|
| 1 | +--- |
| 2 | +title: Deploy with Nx Plugin for AWS |
| 3 | +sidebar: |
| 4 | + label: "Nx Plugin for AWS" |
| 5 | +--- |
| 6 | + |
| 7 | +[Nx](https://nx.dev/) is a build system and monorepo tool for managing multi-project workspaces. The [Nx Plugin for AWS](https://awslabs.github.io/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](https://docs.aws.amazon.com/cdk/) or [Terraform](https://developer.hashicorp.com/terraform) for infrastructure management. |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- [Node.js](https://nodejs.org/) (v22 or later) |
| 14 | +- A package manager: [pnpm](https://pnpm.io/), [yarn](https://yarnpkg.com/), [npm](https://www.npmjs.com/), or [bun](https://bun.sh/) |
| 15 | +- [UV](https://docs.astral.sh/uv/) (for Python agents) |
| 16 | +- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) configured with credentials |
| 17 | +- [Terraform CLI](https://developer.hashicorp.com/terraform/install) (if using Terraform as your IaC provider) |
| 18 | + |
| 19 | +:::note |
| 20 | +The examples below use [pnpm](https://pnpm.io/), but npm, yarn, and bun are also supported. See the [Quick Start Guide](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/quick-start/) for commands using other package managers. |
| 21 | +::: |
| 22 | + |
| 23 | +## Step 1: Create an Nx Workspace |
| 24 | + |
| 25 | +Create a new Nx workspace using the `@aws/nx-plugin` preset: |
| 26 | + |
| 27 | +```bash |
| 28 | +pnpm create @aws/nx-workspace my-agent-project |
| 29 | +``` |
| 30 | + |
| 31 | +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](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/quick-start/) for more details. |
| 32 | + |
| 33 | +## Step 2: Add a Strands Agent |
| 34 | + |
| 35 | +<Tabs> |
| 36 | +<Tab label="Python"> |
| 37 | + |
| 38 | +First, generate a Python project to host your agent: |
| 39 | + |
| 40 | +```bash |
| 41 | +pnpm nx g @aws/nx-plugin:py#project |
| 42 | +``` |
| 43 | + |
| 44 | +Then add a Strands agent to the project: |
| 45 | + |
| 46 | +```bash |
| 47 | +pnpm nx g @aws/nx-plugin:py#strands-agent |
| 48 | +``` |
| 49 | + |
| 50 | +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](https://awslabs.github.io/nx-plugin-for-aws/en/guides/py-strands-agent/). |
| 51 | + |
| 52 | +</Tab> |
| 53 | +<Tab label="TypeScript"> |
| 54 | + |
| 55 | +First, generate a TypeScript project to host your agent: |
| 56 | + |
| 57 | +```bash |
| 58 | +pnpm nx g @aws/nx-plugin:ts#project |
| 59 | +``` |
| 60 | + |
| 61 | +Then add a Strands agent to the project: |
| 62 | + |
| 63 | +```bash |
| 64 | +pnpm nx g @aws/nx-plugin:ts#strands-agent |
| 65 | +``` |
| 66 | + |
| 67 | +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 [TypeScript Strands Agent guide](https://awslabs.github.io/nx-plugin-for-aws/en/guides/ts-strands-agent/). |
| 68 | + |
| 69 | +</Tab> |
| 70 | +</Tabs> |
| 71 | + |
| 72 | +The generator scaffolds your agent code, infrastructure definitions, a Dockerfile, and deployment configuration targeting [Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/). |
| 73 | + |
| 74 | +## Step 3: Add Infrastructure |
| 75 | + |
| 76 | +Generate an infrastructure project for your chosen IaC provider: |
| 77 | + |
| 78 | +<Tabs> |
| 79 | +<Tab label="CDK"> |
| 80 | + |
| 81 | +```bash |
| 82 | +pnpm nx g @aws/nx-plugin:ts#infra --name infra |
| 83 | +``` |
| 84 | + |
| 85 | +Then open `packages/infra/src/stacks/application-stack.ts` and instantiate the generated construct for your agent: |
| 86 | + |
| 87 | +```typescript {9} |
| 88 | +import { Stack, StackProps } from 'aws-cdk-lib'; |
| 89 | +import { MyAgent } from ':my-agent-project/common-constructs'; |
| 90 | +import { Construct } from 'constructs'; |
| 91 | + |
| 92 | +export class ApplicationStack extends Stack { |
| 93 | + constructor(scope: Construct, id: string, props?: StackProps) { |
| 94 | + super(scope, id, props); |
| 95 | + |
| 96 | + new MyAgent(this, 'MyAgent'); |
| 97 | + } |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +Replace `MyAgent` with the construct name generated for your agent (based on the name you chose in Step 2). |
| 102 | + |
| 103 | +</Tab> |
| 104 | +<Tab label="Terraform"> |
| 105 | + |
| 106 | +```bash |
| 107 | +pnpm nx g @aws/nx-plugin:terraform#project --name infra |
| 108 | +``` |
| 109 | + |
| 110 | +Then open `packages/infra/src/main.tf` and add the generated module for your agent: |
| 111 | + |
| 112 | +```hcl |
| 113 | +module "my_agent" { |
| 114 | + source = "../../common/terraform/src/app/agents/my-agent" |
| 115 | +} |
| 116 | +``` |
| 117 | + |
| 118 | +Replace `my-agent` with the module name generated for your agent (based on the name you chose in Step 2). |
| 119 | + |
| 120 | +</Tab> |
| 121 | +</Tabs> |
| 122 | + |
| 123 | +## Step 4: Build and Deploy |
| 124 | + |
| 125 | +Build all projects in the workspace: |
| 126 | + |
| 127 | +```bash |
| 128 | +pnpm build |
| 129 | +``` |
| 130 | + |
| 131 | +Then deploy: |
| 132 | + |
| 133 | +```bash |
| 134 | +pnpm nx deploy infra |
| 135 | +``` |
| 136 | + |
| 137 | +The Nx Plugin handles containerizing your agent, provisioning the required AWS resources, and deploying to [Amazon Bedrock AgentCore Runtime](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/). Follow the [Quick Start Guide](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/quick-start/) for a full walkthrough of the build and deploy workflow. |
| 138 | + |
| 139 | +:::tip[Beyond Agents] |
| 140 | +The Nx Plugin for AWS can also generate APIs (tRPC, FastAPI, Smithy), React websites, and MCP servers. Use the [connection generator](https://awslabs.github.io/nx-plugin-for-aws/en/guides/connection/) to wire these components together — for example, connecting a React frontend to your Strands agent, or linking an agent to an MCP server. The plugin also supports local development with hot reload via a `nx serve-local` command that spins up all connected components (websites, APIs, agents, MCP servers) locally. |
| 141 | + |
| 142 | +The Nx Plugin for AWS also ships with an [MCP server](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/building-with-ai/) that you can use with your favourite AI assistant to accelerate scaffolding and development. |
| 143 | +::: |
| 144 | + |
| 145 | +## Additional Resources |
| 146 | + |
| 147 | +- [Nx Plugin for AWS Documentation](https://awslabs.github.io/nx-plugin-for-aws/) |
| 148 | +- [Python Strands Agent Guide](https://awslabs.github.io/nx-plugin-for-aws/en/guides/py-strands-agent/) |
| 149 | +- [TypeScript Strands Agent Guide](https://awslabs.github.io/nx-plugin-for-aws/en/guides/ts-strands-agent/) |
| 150 | +- [Nx Plugin for AWS Quick Start](https://awslabs.github.io/nx-plugin-for-aws/en/get_started/quick-start/) |
0 commit comments