AgentCore运行时平台
生产就绪的AWS Bedrock AgentCore运行时,使用Strands代理与Atlassian MCP工具集成,Cognito经过身份验证的流式聊天前端,以及用于ECR、网关、内存和Cognito的Terraform基础设施。
此存储库部署了什么
- 基岩代理Core运行Strands代理时
- AgentCore网关和MCP目标配置
- 用于会话和长期上下文的AgentCore内存
- Cognito用户池+OIDC应用程序客户端,用于前端身份验证
- 使用Cognito代币保护的Angular流媒体聊天前端
- ECR存储库和ARM64容器映像工作流
结构
src/
└── agentcore_strands/
├── __init__.py
└── agent.py # Strands agent with memory support
scripts/
└── invoke.py # Script to invoke deployed runtime
push-to-ecr.sh # Script to build and push Docker image to ECR
examples/
├── agent.local.py # Local development example
└── example.local.md
infra/terraform/
├── cognito/
├── gateway/
├── memory/
├── runtime/
└── ecr/
docs/
├── AUTHENTICATION.md
├── JWT_TOKEN_GUIDE.md
├── CLOUDWATCH_LOGS.md
├── ATLASSIAN_MCP_INTEGRATION_BACKEND.md
├── ATLASSIAN_MCP_INTEGRATION_FRONTEND.md
├── strands-agent-integration.md
└── runtime-gateway-integration.md
frontend/ # Angular chat client for runtime integration
Dockerfile # Container image for AgentCore Runtime
pyproject.toml # uv dependency management快速开始
1.部署ECR存储库
cd infra/terraform/ecr
terraform init
terraform apply -var="repository_name=agentvault_agent"2.构建并推送Docker镜像
export AWS_REGION=eu-west-1
export ECR_REPO_NAME=agentvault_agent
./push-to-ecr.sh在Terraform、Docker推送和运行时部署中使用相同的存储库名称和区域。
3.部署网关
cd infra/terraform/gateway
terraform init
terraform apply4.部署内存
cd infra/terraform/memory
terraform init
terraform apply -var="memory_name=my_agent_memory"5.部署Cognito
cd infra/terraform/cognito
terraform init
terraform apply6.部署运行时
使用Gateway、Memory和Cognito JWT授权值部署运行时:
GATEWAY_ID=$(cd infra/terraform/gateway && terraform output -raw gateway_id)
MEMORY_ID=$(cd infra/terraform/memory && terraform output -raw memory_id)
JWT_ISSUER=$(cd infra/terraform/cognito && terraform output -raw cognito_authority)
JWT_AUDIENCE=$(cd infra/terraform/cognito && terraform output -raw user_pool_client_id)
cd infra/terraform/runtime
terraform init
terraform apply \
-var="container_image_uri=ACCOUNT.dkr.ecr.eu-west-1.amazonaws.com/agentvault_agent:latest" \
-var="gateway_id=$GATEWAY_ID" \
-var="memory_id=$MEMORY_ID" \
-var="jwt_issuer=$JWT_ISSUER" \
-var="jwt_audience=$JWT_AUDIENCE"地形部署
网关
基本网关(无MCP服务器):
cd infra/terraform/gateway
terraform init
terraform apply网关+带API密钥的MCP服务器:
# Store API key in Secrets Manager
aws secretsmanager create-secret \
--name mcp-api-key \
--secret-string "your-api-key"
# Deploy
terraform apply \
-var="add_mcp_target=true" \
-var="mcp_server_endpoint=https://your-mcp-server.com" \
-var="mcp_auth_type=API_KEY" \
-var='mcp_api_key_config={secret_arn="arn:aws:secretsmanager:REGION:ACCOUNT:secret:mcp-api-key"}'带有OAuth的网关+MCP服务器:
terraform apply \
-var="add_mcp_target=true" \
-var="mcp_server_endpoint=https://your-mcp-server.com" \
-var="mcp_auth_type=OAUTH" \
-var='mcp_oauth_config={provider_vendor="GoogleOauth2",client_id="your-id",client_secret="your-secret",scopes=["read","write"]}'带IAM的网关+MCP服务器:
terraform apply \
-var="add_mcp_target=true" \
-var="mcp_server_endpoint=https://your-mcp-server.com" \
-var="mcp_auth_type=IAM"运行时
部署(生产):
cd infra/terraform/runtime
terraform init
GATEWAY_ID=$(cd ../gateway && terraform output -raw gateway_id)
MEMORY_ID=$(cd ../memory && terraform output -raw memory_id)
JWT_ISSUER=$(cd ../cognito && terraform output -raw cognito_authority)
JWT_AUDIENCE=$(cd ../cognito && terraform output -raw user_pool_client_id)
terraform apply \
-var="container_image_uri=123456789012.dkr.ecr.eu-west-1.amazonaws.com/agentvault_agent:latest" \
-var="gateway_id=$GATEWAY_ID" \
-var="memory_id=$MEMORY_ID" \
-var="jwt_issuer=$JWT_ISSUER" \
-var="jwt_audience=$JWT_AUDIENCE"认知
部署:
cd infra/terraform/cognito
terraform init
terraform apply获取前端/运行时连接的输出:
cd infra/terraform/cognito
terraform output user_pool_id
terraform output user_pool_client_id
terraform output cognito_authority
terraform output user_pool_domain记忆
基本内存(仅STM):
cd infra/terraform/memory
terraform init
terraform apply -var="memory_name=my_agent_memory"使用语义策略:
terraform apply \
-var="memory_name=my_agent_memory" \
-var='strategies=[{name="semantic-strategy",type="SEMANTIC",namespaces=["default"]}]'使用所有内置策略:
terraform apply \
-var="memory_name=my_agent_memory" \
-var='strategies=[{name="semantic",type="SEMANTIC",namespaces=["default"]},{name="summary",type="SUMMARIZATION",namespaces=["{sessionId}"]},{name="user-pref",type="USER_PREFERENCE",namespaces=["preferences"]}]'使用自定义策略:
terraform apply \
-var="memory_name=my_agent_memory" \
-var='strategies=[{name="custom-semantic",type="CUSTOM",namespaces=["{sessionId}"],configuration={type="SEMANTIC_OVERRIDE",consolidation={append_to_prompt="Focus on key relationships",model_id="anthropic.claude-3-sonnet-20240229-v1:0"}}}]'ECR
创建存储库:
cd infra/terraform/ecr
terraform init
terraform apply -var="repository_name=agentvault_agent"获取网关URL
cd infra/terraform/gateway
terraform output gateway_url调用运行时
部署运行时后,使用以下命令进行测试:
# Get runtime ARN
cd infra/terraform/runtime
RUNTIME_ARN=$(terraform output -raw runtime_arn)
# Invoke with a prompt
python scripts/invoke.py "What is the weather today?" --runtime-arn $RUNTIME_ARN
# Continue conversation with session ID
python scripts/invoke.py "Tell me more" --runtime-arn $RUNTIME_ARN --session-id user123
# If your runtime is outside eu-west-1, pass --region
python scripts/invoke.py "Hello" --runtime-arn $RUNTIME_ARN --region us-east-1配置前端
复制和编辑前端环境文件:
cp frontend/src/environments/environment.example.ts frontend/src/environments/environment.ts
cp frontend/src/environments/environment.prod.example.ts frontend/src/environments/environment.prod.ts从Terraform输出中填充这些值:
agentcore.runtimeUrl从运行时调用URLcognito.authority从infra/terraform/cognito输出cognito_authoritycognito.clientId从infra/terraform/cognito输出user_pool_client_idcognito.userPoolDomain从infra/terraform/cognito输出user_pool_domain
在本地运行前端:
cd frontend
npm install
npm start文档
- docs/AUTHENTICATION.md -MCP服务器的身份验证选项
- docs/ATLASSIAN_MCP_INTEGRAT_BACKEND.md -后端Atlassian MCP集成
- docs/ATLASSIAN_MCP_INTEGRAION_FRONTEND.md -前端Atlassian OAuth集成
- docs/JWT_TOKEN_GUIDE.md -为CUSTOM_JWT授权人获取JWT令牌
- docs/CLOUDWATCH_LOGS.md -CloudWatch日志配置和故障排除
- docs/strands-agent-integration.md -与Strands代理商集成
- docs/运行时网关集成.md -将运行时连接到网关
- infra/terraform/README.md -地形部署指南
需求
- AWS CLI已配置
- 地形>=1.0
- Python>=3.10
- Node.js>=18
- 创建IAM角色、基岩资源的权限
- 对于运行时:ECR容器映像
/ping和/invocations端口8080上的端点
CI/CD
- 部署工作流:
- 销毁工作流:
- 完整设置指南:
当前工作流行为:
- 已配置部署
workflow_dispatch(手动运行)默认情况下。 - 推触发应用程序被故意禁用
branches: [none]. - 在当前工作流文件中,Terraform
apply台阶只能在push到main,因此手动运行验证/构建,但不应用基础架构,除非您对其进行调整if条件。
