How to Deploy an AI Agent to Amazon Bedrock AgentCore
Your agent works on your laptop. Now let other apps, and other people, call it safely.

In this agentic era, everybody is trying to build an agent. But most of the time, that agent lives in one place: your laptop.
That is fine while you are the only person using it. But what if you have an existing app that needs to call your agent? What if someone outside your company wants to use it? You can’t ask them to connect to your laptop.
So how would this be done?
There are many platforms you can deploy an agent to, but one that AWS has beautifully designed is Amazon Bedrock AgentCore. In this article, I’m going to take you from an agent on your laptop to an agent that other apps can safely call.
Here is what we will end up with:

What is Amazon Bedrock AgentCore?
Think about opening a restaurant. You can be a great cook at home, but to serve the public you also need a building, a front door, somebody who checks who comes in, and a way to see what is going on in the kitchen.
In this picture, your agent is the cook. It does the real work: it takes a question, thinks about it, uses its tools, and comes back with an answer.
AgentCore is the restaurant around the cook. It gives your agent a place to run, checks who is allowed to call it, keeps one customer’s conversation apart from another’s, and lets you see what your agent did. You could build all of that yourself, but you would spend more time on the building than on the cooking.
One thing AgentCore doesn’t do is the thinking. That comes from the AI model your agent uses. In this article, it is a model on Amazon Bedrock.
AgentCore is made up of different components, and you can pick the ones you need. These are the main ones. To make them easy to picture, let’s use a course adviser for a training school as the example:
-
Runtime: This is where your agent lives. You hand over your agent, and AWS runs it for you. There is no server to set up, update or restart. If nobody is asking questions at 3 a.m., nothing needs to sit there waiting. If many students ask at the same time, it runs a separate session for each of them.
-
Memory: This helps your agent remember. On its own, the agent can follow a conversation while it is going on, but once that session ends, it forgets. With Memory, a student can come back next week and pick up where they left off, and the adviser can remember they were interested in Kubernetes.
-
Identity: This is the security at the door. It checks who is allowed to talk to your agent. It also works the other way: if your agent needs to open something on a student’s behalf, such as their calendar, Identity helps it get in safely.
-
Gateway: This connects your agent to what you already have. Your school probably has a system with course prices and dates. Gateway turns systems like that into tools the agent can use, so you don’t have to build them again.
-
Code Interpreter: This gives your agent a safe place to calculate things by running code. Say a student asks for a payment plan over six months. The agent can write a small piece of code to work it out, and run it somewhere that can’t affect your other systems.
-
Browser: This lets your agent use a website like a person would. It can open a page, click and fill in a form. This helps when a site has no other way for a program to connect to it.
-
Policy: These are the house rules. They decide what your agent may and may not do with its tools. For example, it can look up a price, but it can’t give a 90% discount, no matter how nicely a student asks.
-
Observability: This is the camera in the kitchen. It shows what your agent did, step by step. If it gives a student a wrong answer, you can look back and see where it went wrong.
In this article, we’ll focus on Runtime, and on controlling who can call your agent.
Don’t mix these up: Bedrock Guardrails is a separate AWS feature that filters what goes into and comes out of a model. The controls in this article decide who can call your agent.
What we are going to build
We’ll build a small course adviser for a training school. You ask it about a course, it looks up the price and the duration, and it answers.
It is small on purpose. Once you can deploy this one, you can deploy a much bigger one the same way.
To build an agent, you normally use a framework. A framework gives you the common parts, such as talking to the model and using tools, so you don’t have to write them yourself. There are many to choose from, including LangChain, LangGraph, CrewAI, Claude Agent SDK and Mastra.
In this article, I’m using Strands Agents. The reason is simple: Strands is an open-source framework built by AWS, so it works well with Amazon Bedrock out of the box, and it makes it very easy to build an agent in a few lines of code.
You are not tied to it. The framework is how you build your agent, and AgentCore is where you run it. If you already use another framework, you can still deploy your agent to AgentCore.
We’ll do it in 8 short steps:
- Install the AgentCore CLI
- Create the project
- Write the agent
- Test it on your laptop
- Deploy it
- Call it from your app
- Let people outside call it
- Clean up
Before you start
What it helps to know
You don’t need to be an expert, but it will be good to have some knowledge of these:
- Python: enough to read a short script, and understand functions and how to install packages.
- AWS basics: what an account, a Region and an ARN are.
- IAM: the idea of roles, policies and permissions. It matters most in Step 6, when your app calls the agent.
- The command line: moving between folders and running commands.
- JSON and APIs: what a request and a response are, because that is how apps will talk to your agent.
- AI agents: the basic idea that an agent uses a model to think, and tools to get things done.
Step 7, letting people outside call your agent, also needs a basic idea of tokens and how users sign in. If that is new to you, you can skip it and still have a working agent.
You don’t need to know Kubernetes or machine learning. You don’t need Docker either, because by default your code is packaged as a zip file.
What you need to have
- An AWS account, with your credentials set up on your laptop
- Python 3.10 or later
- Node.js 22 or later, because the AgentCore command line tool is installed with npm
- uv, the Python package manager the generated project uses
- Permission in your AWS account to deploy with CloudFormation and AgentCore
For Step 6, you also need the AWS SDK for Python, which you can install with pip install boto3. For Step 7, you need an Amazon Cognito user pool, and curl, jq and uuidgen on your laptop.
On Windows? The commands in this article are for Linux and Mac, so use WSL. Install Node.js inside WSL, then run
which npm. If the path starts with/mnt/c, you are still using the Node.js from Windows, and the wrong version may be picked up.
Step 1: Install the AgentCore CLI
npm install -g @aws/agentcore
agentcore --version
Did you use AgentCore before? The older Python starter toolkit has a command with the same name, and it can get in the way, especially on Windows. Remove it with
pip uninstall bedrock-agentcore-starter-toolkitand open a new terminal.
Step 2: Create the project
agentcore create --name CourseAdviser --template agent-python-strands
cd CourseAdviser
These are the files that matter most:
CourseAdviser/
├── agentcore/
│ ├── agentcore.json # what gets deployed
│ └── aws-targets.json # which AWS account and Region
└── app/
└── agent/
├── main.py # your agent
└── model/
└── load.py # which AI model it uses
Open aws-targets.json. It starts empty ([]). If you leave it like that, the CLI fills it in when you deploy, using whichever AWS account you are signed in to. It is safer to fill it in yourself, so you know exactly where your agent is going:
[
{
"name": "default",
"account": "123456789012",
"region": "us-east-1"
}
]
Replace the account number with your own. You can get it with:
aws sts get-caller-identity --query Account --output text
The template also adds an AgentCore Memory resource. We won’t use it in this article, but it is created when you deploy.
Step 3: Write the agent
Open app/agent/main.py and replace what is there with this:
from bedrock_agentcore.runtime import BedrockAgentCoreApp
from model.load import load_model
from strands import Agent, tool
app = BedrockAgentCoreApp()
COURSES = {
"kubernetes": {"price": "$500", "weeks": 8},
"aws": {"price": "$400", "weeks": 6},
"terraform": {"price": "$250", "weeks": 3},
}
@tool
def get_course(name: str) -> str:
"""Get the price and duration of a course.
Args:
name: The course name, for example kubernetes, aws or terraform.
"""
course = COURSES.get(name.strip().lower())
if not course:
return f"No course called {name}. Available: {', '.join(COURSES)}"
return f"{name}: {course['price']}, {course['weeks']} weeks"
agent = Agent(
model=load_model(),
system_prompt="You are a friendly course adviser. Use get_course for prices. Never guess a price.",
tools=[get_course],
)
@app.entrypoint
def invoke(payload, context):
prompt = payload.get("prompt")
if not isinstance(prompt, str) or not prompt.strip():
return {"error": "Send a prompt"}
return {"answer": str(agent(prompt))}
if __name__ == "__main__":
app.run()
There are only three things to understand here:
- The tool.
@toolturns a normal Python function into something the agent can use. The agent reads your docstring to know when to use it, so write it clearly. - The agent. You give it a model, instructions and a list of tools. Strands takes care of the back and forth with the model.
load_model()comes frommodel/load.py, so that is the file to open if you want a different model. - The entrypoint.
@app.entrypointmarks the function AgentCore runs when somebody calls your agent. Whatever the caller sends arrives inpayload.
Those last few lines are what turn an agent on a laptop into one that can be deployed.
Choose the model
The template sets a model for you, but not every AWS account is allowed to use every model. If yours isn’t, you’ll see an AccessDeniedException saying the model “is not available for this account”.
To avoid that, I’m using Amazon Nova 2 Lite, which is AWS’s own model. Open app/agent/model/load.py and change the model ID:
from strands.models.bedrock import BedrockModel
def load_model() -> BedrockModel:
"""Get Bedrock model client using IAM credentials."""
return BedrockModel(model_id="us.amazon.nova-2-lite-v1:0")
The us. at the start is for US Regions, such as us-east-1. You can use any other model your account allows, as long as it supports tools.
Step 4: Test it on your laptop
export AWS_REGION=us-east-1
agentcore dev --mode browser
This starts your agent locally and opens the Agent Inspector in your browser, where you can chat with it. Ask it:
How much is the Kubernetes course, and how long does it take?
This is what I got:

Look at 1 tool used. The agent called our get_course function with kubernetes, got back $500, 8 weeks, and used that to write its answer. It didn’t guess.
Now ask about a course that isn’t on the list. It should tell you it isn’t available, not make up a price. When you are done, press Ctrl+C in the terminal to stop it.
Is it talking to Bedrock already? Yes. Your agent’s code is running on your laptop, but the model it thinks with is on Amazon Bedrock. Your agent calls it using your AWS credentials, so you need an internet connection and access to the model, and you pay a little for each question. What we haven’t used yet is AgentCore Runtime. That comes next.
Step 5: Deploy it
agentcore build
agentcore deploy
The deployment can take some time, especially the first one, because it also prepares your AWS account for the AWS CDK. Let it run. When it finishes, you should see something like this:

The line to look for is deployed project ‘CourseAdviser’ to target ‘default’. I’ve hidden my AWS account number, and yours will show there instead.
Good to know: deploying also turns on CloudWatch Transaction Search for your AWS account, which helps with tracing. If you don’t want that, run
agentcore config transactionSearch falsebefore you deploy.
You can also see your agent in the AWS console. Open Amazon Bedrock AgentCore, choose Agents, and select your agent:

The Type is Runtime and the Status is Active, so your agent is now on AgentCore. There is no activity yet because nobody has called it.
Now check on your agent and call it:
agentcore status
agentcore invoke --runtime agent --payload '{"prompt":"How much is the AWS course?"}'
Here, you are sending it a test question, just like an app would. This is the answer I got:

The status=200 means the call worked. The ** around some words is Markdown, the model’s way of making text bold, so your app can display it that way or remove it.
Your agent is no longer only on your laptop. It is running on AWS.
Now get its address, which you’ll need in the next step. Run the command below and copy the Runtime’s arn:
agentcore status --json
Step 6: Call it from your app
Here is the first question we started with: how does an existing app call your agent?
If the app runs on AWS, or has AWS credentials, it can call the agent with the AWS SDK. By default, AgentCore only accepts calls signed with AWS credentials (IAM), so nobody can call your agent just because they know it exists.
Here is all the code your app needs. Save it as app.py, put in your own ARN, and run it with python app.py:
import json
import uuid
import boto3
client = boto3.client("bedrock-agentcore", region_name="us-east-1")
AGENT_ARN = "arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/YOUR_RUNTIME_ID"
def ask_adviser(question: str, session_id: str) -> str:
response = client.invoke_agent_runtime(
agentRuntimeArn=AGENT_ARN,
runtimeSessionId=session_id,
payload=json.dumps({"prompt": question}).encode(),
)
body = b"".join(response["response"])
return json.loads(body)["answer"]
session = str(uuid.uuid4())
print(ask_adviser("How much is the Terraform course?", session))
print(ask_adviser("And how long does it take?", session))
Notice the session_id. Use the same one for every message in a conversation, and a new one for each customer. AgentCore keeps each session isolated from the others, so one customer’s conversation doesn’t mix with another’s.
The app also needs permission. Give its IAM role access to this one agent and nothing more:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "bedrock-agentcore:InvokeAgentRuntime",
"Resource": [
"arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/YOUR_RUNTIME_ID",
"arn:aws:bedrock-agentcore:us-east-1:111122223333:runtime/YOUR_RUNTIME_ID/*"
]
}
]
}
Step 7: Let people outside call it
Now the second question: what if the caller is outside, and doesn’t have AWS credentials?
You don’t want to hand out AWS keys. Instead, let callers sign in and send a token, the same way most modern APIs work. AgentCore can check tokens from Amazon Cognito, Okta, Microsoft Entra ID, Auth0 and others.
A runtime accepts either AWS credentials or tokens, not both. So for outside callers, you add a second runtime that checks tokens. With Amazon Cognito, it looks like this:
export REGION=us-east-1
export POOL_ID=your-user-pool-id
export CLIENT_ID=your-app-client-id
agentcore add runtime --name PublicAdviser --language python --protocol HTTP \
--authorizer-type CUSTOM_JWT \
--authorizer-configuration "{\"customJwtAuthorizer\":{\"discoveryUrl\":\"https://cognito-idp.$REGION.amazonaws.com/$POOL_ID/.well-known/openid-configuration\",\"allowedClients\":[\"$CLIENT_ID\"]}}" \
--request-header-allowlist Authorization
Give it the same agent code, the same model, and the packages it needs:
cp app/agent/main.py app/PublicAdviser/
cp -r app/agent/model app/PublicAdviser/
cd app/PublicAdviser
uv init --bare
uv add "bedrock-agentcore[strands-agents]" strands-agents "botocore[crt]" aws-opentelemetry-distro
cd ../..
agentcore build
agentcore deploy
Run agentcore status --json again and copy the new runtime’s arn. Your partner signs in, gets a token, and calls the agent over plain HTTPS:
export AGENT_ARN=the-arn-of-PublicAdviser
export TOKEN=the-token-from-signing-in
export SESSION_ID=$(uuidgen)
export ESCAPED_ARN=$(printf '%s' "$AGENT_ARN" | jq -sRr '@uri')
curl -X POST "https://bedrock-agentcore.$REGION.amazonaws.com/runtimes/$ESCAPED_ARN/invocations?qualifier=DEFAULT" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-H "X-Amzn-Bedrock-AgentCore-Runtime-Session-Id: $SESSION_ID" \
-d '{"prompt":"How much is the Kubernetes course?"}'
Without a valid token, the caller gets a 401 and never reaches your agent.
So which one should you use?
| Who is calling? | Use |
|---|---|
| Your own app, on AWS | IAM, with the AWS SDK |
| A partner, a mobile app or a customer | Tokens, with Cognito or your own sign-in provider |
Step 8: Clean up
With Runtime, you pay for the CPU and memory your agent sessions use. You also pay for the model, and for any other AgentCore components you use. If you were only trying this out, remove what you deployed:
agentcore remove all --yes
agentcore deploy --yes
The first command empties your project’s list of resources. The second one is what removes them from AWS, so don’t skip it. Your code stays on your laptop.
A few things are left behind, so check them if you want a completely clean account: the CDKToolkit stack in CloudFormation (keep it if you use the CDK for anything else), your agent’s logs in CloudWatch, the Transaction Search setting, and the Cognito user pool if you did Step 7.
Should you use the AgentCore CLI in production?
The AgentCore CLI is great when you want to build, test and try out an agent quickly. One command creates everything the agent needs, and you can be up and running the same day.
You can use it in production too. But if your environment is going to host many agents, built by many teams, you may not want each team deploying from its own CLI. Instead, use the standards you already have.
Remember what we are really deploying here. We are not deploying Bedrock, and we are not deploying AgentCore. AWS already runs those. What we deploy is a Runtime that holds our agent, and the resources around it. That is something your existing infrastructure as code can create, whether you use Terraform, CloudFormation or CDK.
In that setup, the work is shared like this:
| Who | What they own |
|---|---|
| Platform team | A reusable module that creates the Runtime, its IAM role, sign-in, networking and logging, with your company’s rules built in |
| Agent developers | The agent’s code, its tools and its instructions |
| App developers | The app that calls the agent |
Then you put that module behind your internal developer platform, so nobody has to know how it works underneath:
- A developer asks the platform for a new agent, and gives it a name and a code repository.
- The pipeline packages the code and stores it, as a zip or a container image.
- The infrastructure as code creates the Runtime from that package, with the right permissions.
- The platform gives back the Runtime’s ARN.
- App developers deploy their apps with permission to call that ARN, just like we did in Step 6.
The developers get a working agent in minutes, and the platform team knows that every agent was created the same way, with the same security.
One thing to know: a Runtime can’t be created empty and filled in later. It needs your agent’s package from the start, so the pipeline must build the package before it creates the Runtime.
Whichever you choose, don’t manage the same Runtime with both the CLI and your own infrastructure as code. One can undo the changes made by the other.
So use the CLI to learn and to try ideas quickly. When you have many agents to run, let your platform do the deploying.
Coming next: in my next post, I’ll show you how to build this with a CI/CD pipeline. It will build the agent as a container image, push it to Amazon ECR, and use a Terraform module to create the Runtime, all in one pipeline.
Where to go from here
We started with an agent on a laptop that nobody else could reach. Now it runs on AWS, your own apps can call it, and people outside can call it with a token.
From here, you can add one thing at a time:
- Memory, so it remembers returning customers
- Gateway, so it reads real prices from your own API
- Policy, so you decide which tools it may call
- Observability, so you can see why it gave an answer
Building an agent is the fun part. But an agent only becomes useful when others can call it, safely.





