
Building a Multi-Capability AI Agent on Amazon Bedrock AgentCore using Strands Agents
In this article, I have demonstrated how to build an Agent using Strands Agents SDK and host it on Amazon Bedrock AgentCore
As AI agents become increasingly central to modern applications, the need for robust, scalable, and easily deployable agent infrastructure has never been greater. In this post, I'll walk you through building and deploying a production-ready AI agent on AWS Bedrock AgentCore that combines weather forecasting and commodity rate tracking capabilities using the Strands framework.
What is Amazon Bedrock AgentCore and Strands Agents?
Amazon Bedrock AgentCore is a fully managed service that simplifies the deployment and operation of AI agents. It handles the underlying infrastructure, scaling, and orchestration, allowing developers to focus on building agent capabilities rather than managing servers. Building production-ready AI agents get easier using Strands Agent SDK which is a model-driven, open source SDK that works with Amazon Bedrock, Anthropic, OpenAI, and more.
Project Overview
This solution deploys an AI agent built with the Strands SDK, equipped with two capabilities: retrieving weather forecasts and fetching metal commodity rates. The agent leverages the "minimax.minimax-m2.5" Bedrock Foundation Model for natural language understanding and response generation.
The complete project is available here .
Key Features
- Weather Information: Real-time weather forecasts for US locations using the National Weather Service API
- Metal Commodity Rates: Current gold and silver prices in USD via Gold API
- Containerized Architecture: Runs as a Docker container optimized for ARM64
- Infrastructure as Code: Complete Terraform configuration for reproducible deployments
Architecture Components

1. Application Layer (agent-app/)
The core agent is built using the Strands SDK, which provides a high-level abstraction for creating AI agents with tool-calling capabilities.
1
2
3
4
5
6
7
8
9
10
11
from strands import Agent, tool
from strands.models import BedrockModel
from bedrock_agentcore import BedrockAgentCoreApp
# Initialize the agent with memory
weather_agent = Agent(
model=BedrockModel(model_id="minimax.minimax-m2.5", region_name="eu-west-1"),
system_prompt=MULTI_SYSTEM_PROMPT,
tools=[http_request, get_metal_rates],
memory=True
)Custom Tool Example:
1
2
3
4
5
6
7
8
def get_metal_rates(metal: str) -> dict:
"""Fetch current rates for gold or silver."""
metal = metal.lower()
symbol = "XAU" if metal == "gold" else "XAG"
api_url = f"https://api.gold-api.com/price/{symbol}/USD"
response = requests.get(api_url)
return response.json()2. Infrastructure Layer (agent-infra/)
The infrastructure is fully automated using Terraform with the following resources:
- ECR Repository: Stores Docker images with lifecycle policies
- IAM Roles: Comprehensive permissions for ECR, CloudWatch, Bedrock, X-Ray, and more
- CloudWatch Log Groups: Centralized logging for monitoring and debugging
- Bedrock AgentCore Runtime: Managed runtime environment for the agent
Key IAM Permissions:
1
2
3
4
5
6
- ECR: Pull container images
- CloudWatch Logs: Write to /aws/bedrock-agentcore/runtimes/*
- Bedrock: Invoke foundation models
- X-Ray: Tracing and telemetry
- CloudWatch Metrics: Custom metrics
- EFS/S3 Files: Optional file system accessDeployment Strategy
The project includes two deployment scripts designed for different scenarios:
Fresh Deployment
1
IMAGE_TAG=$(date +%Y%m%d-%H%M%S) ./deploy-fresh.shProcess:
- Creates all infrastructure resources (ECR, IAM, CloudWatch) except the runtime
- Builds Docker image for linux/arm64 platform
- Pushes image to ECR with unique tag
- Creates Bedrock AgentCore runtime with the new image
Runtime Updates
1
IMAGE_TAG=v2.0.0 ./update-runtime.shProcess:
- Builds updated Docker image
- Pushes to ECR with new tag
- Updates runtime configuration with new image
Key Technical Decisions
1. ARM64 Architecture
Bedrock AgentCore requires ARM64 images. The deployment scripts automatically detect Apple Silicon and use the appropriate Docker build flags:
1
2
3
4
if [[ "$(uname -m)" == "arm64" ]]; then
PLATFORM_FLAG="--platform linux/arm64"
fi
docker build ${PLATFORM_FLAG} -t ${ECR_REPO_URL}:${IMAGE_TAG} .2. Immutable Image Tags
To support proper version control and rollbacks, the infrastructure uses variable image tags:
1
container_uri = "${aws_ecr_repository.agent_repo.repository_url}:${var.image_tag}"This allows for timestamp-based or semantic versioning of deployments.
3. Targeted Terraform Deployments
The deployment script uses targeted applies to ensure proper resource creation order:
1
2
3
4
5
6
terraform apply -target=aws_ecr_repository.agent_repo \
-target=aws_ecr_lifecycle_policy.agent_repo_policy \
-target=aws_iam_role.this \
-target=aws_iam_role_policy.this \
-target=aws_cloudwatch_log_group.agentcore_runtime_logs \
-auto-approveThis prevents circular dependencies and ensures the Docker image can be pushed before the runtime is created.
Testing the Agent
Generate Session ID
Session IDs must be 33+ characters for AgentCore:
1
SESSION_ID=$(echo "test-session-$(date +%Y%m%d%H%M%S)-$(uuidgen | cut -c1-8)")Invoke the Agent
Using AWS CLI:
1
2
3
4
5
aws bedrock-agentcore invoke-agent-runtime \
--agent-runtime-id <runtime-id> \
--session-id "${SESSION_ID}" \
--prompt "What's the weather in Boston and the current gold price?" \
--region eu-west-1Using Python Test Script:
The project includes a ready-to-use test script in the
test/ folder:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# test/test-bedrock-runtime.py
import boto3
import json
import uuid
from datetime import datetime
session_id = f"test-session-{datetime.now().strftime('%Y%m%d%H%M%S')}-{str(uuid.uuid4())[:8]}"
client = boto3.client('bedrock-agentcore', region_name='eu-west-1')
payload = json.dumps({"prompt": "What is the weather like in Boston today?"}).encode('utf-8')
response = client.invoke_agent_runtime(
agentRuntimeArn='arn:aws:bedrock-agentcore:eu-west-1:0123456789:runtime/weatheragent-xxx',
runtimeSessionId=session_id,
payload=payload
)
response_body = response['response'].read()
response_data = json.loads(response_body)
print("Agent Response:", response_data)Run the test:
1
python3 test/test-bedrock-runtime.pyNote: Update the
agentRuntimeArn in the test script with your actual runtime ARN from Terraform outputs.Sample Response
1
2
3
4
5
6
7
8
9
10
11
Here's the current weather in Boston and the price of gold:
🌤️ Boston Weather Today
- Conditions: Partly Sunny
- High: 89°F
- Wind: 6-13 mph from Southwest
- Precipitation: 8% chance
🥇 Gold Price
- Price: $4,176.20 USD per ounce
- Updated: Just nowMonitoring and Observability
CloudWatch Logs
1
aws logs tail /aws/bedrock-agentcore/runtimes/weatheragent --follow --region eu-west-1X-Ray Tracing
The agent automatically sends traces to X-Ray for:
- Request latency analysis
- Tool invocation performance
- Error tracking and debugging
Custom Metrics
CloudWatch metrics are published to the
bedrock-agentcore namespace for monitoring agent performance.Lessons Learned
- ARM64 Compatibility: Ensure all dependencies support ARM64 architecture
- State Management: Never manually recreate Terraform state files; always use imports or destroy/recreate
- Image Tag Strategy: Use unique tags (timestamps/versions) to avoid immutability issues
- Permission Scoping: Start with comprehensive permissions and narrow down based on usage patterns
- Testing Strategy: Maintain separate session IDs for testing to avoid polluting production memory
Cost Optimization
- ECR Lifecycle Policies: Keep only the last 10 images to manage storage costs
- CloudWatch Log Retention: Set to 7 days for development (adjust for production)
- On-Demand Scaling: AgentCore scales automatically based on demand
- Resource Tagging: Tag all resources for cost allocation and tracking
Future Enhancements
- Additional Tools: Integrate with more APIs (news, stocks, calendar)
- Multi-Region Deployment: Deploy across regions for lower latency
- Enhanced Memory: Implement vector databases for semantic memory
- Authentication: Add IAM-based authentication for production use
- CI/CD Pipeline: Automate deployments with GitHub Actions or CodePipeline
Conclusion
AWS Bedrock AgentCore provides a powerful platform for deploying production-ready AI agents with minimal infrastructure management. By combining it with the Strands SDK and Infrastructure as Code, we've created a scalable, maintainable, and extensible agent solution.
The complete source code and deployment scripts are available in the project repository . Whether you're building a simple chatbot or a complex multi-tool agent, this architecture provides a solid foundation for your AI agent projects.
Resources
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article