Skip to content

Commit 4616598

Browse files
authored
Merge pull request #2 from damc-dev/claude/review-agentcore-cli-migration-TkwBW
Update README for @aws/agentcore npm CLI migration Replace all references to the old pip-based CLI (agentcore launch, .bedrock_agentcore.yaml, yq, uv run agentcore) with the new npm CLI (agentcore deploy, agentcore.json, agentcore dev). Add CDK bootstrap prerequisite and updated IAM permissions. Update project structure, local dev workflow, and adding-new-agent instructions. https://claude.ai/code/session_01G2hszc4Xx3t7JsaJr9G4qf
2 parents 21d638d + 7ee29cf commit 4616598

18 files changed

Lines changed: 6309 additions & 81 deletions

README.md

Lines changed: 66 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Every commit to `main` automatically:
88
- 🚀 **Deploys a new version** of each agent to AWS Bedrock
99
- 🏗️ **Builds and pushes** Docker images to Amazon ECR
1010
- 📦 **Tracks deployment history** via timestamped artifacts
11-
-**Runs in parallel** for multi-agent deployments
1211

1312
**No manual intervention required.** Push your code, and your agents are live in minutes.
1413

@@ -23,9 +22,7 @@ git push origin main
2322
2423
GitHub Actions detects the push
2524
26-
Workflow extracts all agents from .bedrock_agentcore.yaml
27-
28-
Parallel deployment begins for each agent
25+
AWS credentials configured via OIDC
2926
3027
Docker image built → pushed to ECR → deployed to Bedrock
3128
@@ -38,29 +35,34 @@ The deployment triggers on:
3835

3936
### Deployment Architecture
4037

41-
The GitHub Actions workflow ([.github/workflows/deploy-agent.yml](.github/workflows/deploy-agent.yml)) uses a matrix strategy to deploy multiple agents efficiently:
38+
The GitHub Actions workflow ([.github/workflows/deploy-agent.yml](.github/workflows/deploy-agent.yml)) uses the `@aws/agentcore` npm CLI backed by AWS CDK:
4239

43-
**Setup Job:**
44-
1. Extracts all agent names from `.bedrock_agentcore.yaml` using `yq`
45-
2. Installs Python and `uv` package manager
46-
3. Installs dependencies once (`uv sync`)
47-
4. Caches the environment for reuse
40+
1. Checks out code
41+
2. Installs Node.js and `@aws/agentcore` CLI
42+
3. Installs `uv` (required by the agentcore CLI for Python agents)
43+
4. Configures AWS credentials via OIDC
44+
5. Runs `agentcore deploy -y` which builds the Docker image, pushes to ECR, and deploys to Bedrock AgentCore
4845

49-
**Deploy Jobs (parallel):**
50-
1. Restores the cached environment
51-
2. Configures AWS credentials
52-
3. Runs `agentcore launch --agent {agent-name}` for each agent
53-
4. Saves agent-specific `.bedrock_agentcore.yaml` as an artifact
46+
### Setup Requirements
5447

55-
This approach eliminates redundant dependency installation, significantly speeding up multi-agent deployments.
48+
#### Prerequisites
5649

57-
### Setup Requirements
50+
- Node.js 20+
51+
- [uv](https://github.com/astral-sh/uv) package manager
52+
- AWS account with CDK bootstrapped in your target region
5853

59-
#### AWS Configuration
54+
#### CDK Bootstrap (one-time per account/region)
6055

61-
You need to configure AWS authentication for GitHub Actions. Two options:
56+
The `@aws/agentcore` CLI uses AWS CDK internally. Before the first deploy, bootstrap your account:
6257

63-
**Option 1: OIDC (Recommended)**
58+
```bash
59+
npm install -g @aws/agentcore
60+
npx cdk bootstrap aws://YOUR_ACCOUNT_ID/us-east-1
61+
```
62+
63+
#### AWS Configuration
64+
65+
Configure AWS authentication for GitHub Actions using OIDC:
6466

6567
1. Create an IAM OIDC identity provider for GitHub Actions:
6668
```
@@ -94,32 +96,25 @@ You need to configure AWS authentication for GitHub Actions. Two options:
9496
- Amazon ECR (push images)
9597
- AWS CodeBuild (trigger builds)
9698
- Amazon Bedrock AgentCore (deploy agent)
99+
- AWS CloudFormation (CDK stack management)
100+
- `sts:AssumeRole` for CDK bootstrap roles (`cdk-hnb659fds-*`)
97101

98102
4. Add the role ARN as a GitHub secret: `AWS_ROLE_ARN`
99103

100-
**Option 2: Access Keys**
101-
102-
1. Create an IAM user with programmatic access
103-
2. Attach necessary permissions (same as above)
104-
3. Add GitHub secrets:
105-
- `AWS_ACCESS_KEY_ID`
106-
- `AWS_SECRET_ACCESS_KEY`
107-
108104
### Manual Deployment
109105

110-
To deploy a specific agent:
111-
112106
```bash
113-
uv sync
114-
uv run agentcore launch --agent <agent-name>
107+
npm install -g @aws/agentcore
108+
agentcore deploy -y
115109
```
116110

117111
## Development
118112

119113
### Prerequisites
120114

121-
- Python 3.12+
115+
- Python 3.13+
122116
- [uv](https://github.com/astral-sh/uv) package manager
117+
- Node.js 20+ and `@aws/agentcore` CLI
123118
- AWS credentials configured
124119

125120
### Local Setup
@@ -128,20 +123,21 @@ uv run agentcore launch --agent <agent-name>
128123
# Install uv
129124
curl -LsSf https://astral.sh/uv/install.sh | sh
130125

131-
# Install dependencies
126+
# Install Python dependencies
132127
uv sync
128+
129+
# Install agentcore CLI
130+
npm install -g @aws/agentcore
133131
```
134132

135-
### Local Agent Run
133+
### Local Agent Development
136134

137135
```bash
138-
# Run the agent locally (if applicable)
139-
uv run python agent.py
136+
# Run the agent locally with a live reload server
137+
agentcore dev
140138
```
141139

142-
### Local Invocation
143-
You can invoke the agent locally for testing:
144-
140+
Then in another terminal:
145141
```bash
146142
curl -X POST http://localhost:8080/invocations \
147143
-H "Content-Type: application/json" \
@@ -150,55 +146,48 @@ curl -X POST http://localhost:8080/invocations \
150146

151147
### Adding a New Agent
152148

153-
Adding a new agent is simple and automatically deployed:
154-
155-
```bash
156-
# Configure a new agent interactively
157-
uv run agentcore configure --agent <new-agent-name>
158-
159-
# Commit and push
160-
git add .bedrock_agentcore.yaml
161-
git commit -m "Add new agent"
162-
git push origin main
163-
```
164-
165-
**What happens next:**
166-
1. Configure command updates `.bedrock_agentcore.yaml` with your new agent
167-
2. Push to `main` triggers the deployment workflow
168-
3. Workflow automatically detects the new agent
169-
4. New agent is built and deployed alongside existing agents in parallel
170-
5. Your new agent is live! 🎉
171-
172-
**Example:**
173-
```bash
174-
# Add a new agent called "summarizer_agent"
175-
uv run agentcore configure --entrypoint summarizer_agent.py
176-
177-
# Commit and push to deploy
178-
git add .bedrock_agentcore.yaml
179-
git commit -m "Add summarizer agent"
180-
git push origin main
149+
1. Add a new entry to `agentcore/agentcore.json`:
150+
```json
151+
{
152+
"type": "AgentCoreRuntime",
153+
"name": "my-new-agent",
154+
"build": "Container",
155+
"entrypoint": "my_agent.py",
156+
"codeLocation": ".",
157+
"runtimeVersion": "PYTHON_3_13"
158+
}
159+
```
181160

182-
# ✅ Agent automatically deployed to AWS Bedrock
183-
```
161+
2. Commit and push:
162+
```bash
163+
git add agentcore/agentcore.json my_agent.py
164+
git commit -m "Add my-new-agent"
165+
git push origin main
166+
```
184167

168+
The workflow automatically deploys the new agent alongside existing ones.
185169

186170
## Project Structure
187171

188-
- `agent.py` - Agent entrypoint
189-
- `.bedrock_agentcore.yaml` - Agent configuration
190-
- `Dockerfile` - Container definition
191-
- `.github/workflows/deploy-agent.yml` - Deployment workflow
172+
```
173+
agent.py # Agent entrypoint
174+
agentcore/
175+
agentcore.json # Agent configuration
176+
aws-targets.json # Deployment target (account/region)
177+
cdk/ # CDK app (managed by agentcore CLI)
178+
Dockerfile # Container definition
179+
.github/workflows/deploy-agent.yml # Deployment workflow
180+
```
192181

193182
## Deployment Versioning & History
194183

195184
Every deployment is tracked and versioned automatically:
196185

197186
### Artifacts
198-
Each successful deployment creates timestamped artifacts:
199-
- **Naming**: `bedrock-agentcore-config-{agent-name}-{commit-sha}`
187+
Each successful deployment creates artifacts:
188+
- **Naming**: `agentcore-config-{commit-sha}`
189+
- **Contents**: `agentcore/agentcore.json` and `agentcore/aws-targets.json`
200190
- **Retention**: 90 days
201-
- **Purpose**: Full audit trail of deployments and configuration changes
202191

203192
### Version Tracking
204193
- Each `git push` to `main` creates a new agent version in AWS Bedrock

agentcore/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Secrets (local environment files are never committed)
2+
.env.local
3+
4+
# CDK Build Artifacts
5+
cdk/cdk.out/
6+
cdk/node_modules/
7+
8+
# CLI Internals
9+
.cli/*
10+
11+
# Ephemeral Staging
12+
.cache/*
13+
14+
# Exception: Commit the State
15+
!.cli/deployed-state.json

agentcore/.llm-context/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# LLM Context Files
2+
3+
**DO NOT EDIT THESE FILES** - They are read-only reference for AI coding assistants.
4+
5+
## Files
6+
7+
| File | JSON Config | Purpose |
8+
| ---------------- | ------------------ | ------------------------------------ |
9+
| `agentcore.ts` | `agentcore.json` | Project and agent environment config |
10+
| `aws-targets.ts` | `aws-targets.json` | Deployment targets |
11+
12+
## Usage
13+
14+
When editing schema JSON files, reference the corresponding `.ts` file here for type definitions and validation
15+
constraints (marked with `@regex`, `@min`, `@max`).
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
/**
3+
* READ-ONLY LLM CONTEXT - Do not edit this file.
4+
*
5+
* JSON File: agentcore/agentcore.json
6+
* Purpose: Top-level project configuration with flat resource model
7+
*/
8+
9+
// ─────────────────────────────────────────────────────────────────────────────
10+
// ROOT SCHEMA: AgentCoreProjectSpec
11+
// ─────────────────────────────────────────────────────────────────────────────
12+
13+
interface AgentCoreProjectSpec {
14+
name: string; // @regex ^[A-Za-z][A-Za-z0-9]{0,22}$ @max 23 - project name
15+
version: number; // Schema version (integer)
16+
agents: AgentEnvSpec[]; // Unique by name
17+
memories: Memory[]; // Unique by name
18+
credentials: Credential[]; // Unique by name
19+
}
20+
21+
// ─────────────────────────────────────────────────────────────────────────────
22+
// ENUMS
23+
// ─────────────────────────────────────────────────────────────────────────────
24+
25+
type BuildType = 'CodeZip' | 'Container';
26+
type PythonRuntime = 'PYTHON_3_10' | 'PYTHON_3_11' | 'PYTHON_3_12' | 'PYTHON_3_13';
27+
type NodeRuntime = 'NODE_18' | 'NODE_20' | 'NODE_22';
28+
type RuntimeVersion = PythonRuntime | NodeRuntime;
29+
type NetworkMode = 'PUBLIC' | 'PRIVATE';
30+
type MemoryStrategyType = 'SEMANTIC' | 'SUMMARIZATION' | 'USER_PREFERENCE';
31+
type ModelProvider = 'Bedrock' | 'Gemini' | 'OpenAI' | 'Anthropic';
32+
33+
// ─────────────────────────────────────────────────────────────────────────────
34+
// AGENT
35+
// ─────────────────────────────────────────────────────────────────────────────
36+
37+
interface AgentEnvSpec {
38+
type: 'AgentCoreRuntime';
39+
name: string; // @regex ^[a-zA-Z][a-zA-Z0-9_]{0,47}$ @max 48
40+
build: BuildType;
41+
entrypoint: string; // @regex ^[a-zA-Z0-9_][a-zA-Z0-9_/.-]*\.(py|ts|js)(:[a-zA-Z_][a-zA-Z0-9_]*)?$ e.g. "main.py:handler" or "index.ts"
42+
codeLocation: string; // Directory path
43+
runtimeVersion: RuntimeVersion;
44+
envVars?: EnvVar[];
45+
networkMode?: NetworkMode; // default 'PUBLIC'
46+
instrumentation?: Instrumentation; // OTel settings
47+
modelProvider?: ModelProvider; // Model provider used by this agent
48+
}
49+
50+
interface Instrumentation {
51+
enableOtel: boolean; // default true - wrap entrypoint with opentelemetry-instrument
52+
}
53+
54+
interface EnvVar {
55+
name: string; // @regex ^[A-Za-z_][A-Za-z0-9_]*$ @max 255
56+
value: string;
57+
}
58+
59+
// ─────────────────────────────────────────────────────────────────────────────
60+
// MEMORY
61+
// ─────────────────────────────────────────────────────────────────────────────
62+
63+
interface Memory {
64+
type: 'AgentCoreMemory';
65+
name: string; // @regex ^[a-zA-Z][a-zA-Z0-9_]{0,47}$ @max 48
66+
eventExpiryDuration: number; // @min 7 @max 365 (days)
67+
strategies: MemoryStrategy[]; // @min 1, unique by type
68+
}
69+
70+
interface MemoryStrategy {
71+
type: MemoryStrategyType;
72+
name?: string; // @regex ^[a-zA-Z][a-zA-Z0-9_]{0,47}$ @max 48
73+
description?: string;
74+
namespaces?: string[];
75+
}
76+
77+
// ─────────────────────────────────────────────────────────────────────────────
78+
// CREDENTIAL
79+
// ─────────────────────────────────────────────────────────────────────────────
80+
81+
interface Credential {
82+
type: 'ApiKeyCredentialProvider';
83+
name: string; // @regex ^[A-Za-z0-9_.-]+$ @min 3 @max 255
84+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
2+
/**
3+
* READ-ONLY LLM CONTEXT - Do not edit this file.
4+
*
5+
* JSON File: agentcore/aws-targets.json
6+
* Purpose: AWS deployment targets for AgentCore resources
7+
*/
8+
9+
// ─────────────────────────────────────────────────────────────────────────────
10+
// ROOT SCHEMA: AwsDeploymentTargets (array)
11+
// ─────────────────────────────────────────────────────────────────────────────
12+
13+
// The JSON file contains an array of deployment targets.
14+
// Target names must be unique within the array.
15+
type AwsDeploymentTargets = AwsDeploymentTarget[];
16+
17+
interface AwsDeploymentTarget {
18+
name: string; // @regex ^[a-zA-Z][a-zA-Z0-9_-]*$ @max 64 - unique identifier
19+
description?: string; // @max 256
20+
account: string; // @regex ^[0-9]{12}$ - AWS account ID (exactly 12 digits)
21+
region: AgentCoreRegion;
22+
}
23+
24+
// ─────────────────────────────────────────────────────────────────────────────
25+
// SUPPORTED REGIONS
26+
// ─────────────────────────────────────────────────────────────────────────────
27+
28+
type AgentCoreRegion =
29+
| 'ap-northeast-1'
30+
| 'ap-south-1'
31+
| 'ap-southeast-1'
32+
| 'ap-southeast-2'
33+
| 'eu-central-1'
34+
| 'eu-west-1'
35+
| 'us-east-1'
36+
| 'us-east-2'
37+
| 'us-west-2';

agentcore/agentcore.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "autodeployed-agent",
3-
"version": "1",
2+
"name": "autodeployedagent",
3+
"version": 1,
44
"agents": [
55
{
66
"type": "AgentCoreRuntime",
@@ -10,7 +10,9 @@
1010
"codeLocation": ".",
1111
"runtimeVersion": "PYTHON_3_13",
1212
"networkMode": "PUBLIC",
13-
"instrumentation": { "enabled": true }
13+
"instrumentation": { "enableOtel": true }
1414
}
15-
]
15+
],
16+
"memories": [],
17+
"credentials": []
1618
}

0 commit comments

Comments
 (0)