cloud-nuke
$ cloud-nuke 社区开源 高风险Gruntwork 出品的 cloud-nuke 用于扫描并清理 AWS、GCP 与 Azure 账号中的孤儿资源,非常适合回收临时测试沙箱环境。支持 --dry-run、--output-format json、--older-than、--region 与 --resource-type 精确筛选。
brew install cloud-nuke 全账号级破坏性清理必须在本地经 --dry-run 核验并受 --force 门控保护,不应直接作为删除型 MCP 工具暴露给模型。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
支持 --dry-run、--output-format json、--older-than 与 --force,在只读预演清点场景下非常可靠。
- Supports
--dry-runand--output-format json - Interactive confirmation prompt blocks unless
--forceis passed
默认要求交互确认(或显式 --force)并提供 --dry-run 与 --config 排除规则,但核心功能是不可逆的批量删资源操作。
--dry-runand--configexclude filters mitigate risk- High blast radius:
--forcedeletes matched resources across regions
静态 Go 单二进制,支持 Homebrew 与 macOS/Linux/Windows 官方发布包。
- Available via
brew install cloud-nuke
跨区域盘点并回收测试沙箱残留资源的效率极高。
- Parallel multi-region resource discovery and deletion
由 Gruntwork(gruntwork-io/cloud-nuke)基于 Apache-2.0 维护。
- Gruntwork open-source repository under Apache-2.0
仓库 README 与 cloud-nuke aws --help 详述了 --config、--dry-run 过滤规则与资源支持清单。
- Repository README and
cloud-nuke aws --help
安全边界、鉴权与放权指南
复用标准 AWS(~/.aws/credentials、AWS_*)、GCP(GOOGLE_APPLICATION_CREDENTIALS)或 Azure(AZURE_*)环境变量凭证。
Apache-2.0 开源 CLI 免费;合理清理可节省闲置云账单,但误操作将造成不可逆数据丢失。
# cloud-nuke Agent Rules - ALWAYS run with `--dry-run --output-format json` first and show the full target list to the user. - NEVER pass `--force` or run `cloud-nuke` without `--region` and `--resource-type` filters unless explicitly instructed for an ephemeral sandbox account.
Agent 高频安全命令配方
只读查询(安全推荐)
--dry-run JSON 审计超过 24 小时的 AWS 资源 cloud-nuke aws --dry-run --older-than 24h --region us-east-1 --output-format json
仅扫描并以 JSON 输出待清理目标列表,不执行任何删除。
--dry-run 按资源类型定向扫描 cloud-nuke aws --dry-run --resource-type ec2 --resource-type ebs --region us-east-1
将扫描范围严格限定在单一区域的 EC2 实例与 EBS 卷。
受控写入与预演
--force 按过滤条件清理沙箱 EC2 实例 cloud-nuke aws --resource-type ec2 --older-than 72h --region us-east-1 --force
仅在 --dry-run 核对无误且获得用户明确批准后使用 --force 执行清理。
核心优势
- +
--dry-run --output-format json是安全高效的跨区域资源盘点利器。 - + 缺少交互确认或
--force时默认拒绝删除。 - + 提供细粒度的
--resource-type、--region、--older-than与--config排除机制。
注意事项与踩坑点
- ! 在非沙箱生产账号误传
--force会造成严重破坏。 - ! GCP 与 Azure 支持的资源类型覆盖度不如 AWS 全面。