This Pulumi program provisions production-ready infrastructure for deploying a LangGraph ReAct agent to AWS Bedrock AgentCore. It creates all necessary AWS resources using infrastructure as code, including Knowledge Bases, Lambda functions, and containerized agent runtime.
- AWS CLI configured with appropriate credentials
- Docker installed and running
- Pulumi CLI installed
- Python 3.12+
- UV package manager (installation guide)
-
Deploy CloudFormation stack (Knowledge Bases, Lambdas, Guardrails):
aws cloudformation create-stack \ --stack-name pet-store-kb \ --template-body file://pet_store_knowledge_bases.yaml \ --capabilities CAPABILITY_IAM
-
Sync Knowledge Bases:
- Navigate to AWS Console → Bedrock → Knowledge Bases
- Sync both Product Info and Pet Care knowledge bases
-
Install dependencies:
uv sync
-
Configure Pulumi with CloudFormation outputs:
uv run python setup_config.py pet-store-kb
-
Login to Pulumi (if needed):
pulumi login
-
Preview infrastructure:
pulumi preview
-
Deploy infrastructure:
pulumi up
The infrastructure includes:
- AWS Bedrock AgentCore Runtime: Containerized execution environment for the LangGraph agent
- ECR Repository: Stores the ARM64 Docker image for the agent
- Knowledge Bases (2):
- Product Information KB
- Pet Care KB
- Lambda Functions (2):
- Inventory Management System
- User Management System
- Guardrails: Content filtering and safety controls
- IAM Roles & Policies: Secure access control for all components
- ARM64 Architecture: Optimized for AWS Graviton processors
- OpenTelemetry Integration: Full observability with CloudWatch GenAI dashboard
- Automated Docker Build: Uses Pulumi Docker Build provider for image building
- Production Security: Proper IAM roles, policies, and guardrails
- UV Package Manager: Fast, reliable dependency management
- ECR Repository: Container image storage with lifecycle policy
- Docker Image: LangGraph agent with OpenTelemetry instrumentation
- AgentCore Runtime: Serverless runtime integrated with Knowledge Bases, Lambda, and Guardrails
- Configuration: Pulumi stack configuration from CloudFormation outputs
- CloudFormation stack deployed and Knowledge Bases synced
- AWS CLI configured with appropriate credentials
- Docker installed and running
- Pulumi CLI installed
- UV package manager (already configured)
# Preview changes
pulumi preview
# Deploy infrastructure
pulumi up
# Get outputs
pulumi stack outputagent_runtime_arn: Full ARN for agent invocationagent_runtime_name: Runtime name for evaluationecr_repository_url: Container image repository
The deployed agent handles:
- Product Queries: Retrieves product info from knowledge base
- Inventory Checks: Real-time inventory via Lambda
- User Management: Customer lookup by ID and email
- Pet Care Advice: Provides advice from knowledge base
- Order Processing: Calculates pricing, discounts, and shipping
- Business Rules:
- 15% discount on orders over $300
- 10% multi-unit discount
- Dynamic shipping costs
- Inventory replenishment alerts
The agent includes full OpenTelemetry instrumentation:
- Service Name:
langgraph-agent - Dashboard: CloudWatch GenAI Observability
- Traces: Full request/response tracing
- Metrics: Performance and usage metrics
Invoke the agent runtime:
import boto3
import json
import uuid
client = boto3.client('bedrock-agentcore')
response = client.invoke_agent_runtime(
agentRuntimeArn='<from-pulumi-output>',
qualifier='DEFAULT',
traceId=str(uuid.uuid4()),
contentType='application/json',
payload=json.dumps({
"prompt": "What's the price of Doggy Delights?"
})
)- "Knowledge Base not found": Ensure KB synced in AWS Console
- "Docker build failed": Check Docker daemon and ECR permissions
- "Runtime creation failed": Verify IAM role permissions and CloudFormation outputs
pulumi destroy- The agent code is located in the
pet_store_agentdirectory - Docker build uses ARM64 platform for optimal AgentCore performance
- All resources follow AWS best practices
- Configuration is automatically populated from CloudFormation stack outputs