{"id":37109674,"url":"https://github.com/nnsay/devops-tools","last_synced_at":"2026-01-14T13:02:25.759Z","repository":{"id":168481916,"uuid":"619088459","full_name":"nnsay/devops-tools","owner":"nnsay","description":"A set of tools for AWS DevOps","archived":false,"fork":false,"pushed_at":"2023-12-29T03:00:20.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T18:09:39.117Z","etag":null,"topics":["aws","devops","tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nnsay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-26T08:25:46.000Z","updated_at":"2023-07-26T03:24:22.000Z","dependencies_parsed_at":"2023-12-29T04:20:03.032Z","dependency_job_id":"79c1f837-b863-4124-a0b3-4f056c64d5f3","html_url":"https://github.com/nnsay/devops-tools","commit_stats":null,"previous_names":["nnsay/aws-tools","nnsay/devops-tools"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/nnsay/devops-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnsay%2Fdevops-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnsay%2Fdevops-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnsay%2Fdevops-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnsay%2Fdevops-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nnsay","download_url":"https://codeload.github.com/nnsay/devops-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nnsay%2Fdevops-tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","devops","tools"],"created_at":"2026-01-14T13:02:25.126Z","updated_at":"2026-01-14T13:02:25.753Z","avatar_url":"https://github.com/nnsay.png","language":"Go","readme":"# 1. Devops-TOOLS\n\n本项目编写一些日常运维的小工具, 本项目使用`spf13/cobra`为命令行开发开发, 目前支持的工具如下\n\n- AWS 类\n- Monorepo 类\n\n# 2. AWS 类\n\n该类型的工具需要具有 aws 访问权限, 如果需要发送通知, 还需要配置 Slack:\n\n- AWS\n\n  本工具引用了 aws sdk 所以权限上依赖 sdk 自己的设置, 根据文档支持: AWS\\_\\*环境变量和配置文件, 关于这块的配置请查看 AWS 文档: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html\n\n- Slack\n\n  Slack 消息是通过安装自定义 Slack 应用, 然后利用该应用发送消息的途径, 而发消息需要`calls:write`权限, 详情参考 [Using the Calls API](https://api.slack.com/apis/calls); 之所以使用该种方式而不是[Incoming Webhooks](https://api.slack.com/apps/A052AEV2S68/incoming-webhooks)的原因是 webhook 不支持指定 Channel\n\n## 2.1 删除过期的 IAM 证书\n\n作用: 删除已经过期的 IAM 证书\n\n使用方法:\n\n```bash\n# use alias command\ndevops-tools iam dec\n# use fullname command\ndevops-tools iam delete-expired-certification\n```\n\n参数说明:\n\n| 参数名称              | 别名 | 描述                       | 默认值       |\n| --------------------- | ---- | -------------------------- | ------------ |\n| expiration            | e    | 指定过期时间, 格式为时间戳 | time.Now()   |\n| path-prefix           | p    | 证书路径                   | /cloudfront/ |\n| **TIME_OFFSET_HOURS** | 无   | 时区偏移小时数             | 0            |\n\n## 2.2 检查临期 IAM 证书\n\n作用: 检查即将过期的证书并提醒, 提醒消息发送到 Slack(需配置 **SLACK_HOOK**)\n\n使用方法:\n\n```bash\n# use alias command\ndevops-tools iam ccd\n# use fullname command\ndevops-tools iam check-certification-date\n```\n\n参数说明:\n\n| 参数名称              | 别名 | 描述                                               | 默认值       |\n| --------------------- | ---- | -------------------------------------------------- | ------------ |\n| expire-hours          | e    | 剩余过期小时数                                     | 72           |\n| path-prefix           | p    | 证书路径                                           | /cloudfront/ |\n| channel               | c    | Slack Channel                                      | #devops      |\n| **SLACK_TOKEN**       | 无   | 必选, Slack 自定义应用 Auto Token 地址**环境变量** | 无           |\n| **ENV_NAME**          | 无   | 可选, 如果有多个环境可以指定环境名称**环境变量**   | 无           |\n| **TIME_OFFSET_HOURS** | 无   | 时区偏移小时数                                     | 0            |\n\n提醒消息:\n![提醒消息](https://raw.githubusercontent.com/nnsay/gist/main/img20230629183823.png)\n\n## 2.3 检查未变更的 Cloudformation\n\n作用: 检查超过指定天数的未变更的 Cloudformation Stack 并发送提醒消息\n\n使用方法:\n\n```bash\n# use alias command\ndevops-tools cloudformation cec\n# use fullname command\ndevops-tools cloudformation checkExpirationCloudformation\n```\n\n参数说明:\n\n| 参数名称              | 别名 | 描述                                               | 默认值  |\n| --------------------- | ---- | -------------------------------------------------- | ------- |\n| days                  | d    | 多少天未更新                                       | 10      |\n| channel               | c    | Slack Channel                                      | #devops |\n| **SLACK_TOKEN**       | 无   | 必选, Slack 自定义应用 Auto Token 地址**环境变量** | 无      |\n| **ENV_NAME**          | 无   | 可选, 如果有多个环境可以指定环境名称**环境变量**   | 无      |\n| **WHITE_STACK_NAMES** | 无   | 可选, stack 白名单,多个以逗号分隔**环境变量**      | 无      |\n| **TIME_OFFSET_HOURS** | 无   | 时区偏移小时数                                     | 0       |\n\n提醒消息:\n![提醒消息](https://raw.githubusercontent.com/nnsay/gist/main/img20230630104222.png)\n\n# 3. Monorepo 类\n\nMonorepo 基于[Nx](https://nx.dev/)的实践, 不过该类工具设计时与具体哪种 Monorepo 无关, 主要是解决 Monorepo 中的痛点问题.\n\n## 3.1 代码覆盖率报告\n\n依赖前提:\n\n测试覆盖率报告需要是`json-summary`格式, Istanbul 是事实上的代码测试覆盖率标准, 其支持产生的代码覆盖率报告格式有很多种, 常见的如 json, json-summary, text, lcov 等, 详情可以查看[这里](https://istanbul.js.org/docs/advanced/alternative-reporters/)\n\n作用:\n\n- 基于 Monorepo 的多项目的代码覆盖率报告, 覆盖率报告以项目分组\n- 支持检测代码覆盖率阈值检查, 目前检查的是 statement 指标, 如果有低于阈值的覆盖率则会产生.exit 文件\n\n使用方法:\n\n```bash\n# use alias command\ndevops-tools monorepo ccr\n# use fullname command\ndevops-tools monorepo codeCoverageReport\n```\n\n参数说明:\n\n| 参数名称       | 别名 | 描述                                                               | 默认值         |\n| -------------- | ---- | ------------------------------------------------------------------ | -------------- |\n| coverageDir    | d    | 覆盖率报告目录, 一般层级是: 覆盖率报告目录/应用目录/覆盖率报告文件 | {tmp/packages} |\n| limitTarget    | l    | statement 最低覆盖率阈值                                           | -1             |\n| reportPath     | r    | 自定义覆盖率报告产生位置                                           | tmp/report.md  |\n| ignoreProjects | i    | 需要忽略的项目, 多个的话使用逗号分隔                               | \"\"             |\n\n报告展示:\n\n展示结果以默认参数为例, 聚合的自定义覆盖率报告./tmp/report.md 内容如下:\n\n```markdown\n# Coverage report\n\n| App  | Lines      | Statements | Branches   | Functions  |\n| ---- | ---------- | ---------- | ---------- | ---------- |\n| app1 | 🟢 100.00% | 🟢 100.00% | 🟢 100.00% | 🟢 100.00% |\n| app2 | 🟢 90.13%  | 🟢 89.90%  | 🟡 66.06%  | 🟢 90.61%  |\n| app3 | 🟢 100.00% | 🟢 100.00% | 🟢 100.00% | 🟢 100.00% |\n| lib1 | 🟢 89.22%  | 🟢 87.82%  | 🟡 66.66%  | 🟢 93.33%  |\n```\n\n如果指定了覆盖率阈值, 且任意 Monorepo 项目中有低于阈值的项目会被另外统计且产生与自定义覆盖率报告同名但是结尾是`.exit`的文件, ./tmp/report.md.exit 内容如下:\n\n```\napp2 statements coverage 90.36 is lower than the limition target 100 !\ncivil-toolkit statements coverage 87.82 is lower than the limition target 100 !\nlib1 statements coverage 84.44 is lower than the limition target 100 !\n```\n\n扩展使用:\n\n该工具可以结合 gh 一起使用, 可以在流水线中显示覆盖率报告或者让低覆盖流水任务失败, 这部分技巧可以参考: [3. 配合 Github Workflow 使用](https://nnsay.cn/2023/07/17/code-coverage/#3-%E9%85%8D%E5%90%88-Github-Workflow-%E4%BD%BF%E7%94%A8)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnsay%2Fdevops-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnnsay%2Fdevops-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnnsay%2Fdevops-tools/lists"}