Restore Tencent Cloud API 3.0 with correct TC3-HMAC-SHA256 signing
Major Changes: - ✅ Restored: TENCENT_SECRET_ID/TENCENT_SECRET_KEY authentication - ✅ Fixed: TC3-HMAC-SHA256 signature implementation - ✅ Fixed: SERVICE='dnspod' in credential scope (not API_VERSION) - ✅ Fixed: API parameter naming (SubDomain not Subdomain) - ✅ Fixed: Error handling for empty record lists Files Updated: - scripts/deploy_record.py - Complete rewrite with correct signing - .env.example - Updated to Tencent Cloud credentials format - SKILL.md - Updated documentation for API 3.0 New Documentation: - MIGRATION.md - Migration guide - UPDATE-SUMMARY-V3.md - Version 3.0 update summary - TEST-REPORT.md - Test results and verification Testing Results: ✅ API connection successful ✅ Domain query working ✅ Record creation successful (tested: test.eoxnet.com A 1.2.3.4) ✅ Record verification working ✅ Error handling complete API Details: - Endpoint: dnspod.tencentcloudapi.com - Version: 2021-03-23 - Signature: TC3-HMAC-SHA256 - Service: dnspod Version: 3.0 (Tencent Cloud API 3.0)
This commit is contained in:
319
SKILL.md
319
SKILL.md
@@ -1,34 +1,41 @@
|
||||
---
|
||||
name: tencent-dnspod
|
||||
description: |
|
||||
腾讯云DNSPod域名快速部署工具。用于自动化部署DNS记录、批量配置域名解析、快速上线服务。
|
||||
当用户需要: (1) 快速添加DNS记录部署新服务, (2) 批量配置A/CNAME/MX等记录,
|
||||
(3) 域名解析自动化管理, (4) DevOps域名部署流程时触发。
|
||||
腾讯云 DNSPod 域名快速部署工具 (API 3.0)。用于自动化部署 DNS 记录、批量配置域名解析、快速上线服务。
|
||||
当用户需要:(1) 快速添加 DNS 记录部署新服务,(2) 批量配置 A/CNAME/MX 等记录,
|
||||
(3) 域名解析自动化管理,(4) DevOps 域名部署流程时触发。
|
||||
---
|
||||
|
||||
# 腾讯云DNSPod域名快速部署
|
||||
# 腾讯云 DNSPod 域名快速部署
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 1. 配置认证
|
||||
|
||||
获取API密钥: https://console.cloud.tencent.com/cam/capi
|
||||
获取 API 密钥:https://console.cloud.tencent.com/cam/capi
|
||||
|
||||
**方式1: 使用 .env 文件(推荐,更安全):**
|
||||
**方式 1: 使用 .env 文件 (推荐,更安全):**
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# 编辑 .env 文件,填入你的密钥
|
||||
# 编辑 .env 文件,填入你的密钥
|
||||
```
|
||||
|
||||
**方式2: 设置环境变量:**
|
||||
**方式 2: 设置环境变量:**
|
||||
```bash
|
||||
export TENCENT_SECRET_ID="你的SecretId"
|
||||
export TENCENT_SECRET_KEY="你的SecretKey"
|
||||
export TENCENT_SECRET_ID="AKIDxxxxxxxxxxxxxxxx"
|
||||
export TENCENT_SECRET_KEY="xxxxxxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
**获取密钥步骤:**
|
||||
1. 访问:https://console.cloud.tencent.com/cam/capi
|
||||
2. 登录腾讯云控制台
|
||||
3. 进入 **访问管理** → **访问密钥** → **API 密钥管理**
|
||||
4. 点击 **新建密钥** 或查看现有密钥
|
||||
5. 复制 SecretId 和 SecretKey
|
||||
|
||||
### 2. 核心命令
|
||||
|
||||
**添加单条记录(最常用):**
|
||||
**添加单条记录 (最常用):**
|
||||
```bash
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
@@ -38,14 +45,14 @@ python scripts/deploy_record.py \
|
||||
--line "默认"
|
||||
```
|
||||
|
||||
**批量部署(从配置文件):**
|
||||
**批量部署 (从配置文件):**
|
||||
```bash
|
||||
python scripts/batch_deploy.py \
|
||||
--domain example.com \
|
||||
--config dns-config.json
|
||||
```
|
||||
|
||||
**快速配置服务(常用组合):**
|
||||
**快速配置服务 (常用组合):**
|
||||
```bash
|
||||
python scripts/deploy_service.py \
|
||||
--domain example.com \
|
||||
@@ -62,198 +69,184 @@ python scripts/delete_record.py \
|
||||
|
||||
## 域名快速部署流程
|
||||
|
||||
### 场景1: 部署新Web服务
|
||||
### 场景 1: 部署新 Web 服务
|
||||
```bash
|
||||
# 一键部署www和主域名
|
||||
# 一键部署 www 和主域名
|
||||
python scripts/deploy_service.py \
|
||||
--domain example.com \
|
||||
--service web \
|
||||
--ip 1.2.3.4
|
||||
|
||||
# 自动创建:
|
||||
# - example.com (A记录)
|
||||
# - www.example.com (A记录)
|
||||
# - *.example.com (泛域名A记录,可选)
|
||||
# - example.com (A 记录)
|
||||
# - www.example.com (A 记录)
|
||||
# - *.example.com (泛域名 A 记录,可选)
|
||||
```
|
||||
|
||||
### 场景2: 部署API服务
|
||||
### 场景 2: 部署 API 服务
|
||||
```bash
|
||||
# 部署api子域名
|
||||
# 部署 API 子域名
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--subdomain api \
|
||||
--type A \
|
||||
--value 1.2.3.4
|
||||
```
|
||||
|
||||
### 场景3: 配置邮件服务
|
||||
```bash
|
||||
# 一键配置MX记录
|
||||
python scripts/deploy_mx.py \
|
||||
# 或者使用服务模板
|
||||
python scripts/deploy_service.py \
|
||||
--domain example.com \
|
||||
--mx-server mx.example.com \
|
||||
--priority 10
|
||||
--service api \
|
||||
--ip 1.2.3.4
|
||||
```
|
||||
|
||||
### 场景4: CDN加速配置
|
||||
### 场景 3: 域名验证 (TXT 记录)
|
||||
```bash
|
||||
# 添加CNAME指向CDN
|
||||
# SSL 证书验证
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--subdomain cdn \
|
||||
--type CNAME \
|
||||
--value cdn.example.com.cdn.dnsv1.com
|
||||
--subdomain _dnsauth \
|
||||
--type TXT \
|
||||
--value "验证字符串"
|
||||
```
|
||||
|
||||
### 场景5: 批量部署多个环境
|
||||
### 场景 4: 邮件服务 (MX 记录)
|
||||
```bash
|
||||
# 从配置文件批量创建
|
||||
python scripts/batch_deploy.py \
|
||||
# 添加 MX 记录
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--config deployments/dev.json
|
||||
|
||||
# 配置文件示例见下文
|
||||
--subdomain @ \
|
||||
--type MX \
|
||||
--value "mxbiz1.qq.com" \
|
||||
--line "默认"
|
||||
```
|
||||
|
||||
## 记录类型说明
|
||||
## 支持的记录类型
|
||||
|
||||
| 类型 | 用途 | 示例 |
|
||||
|------|------|------|
|
||||
| A | 指向IPv4地址 | www → 1.2.3.4 |
|
||||
| CNAME | 指向域名别名 | www → cdn.example.com |
|
||||
| MX | 邮件服务器 | @ → mx.example.com |
|
||||
| TXT | 文本记录(验证/SPF) | @ → "v=spf1 include:_spf.example.com ~all" |
|
||||
| AAAA | 指向IPv6地址 | www → 2001:db8::1 |
|
||||
- **A**: IPv4 地址记录
|
||||
- **AAAA**: IPv6 地址记录
|
||||
- **CNAME**: 别名记录
|
||||
- **MX**: 邮件交换记录
|
||||
- **TXT**: 文本记录 (常用于验证)
|
||||
- **NS**: 域名服务器记录
|
||||
- **SRV**: 服务定位记录
|
||||
- **CAA**: 证书颁发机构授权
|
||||
|
||||
## 批量部署配置文件格式
|
||||
## 高级用法
|
||||
|
||||
`dns-config.json`:
|
||||
```json
|
||||
{
|
||||
"records": [
|
||||
{
|
||||
"subdomain": "@",
|
||||
"type": "A",
|
||||
"value": "1.2.3.4",
|
||||
"line": "默认"
|
||||
},
|
||||
{
|
||||
"subdomain": "www",
|
||||
"type": "A",
|
||||
"value": "1.2.3.4",
|
||||
"line": "默认"
|
||||
},
|
||||
{
|
||||
"subdomain": "api",
|
||||
"type": "A",
|
||||
"value": "1.2.3.5",
|
||||
"line": "电信"
|
||||
},
|
||||
{
|
||||
"subdomain": "cdn",
|
||||
"type": "CNAME",
|
||||
"value": "cdn.example.com.cdn.dnsv1.com",
|
||||
"line": "默认"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
使用批量配置:
|
||||
### 强制更新现有记录
|
||||
```bash
|
||||
python scripts/batch_deploy.py \
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--config dns-config.json
|
||||
--subdomain www \
|
||||
--type A \
|
||||
--value 1.2.3.5 \
|
||||
--force # 不询问直接更新
|
||||
```
|
||||
|
||||
## 线路类型说明
|
||||
|
||||
常用线路值:
|
||||
- `默认` - 默认线路
|
||||
- `电信` - 电信用户
|
||||
- `联通` - 联通用户
|
||||
- `移动` - 移动用户
|
||||
- `境外` - 海外用户
|
||||
- `搜索引擎` - 爬虫线路
|
||||
|
||||
查看完整线路列表:
|
||||
### 域名不存在时自动创建
|
||||
```bash
|
||||
python scripts/list_lines.py --domain example.com
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--subdomain www \
|
||||
--type A \
|
||||
--value 1.2.3.4 \
|
||||
--create-domain # 自动创建域名
|
||||
```
|
||||
|
||||
### 自定义 TTL
|
||||
```bash
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--subdomain www \
|
||||
--type A \
|
||||
--value 1.2.3.4 \
|
||||
--ttl 300 # 5 分钟
|
||||
```
|
||||
|
||||
### 添加记录备注
|
||||
```bash
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--subdomain www \
|
||||
--type A \
|
||||
--value 1.2.3.4 \
|
||||
--remark "生产环境 Web 服务器"
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
|
||||
### .env 文件配置
|
||||
|
||||
```bash
|
||||
# 腾讯云 DNSPod API 密钥配置
|
||||
|
||||
# SecretId (以 AKID 开头)
|
||||
TENCENT_SECRET_ID=AKIDxxxxxxxxxxxxxxxx
|
||||
|
||||
# SecretKey (32 位字符串)
|
||||
TENCENT_SECRET_KEY=xxxxxxxxxxxxxxxx
|
||||
```
|
||||
|
||||
### 环境变量
|
||||
|
||||
```bash
|
||||
export TENCENT_SECRET_ID="AKIDxxxxxxxxxxxxxxxx"
|
||||
export TENCENT_SECRET_KEY="xxxxxxxxxxxxxxxx"
|
||||
```
|
||||
|
||||
## API 说明
|
||||
|
||||
本技能使用 **腾讯云 API 3.0**:
|
||||
- API 端点:`dnspod.tencentcloudapi.com`
|
||||
- API 版本:`2021-03-23`
|
||||
- 认证方式:TC3-HMAC-SHA256 签名
|
||||
- 文档:https://cloud.tencent.com/document/product/1427
|
||||
|
||||
**优势:**
|
||||
- ✅ CAM 权限管理,支持子账号
|
||||
- ✅ 与腾讯云产品深度集成
|
||||
- ✅ 全面的错误码和 SDK 支持
|
||||
- ✅ 性能优化,全球部署
|
||||
|
||||
**签名方法:**
|
||||
- 算法:TC3-HMAC-SHA256
|
||||
- 文档:https://cloud.tencent.com/document/product/1427/56189
|
||||
|
||||
## 安全提示
|
||||
|
||||
⚠️ **API 密钥等同于密码,请妥善保管!**
|
||||
|
||||
- 不要将密钥提交到 Git 仓库
|
||||
- 不要将密钥分享给他人
|
||||
- 定期更换密钥
|
||||
- 如已泄露,立即禁用并重新创建
|
||||
|
||||
## 常见问题
|
||||
|
||||
### 1. 记录冲突
|
||||
如果记录已存在,脚本会提示是否更新。使用 `--force` 强制更新。
|
||||
### Q: 密钥格式错误?
|
||||
A: SecretId 应该以 `AKID` 开头,约 20 位;SecretKey 是 32 位字符串
|
||||
|
||||
### 2. 批量操作失败
|
||||
批量操作会继续执行后续记录,最后汇总结果。检查输出中的 `[FAIL]` 标记。
|
||||
### Q: 提示"域名不存在"?
|
||||
A: 使用 `--create-domain` 参数自动创建域名,或先在控制台添加域名
|
||||
|
||||
### 3. API频率限制
|
||||
默认限制: 20次/秒。大批量部署时会自动限速。
|
||||
|
||||
### 4. 域名未添加
|
||||
如果域名未添加到DNSPod,使用 `--create-domain` 自动创建:
|
||||
### Q: 如何查看现有记录?
|
||||
A: 使用 `list_records.py` 脚本:
|
||||
```bash
|
||||
python scripts/deploy_record.py \
|
||||
--domain example.com \
|
||||
--create-domain \
|
||||
--subdomain www \
|
||||
--type A \
|
||||
--value 1.2.3.4
|
||||
```
|
||||
|
||||
## API错误处理
|
||||
|
||||
详细错误说明见 [common-errors.md](references/common-errors.md)
|
||||
|
||||
## 高级功能
|
||||
|
||||
### 创建快照(部署前备份)
|
||||
```bash
|
||||
python/scripts/snapshot.py \
|
||||
--domain example.com \
|
||||
--action create \
|
||||
--name "部署前备份"
|
||||
```
|
||||
|
||||
### 回滚快照
|
||||
```bash
|
||||
python scripts/snapshot.py \
|
||||
--domain example.com \
|
||||
--action rollback \
|
||||
--snapshot-id <snapshot-id>
|
||||
```
|
||||
|
||||
### 查看部署历史
|
||||
```bash
|
||||
python scripts/list_records.py \
|
||||
--domain example.com \
|
||||
--show-changes
|
||||
```
|
||||
|
||||
## 最佳实践
|
||||
|
||||
1. **部署前备份** - 重大部署前先创建快照
|
||||
2. **分环境管理** - 使用不同子域名(dev/stage/prod)
|
||||
3. **TTL设置** - 生产环境600s,测试环境60s
|
||||
4. **批量测试** - 先在测试域名验证配置,再批量部署
|
||||
5. **记录备注** - 添加 `--remark` 标记记录用途
|
||||
|
||||
## 示例: 完整部署流程
|
||||
|
||||
```bash
|
||||
# 1. 部署前备份
|
||||
python scripts/snapshot.py --domain example.com --action create --name "部署前"
|
||||
|
||||
# 2. 批量部署
|
||||
python scripts/batch_deploy.py \
|
||||
--domain example.com \
|
||||
--config dns-config.json
|
||||
|
||||
# 3. 验证部署
|
||||
python scripts/list_records.py --domain example.com
|
||||
|
||||
# 4. 测试解析
|
||||
dig www.example.com
|
||||
```
|
||||
|
||||
### Q: 支持哪些记录类型?
|
||||
A: 支持 A、AAAA、CNAME、MX、TXT、NS、SRV、CAA 等常见类型
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [腾讯云 API 3.0 文档](https://cloud.tencent.com/document/product/1427)
|
||||
- [签名方法 v3](https://cloud.tencent.com/document/product/1427/56189)
|
||||
- [API 密钥管理](https://console.cloud.tencent.com/cam/capi)
|
||||
- [API Explorer](https://console.cloud.tencent.com/api/explorer)
|
||||
|
||||
---
|
||||
|
||||
**版本**: 3.0 (使用腾讯云 API 3.0)
|
||||
**更新**: 2026-03-01
|
||||
**API**: 腾讯云 API 3.0 (TC3-HMAC-SHA256)
|
||||
|
||||
Reference in New Issue
Block a user