AWS-Panel/README.md
2025-12-10 12:02:17 +08:00

39 lines
1.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# AWS EC2 Panel (FastAPI + Vue 3)
Minimal multi-tenant EC2 管理面板示例,后端使用 FastAPI/SQLAlchemy前端使用 Vue 3 + Vite + TypeScript + Naive UI + Tailwind。
## 数据库初始化
1. 确认 MySQL 8 已安装并创建空库:
```sql
SOURCE db_schema.md;
```
2. 准备 `backend/.env`(复制 `backend/.env.example` 并修改 DB_URL/JWT_SECRET 等)。
## 启动后端
```bash
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -U pip
pip install fastapi uvicorn[standard] sqlalchemy[asyncio] asyncmy pydantic pydantic-settings python-jose passlib[bcrypt] boto3
uvicorn backend.app:app --reload --host 0.0.0.0 --port 8000
```
健康检查:`GET http://localhost:8000/healthz`
元数据接口示例:
- 区域列表:`GET /api/v1/instances/meta/aws/regions`
- VPC/子网/安全组:`GET /api/v1/instances/meta/aws/network?credential_id=1&region=ap-northeast-1`
- KeyPair 列表:`GET /api/v1/instances/meta/aws/keypairs?credential_id=1&region=ap-northeast-1`
## 启动前端
```bash
cd frontend
npm install
npm run dev
```
默认前端开发服务器使用 `/api` 代理到后端(在 `vite.config.ts` 可调整)。
## 目录速览
- `backend/`FastAPI 应用、路由、SQLAlchemy 模型、AWS 封装。
- `frontend/`Vue 3 + Vite + Naive UI 前端。
- `db_schema.md`MySQL 表结构(务必保持字段/表名一致)。