<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Emdadul Islam - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Emdadul Islam - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 22:23:56 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/author/emdadulislam/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Deploy an AI Agent with Amazon Bedrock AgentCore ]]>
                </title>
                <description>
                    <![CDATA[ Amazon Bedrock AgentCore is a managed service that makes it easier to build, deploy, and operate AI agents securely at scale on AWS. It works seamlessly with frameworks like Strands Agents, LangGraph, CrewAI, and LlamaIndex, while taking care of the ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/deploy-an-ai-agent-with-amazon-bedrock/</link>
                <guid isPermaLink="false">68eef2757ef88f92913602c6</guid>
                
                    <category>
                        <![CDATA[ AI ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ai agents ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Artificial Intelligence ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Emdadul Islam ]]>
                </dc:creator>
                <pubDate>Wed, 15 Oct 2025 01:01:41 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1760489893067/3f33049f-d17e-4d94-8deb-fa43c65ec753.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Amazon Bedrock AgentCore is a managed service that makes it easier to build, deploy, and operate AI agents securely at scale on AWS. It works seamlessly with frameworks like Strands Agents, LangGraph, CrewAI, and LlamaIndex, while taking care of the complex tasks such as runtime management, IAM role configuration, and observability.</p>
<p>In this guide, you’ll set up your environment, create and test a simple AI agent locally, deploy it with the AgentCore starter toolkit, and invoke it through the AWS SDK.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a class="post-section-overview" href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-1-set-up-aws-cli">Step 1: Set Up AWS CLI</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-2-install-and-create-your-agent">Step 2: Install and Create Your Agent</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-create-a-requirementstxt-file">Create a requirements.txt file</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-breaking-down-the-code">Breaking Down the Code</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-step-3-test-the-agent-locally">Step 3: Test the Agent Locally</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-4-deploy-to-agentcore-runtime">Step 4: Deploy to AgentCore Runtime</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-5-invoke-the-agent-with-aws-sdk">Step 5: Invoke the Agent with AWS SDK</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-step-6-clean-up">Step 6: Clean Up</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-common-issues">Common Issues</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before you start, make sure you have:</p>
<ul>
<li><p>An AWS account with credentials configured.</p>
</li>
<li><p>AWS CLI installed and working.</p>
</li>
<li><p>Python 3.10 or later installed.</p>
</li>
<li><p>Boto3 installed.</p>
</li>
<li><p>Model access enabled in the Amazon Bedrock console (for example, Anthropic Claude Sonnet 4.0).</p>
</li>
</ul>
<h2 id="heading-step-1-set-up-aws-cli">Step 1: Set Up AWS CLI</h2>
<p>First, install the AWS CLI if you do not already have it. On Linux or macOS: <a target="_blank" href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI setup guide</a>.</p>
<p>Next, <a target="_blank" href="https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html">configure</a> a profile with AWS SSO:</p>
<pre><code class="lang-bash">aws configure sso --profile my-profile
</code></pre>
<p>You’ll be prompted to enter details such as:</p>
<ul>
<li><p><strong>SSO start URL</strong> – the URL for your AWS organization’s IAM Identity Center portal.</p>
</li>
<li><p><strong>SSO region</strong> – the AWS region where IAM Identity Center is configured.</p>
</li>
<li><p><strong>Account ID</strong> – the AWS account you want to access.</p>
</li>
<li><p><strong>Role name</strong> – the IAM role you want to assume within that account.</p>
</li>
<li><p><strong>Default region</strong> – the region that will be used when making requests.</p>
</li>
<li><p><strong>Default output format</strong> – for example, <code>json</code>, <code>yaml</code>, or <code>table</code>.</p>
</li>
</ul>
<p>This creates a new profile called <code>my-profile</code> in your AWS CLI configuration, allowing you to use that identity to interact with AWS services.</p>
<p>Next, you have to verify your identity. Once your profile is configured, confirm that the CLI is correctly authenticating with AWS by running:</p>
<pre><code class="lang-bash">aws sts get-caller-identity --profile my-profile
</code></pre>
<p>This command returns details about your identity, including:</p>
<ul>
<li><p><strong>Account</strong> – the AWS account ID you’re authenticated against.</p>
</li>
<li><p><strong>UserId</strong> – the unique identifier of your IAM role or user.</p>
</li>
<li><p><strong>Arn</strong> – the full Amazon Resource Name (ARN) of your identity.</p>
</li>
</ul>
<p>If the command succeeds and shows your account information, it means your profile is properly set up and ready to use with AWS SDKs, the AWS CLI, or services like Bedrock AgentCore.</p>
<h2 id="heading-step-2-install-and-create-your-agent">Step 2: Install and Create Your Agent</h2>
<p>First, you need to set up Python virtual environment. This prevents dependency conflicts with other projects on your machine.</p>
<p>Let’s create and activate a virtual environment:</p>
<p>On <strong>macOS/Linux:</strong></p>
<pre><code class="lang-bash">python3 -m venv .venv
<span class="hljs-built_in">source</span> .venv/bin/activate
</code></pre>
<p>On <strong>Windows (PowerShell or CMD):</strong></p>
<pre><code class="lang-python">python -m venv .venv
.venv\Scripts\activate
</code></pre>
<ul>
<li><p><code>python -m venv .venv</code> → creates a virtual environment named <code>.venv</code> in your project folder.</p>
</li>
<li><p><code>.venv\Scripts\activate</code> → activates the environment.</p>
</li>
</ul>
<p>Once activated, your terminal prompt will show (.venv) at the beginning. To deactivate:</p>
<pre><code class="lang-bash">deactivate
</code></pre>
<h3 id="heading-create-a-requirementstxt-file">Create a <code>requirements.txt</code> file</h3>
<p>List the dependencies your project needs by creating a file named <code>requirements.txt</code> in the project root:</p>
<pre><code class="lang-bash">bedrock-agentcore
strands-agents
</code></pre>
<p>This makes it easy to install everything at once with:</p>
<pre><code class="lang-python">pip install -r requirements.txt
</code></pre>
<p>Create a file called <code>my_agent.py</code> and add the following code:</p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> bedrock_agentcore <span class="hljs-keyword">import</span> BedrockAgentCoreApp
<span class="hljs-keyword">from</span> strands <span class="hljs-keyword">import</span> Agent

app = BedrockAgentCoreApp()
<span class="hljs-comment"># Create an agent with default settings</span>
agent = Agent()

<span class="hljs-meta">@app.entrypoint</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">invoke</span>(<span class="hljs-params">payload</span>):</span>
    <span class="hljs-string">"""Your AI agent function"""</span>
    user_message = payload.get(<span class="hljs-string">"prompt"</span>, <span class="hljs-string">"Hello! How can I help you today?"</span>)
    result = agent(user_message)
    <span class="hljs-keyword">return</span> {<span class="hljs-string">"result"</span>: result.message}

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    app.run()
</code></pre>
<h3 id="heading-breaking-down-the-code">Breaking Down the Code</h3>
<ul>
<li><p><code>BedrockAgentCoreApp</code> – the core runtime wrapper that handles configuration, execution, and integration with AWS services.</p>
</li>
<li><p><code>Agent</code> – a basic agent object from the Strands library that can process and respond to prompts.</p>
</li>
<li><p><code>BedrockAgentCoreApp()</code> creates the container application that manages your agent’s lifecycle.</p>
</li>
<li><p><code>Agent()</code> initializes a simple Strands agent with default settings. In a real-world case, you can customize this with specific tools, memory, or reasoning logic.</p>
</li>
<li><p>The <code>@app.entrypoint</code> decorator marks this function as the callable entry point for your agent. Whenever a request is sent to the agent (via the AWS SDK, CLI, or local test), this function is invoked.</p>
</li>
<li><p>The agent looks for a <code>"prompt"</code> in the incoming payload.</p>
</li>
<li><p>If no prompt is provided, it defaults to <code>"Hello! How can I help you today?"</code>.</p>
</li>
<li><p>The <code>Agent</code> object then processes this input and generates a response.</p>
</li>
</ul>
<h2 id="heading-step-3-test-the-agent-locally">Step 3: Test the Agent Locally</h2>
<p>Run the agent:</p>
<pre><code class="lang-bash">python3 -u my_agent.py
</code></pre>
<p>Open another terminal and send a request:</p>
<pre><code class="lang-bash">curl -X POST http://localhost:8080/invocations \
  -H <span class="hljs-string">"Content-Type: application/json"</span> \
  -d <span class="hljs-string">'{"prompt": "Hello!"}'</span>
</code></pre>
<p>If successful, you will see:</p>
<pre><code class="lang-plaintext">{"result": "Hello! I'm here to help..."}
</code></pre>
<p>You can stop the agent with Ctrl+C.</p>
<h2 id="heading-step-4-deploy-to-agentcore-runtime">Step 4: Deploy to AgentCore Runtime</h2>
<p>Now you are ready to deploy your agent to AWS.</p>
<p>Configure the agent:</p>
<pre><code class="lang-plaintext">agentcore configure -e my_agent.py
</code></pre>
<p>This creates a configuration file called <code>bedrock_agentcore.yaml</code>.</p>
<p>You can launch the deployment with this command:</p>
<pre><code class="lang-plaintext">agentcore launch
</code></pre>
<p>The output will include:</p>
<ul>
<li><p>The Amazon Resource Name (ARN) of your agent.</p>
</li>
<li><p>The location of logs in Amazon CloudWatch.</p>
</li>
</ul>
<p>Test your deployed agent:</p>
<pre><code class="lang-bash">agentcore invoke <span class="hljs-string">'{"prompt": "tell me a joke"}'</span>
</code></pre>
<p>If you get a joke back, your agent is running successfully.</p>
<h2 id="heading-step-5-invoke-the-agent-with-aws-sdk">Step 5: Invoke the Agent with AWS SDK</h2>
<p>You can call your agent programmatically using Boto3. Create a file called <code>invoke_agent.py</code>:</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> json
<span class="hljs-keyword">import</span> boto3

agent_arn = <span class="hljs-string">"YOUR_AGENT_ARN"</span>
prompt = <span class="hljs-string">"Tell me a joke"</span>

agent_core_client = boto3.client(<span class="hljs-string">"bedrock-agentcore"</span>)

payload = json.dumps({<span class="hljs-string">"prompt"</span>: prompt}).encode()

response = agent_core_client.invoke_agent_runtime(
    agentRuntimeArn=agent_arn,
    payload=payload
)

content = []
<span class="hljs-keyword">for</span> chunk <span class="hljs-keyword">in</span> response.get(<span class="hljs-string">"response"</span>, []):
    content.append(chunk.decode(<span class="hljs-string">"utf-8"</span>))
print(json.loads(<span class="hljs-string">""</span>.join(content)))
</code></pre>
<p>Run the script:</p>
<pre><code class="lang-plaintext">python invoke_agent.py
</code></pre>
<p>You should see the AI agent’s response.</p>
<h2 id="heading-step-6-clean-up">Step 6: Clean Up</h2>
<p><strong>If you no longer want to run the agent, delete the runtime:</strong></p>
<pre><code class="lang-plaintext">aws bedrock-agentcore delete-agent-runtime --agent-runtime-arn &lt;your_arn&gt;
</code></pre>
<h3 id="heading-common-issues">Common Issues</h3>
<ul>
<li><p><strong>Permission denied</strong>: Check your AWS credentials and IAM policies.</p>
</li>
<li><p><strong>Docker warning</strong>: Ignore this unless you use — local or — local-build.</p>
</li>
<li><p><strong>Model access denied</strong>: Enable model access (such as Claude Sonnet 4.0) in the Bedrock console.</p>
</li>
<li><p><strong>Build errors</strong>: Check CloudWatch build logs and IAM policies.</p>
</li>
</ul>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Amazon Bedrock AgentCore makes it easy to create and deploy AI agents without dealing with complex container setups or infrastructure. You can test locally, launch to the cloud with one command, and monitor everything through CloudWatch.</p>
<p>This workflow is ideal for developers who want to move from prototype to production quickly while staying inside the AWS ecosystem.</p>
<p>Resources:</p>
<p><a target="_blank" href="https://strandsagents.com/latest/">https://strandsagents.com/latest/</a></p>
<p><a target="_blank" href="https://aws.amazon.com/bedrock/agentcore/">https://aws.amazon.com/bedrock/agentcore/</a></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
