这是一个使用Strands SDK构建的复杂多代理系统,利用AWS知识图谱MCP(模型上下文协议)加速跨多个区域的AWS基础设施扩展。
本项目展示了如何利用AI代理和AWS知识图谱智能地规划和执行多区域基础设施部署。该系统分析现有的AWS资源,识别区域服务可用性差距,并生成全面的扩展策略。
该系统由几个专门的代理组成:
git clone <repository-url>
cd multi-region-expansion-planner
python -m venv .venv
source .venv/bin/activate # 在Windows上:.venv\Scripts\activate
pip install -r requirements.txt
创建具有以下权限的IAM用户
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CloudFormationAnalysis",
"Effect": "Allow",
"Action": [
"cloudformation:ListStacks",
"cloudformation:DescribeStacks",
"cloudformation:ListStackResources",
"cloudformation:DescribeStackResources"
],
"Resource": "*"
},
{
"Sid": "CloudTrailAnalysis",
"Effect": "Allow",
"Action": [
"cloudtrail:LookupEvents"
],
"Resource": "*"
},
{
"Sid": "BedrockAccess",
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": [
"arn:aws:bedrock:*:*:inference-profile/us.anthropic.claude-sonnet-4-20250514-v1:0"
]
}
]
}
aws configure --profile region-planner-user
当提示时,输入:
测试配置文件
# 验证凭据是否工作
aws sts get-caller-identity --profile region-planner-user
src/utils/config.py中配置Bedrock模型提供商账户AWS配置文件以进行身份验证:class Constants:
# 替换为您实际的账户ID以使用Bedrock模型
INFRA_ACCOUNT = "123456789012"
# 用于认证的AWS CLI配置文件
BEDROCK_AWS_CLI_PROFILE = "bedrock-profile"
class ExpansionPlaningInputs:
PROFILE_NAME = 'your-aws-profile'
SOURCE_REGION = 'us-east-1'
TARGET_REGIONS = ['eu-central-1', 'ap-southeast-1', 'ca-central-1']
在运行新的分析之前,可以清理之前的分析结果:
./cleanup.sh
运行完整的扩展规划工作流:
python src/main.py
这将:
您也可以单独运行特定分析的代理:
# 仅运行CFN分析
python src/agents/cfn_explorer.py
# 运行区域差距分析
python src/agents/waypoint_explorer.py
# 生成扩展计划
python src/agents/multi_region_expansion_planner.py
系统将在src/analysis_results/目录下生成多个输出文件:
cfn_explorer_result.json:CloudFormation资源分析cloudtrail_explorer_result.json:服务使用模式waypoint_explorer_<region>_result.json:区域可用性分析expansion_planning_report.md:最终扩展规划报告multi_region_expansion_planning_report.md:详细的技术分析本项目展示了AWS知识图谱MCP服务器的强大功能,包括:
├── src/
│ ├── agents/ # 专门的AI代理
│ │ ├── cfn_explorer.py
│ │ ├── cloudtrail_explorer.py
│ │ ├── waypoint_explorer.py
│ │ ├── multi_region_expansion_planner.py
│ │ └── ...
│ ├── analysis_results/ # 生成的分析输出
│ ├── utils/ # 配置和工具
│ │ ├── config.py
│ │ ├── planner_inputs.py
│ │ └── prompts.py
│ └── main.py # 主协调脚本
├── tests/ # 测试文件
├── requirements.txt # Python依赖项
└── README.md # 本文件
本项目根据MIT许可发布 - 查看LICENSE文件以获取详情。
对于问题或问题: