Infra Wrapper
Infra Wrapper v2.0.0 — a utility toolkit for running, checking, converting, analyzing, generating, previewing, batching, comparing, exporting, configuring, monitoring status, and reporting on infrastructure wrapper operations. All entries are timestamped and logged locally for history tracking.
Commands
Core Commands
- -
run <input> — Record and log a run entry. Without arguments, shows the 20 most recent run entries. - INLINECODE1 — Record and log a check entry. Without arguments, shows recent check entries.
- INLINECODE2 — Record and log a convert entry. Without arguments, shows recent convert entries.
- INLINECODE3 — Record and log an analyze entry. Without arguments, shows recent analyze entries.
- INLINECODE4 — Record and log a generate entry. Without arguments, shows recent generate entries.
- INLINECODE5 — Record and log a preview entry. Without arguments, shows recent preview entries.
- INLINECODE6 — Record and log a batch entry. Without arguments, shows recent batch entries.
- INLINECODE7 — Record and log a compare entry. Without arguments, shows recent compare entries.
- INLINECODE8 — Record and log an export entry. Without arguments, shows recent export entries.
- INLINECODE9 — Record and log a config entry. Without arguments, shows recent config entries.
- INLINECODE10 — Record and log a status entry. Without arguments, shows recent status entries.
- INLINECODE11 — Record and log a report entry. Without arguments, shows recent report entries.
Utility Commands
- -
stats — Show summary statistics across all log files (entry counts per type, total entries, disk usage). - INLINECODE13 — Export all logged data to a file. Supported formats:
json, csv, txt. (Note: also doubles as a core command when given non-format arguments.) - INLINECODE17 — Search all log files for a case-insensitive term match.
- INLINECODE18 — Show the 20 most recent entries from the activity history log.
- INLINECODE19 — Health check showing version, data directory, total entries, disk usage, and last activity. (Note: also doubles as a core command when given arguments.)
- INLINECODE20 — Display the full help message with all available commands.
- INLINECODE21 — Print the current version (v2.0.0).
Data Storage
All data is stored in ~/.local/share/infra-wrapper/:
- - Each core command writes timestamped entries to its own log file (e.g.,
run.log, check.log, batch.log). - A unified
history.log tracks all operations across commands. - Export files are written to the same directory as
export.json, export.csv, or export.txt.
Requirements
- - Bash (with
set -euo pipefail) - Standard Unix utilities:
date, wc, du, tail, grep, sed, cat, INLINECODE38
When to Use
- - When you need to log and track infrastructure wrapper operations (runs, checks, conversions, batch jobs, etc.)
- For maintaining an audit trail of Terragrunt/OpenTofu/Terraform orchestration activities
- To analyze and compare infrastructure configurations with timestamped records
- To export accumulated infra wrapper data in JSON, CSV, or plain text for downstream processing
- As part of a larger IaC automation pipeline that needs timestamped operation records
- When you need to search across historical infrastructure orchestration entries
- For batch processing multiple infrastructure operations and tracking their status
Examples
CODEBLOCK0
Output
All commands output results to stdout. Redirect to a file if needed:
CODEBLOCK1
Powered by BytesAgain | bytesagain.com | hello@bytesagain.com
基础设施包装器
Infra Wrapper v2.0.0 — 一个用于运行、检查、转换、分析、生成、预览、批处理、比较、导出、配置、监控状态以及报告基础设施包装器操作的实用工具包。所有条目均带有时间戳并本地记录日志,以便进行历史追踪。
命令
核心命令
- - run <输入> — 记录并记录运行条目。无参数时,显示最近20条运行条目。
- check <输入> — 记录并记录检查条目。无参数时,显示最近的检查条目。
- convert <输入> — 记录并记录转换条目。无参数时,显示最近的转换条目。
- analyze <输入> — 记录并记录分析条目。无参数时,显示最近的分析条目。
- generate <输入> — 记录并记录生成条目。无参数时,显示最近的生成条目。
- preview <输入> — 记录并记录预览条目。无参数时,显示最近的预览条目。
- batch <输入> — 记录并记录批处理条目。无参数时,显示最近的批处理条目。
- compare <输入> — 记录并记录比较条目。无参数时,显示最近的比较条目。
- export <输入> — 记录并记录导出条目。无参数时,显示最近的导出条目。
- config <输入> — 记录并记录配置条目。无参数时,显示最近的配置条目。
- status <输入> — 记录并记录状态条目。无参数时,显示最近的状态条目。
- report <输入> — 记录并记录报告条目。无参数时,显示最近的报告条目。
实用命令
- - stats — 显示所有日志文件的汇总统计信息(每种类型的条目数、总条目数、磁盘使用量)。
- export <格式> — 将所有记录的数据导出到文件。支持的格式:json、csv、txt。(注意:当给定非格式参数时,也兼作核心命令。)
- search <搜索词> — 在所有日志文件中搜索不区分大小写的匹配项。
- recent — 显示活动历史日志中最近的20条条目。
- status — 健康检查,显示版本、数据目录、总条目数、磁盘使用量和最近活动。(注意:当给定参数时,也兼作核心命令。)
- help — 显示包含所有可用命令的完整帮助信息。
- version — 打印当前版本(v2.0.0)。
数据存储
所有数据存储在 ~/.local/share/infra-wrapper/ 中:
- - 每个核心命令将其带时间戳的条目写入自己的日志文件(例如 run.log、check.log、batch.log)。
- 统一的 history.log 追踪所有命令的操作。
- 导出文件写入同一目录,文件名为 export.json、export.csv 或 export.txt。
要求
- - Bash(使用 set -euo pipefail)
- 标准Unix工具:date、wc、du、tail、grep、sed、cat、basename
使用场景
- - 当您需要记录和追踪基础设施包装器操作(运行、检查、转换、批处理作业等)时
- 用于维护Terragrunt/OpenTofu/Terraform编排活动的审计追踪
- 使用带时间戳的记录分析和比较基础设施配置
- 将累积的基础设施包装器数据导出为JSON、CSV或纯文本,以供下游处理
- 作为需要带时间戳操作记录的更大规模IaC自动化流水线的一部分
- 当您需要跨历史基础设施编排条目进行搜索时
- 用于批处理多个基础设施操作并追踪其状态
示例
bash
运行操作
infra-wrapper run terragrunt apply --all
检查配置
infra-wrapper check staging环境中的模块依赖关系
转换基础设施格式
infra-wrapper convert 用于CI管道的HCL转JSON
分析基础设施
infra-wrapper analyze 扩缩变更的成本影响
生成配置
infra-wrapper generate 新服务的模块样板
预览变更后再应用
infra-wrapper preview 生产环境的计划输出
批处理操作
infra-wrapper batch 应用us-east-1中的所有模块
比较环境
infra-wrapper compare staging与生产配置对比
更新配置
infra-wrapper config 设置后端为s3://terraform-state
查看最近活动
infra-wrapper recent
跨所有日志搜索
infra-wrapper search production
导出所有内容为CSV
infra-wrapper export csv
显示统计信息
infra-wrapper stats
健康检查
infra-wrapper status
输出
所有命令将结果输出到stdout。如有需要,可重定向到文件:
bash
infra-wrapper stats > report.txt
infra-wrapper export json
由BytesAgain提供支持 | bytesagain.com | hello@bytesagain.com