Metadata-Version: 2.5
Name: tfbrief
Version: 0.1.4
Summary: Human-readable Terraform plan output for CI — format terraform show -json into summaries, tables, and diffs
Project-URL: Homepage, https://github.com/infroware/tfbrief
Project-URL: Repository, https://github.com/infroware/tfbrief
Project-URL: Issues, https://github.com/infroware/tfbrief/issues
Project-URL: PyPI, https://pypi.org/project/tfbrief/
Author: infroware
License-Expression: MIT
License-File: LICENSE
Keywords: ci-cd,devops,github-actions,iac,infrastructure-as-code,plan-review,terraform,terraform-plan,terraform-show-json,tfbrief
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# TfBrief

[![PyPI version](https://img.shields.io/pypi/v/tfbrief.svg?logo=pypi&logoColor=white&label=PyPI&cacheSeconds=300)](https://pypi.org/project/tfbrief/)
[![Python](https://img.shields.io/pypi/pyversions/tfbrief.svg?logo=python&logoColor=white&cacheSeconds=300)](https://pypi.org/project/tfbrief/)

**TfBrief** turns [`terraform show -json`](https://developer.hashicorp.com/terraform/cli/commands/show) plan output into **readable CI logs**: a summary panel, per-resource actions, and attribute-level diffs. Use it in **Terraform**, **GitHub Actions**, and other **DevOps / IaC** pipelines when raw JSON is too noisy for reviewers.

- **Terraform plan review** without scrolling megabytes of JSON
- **CI/CD** friendly — stdlib only, `pip install tfbrief`, one pipe on stdout
- Optional **`--has-changes`** boolean for conditional `terraform apply`

**Install from PyPI:** [pypi.org/project/tfbrief](https://pypi.org/project/tfbrief/)

<!-- tfbrief-demo:start -->
<details open>
<summary><strong>Example output</strong> (fixture <a href="fixtures/minimal-plan.json"><code>minimal-plan.json</code></a>)</summary>

<div style="width:100%;overflow-x:auto">
  <img src="docs/demo.svg" alt="TfBrief terminal output: summary, resource actions, and attribute diffs" style="display:block;width:auto;max-width:none;height:auto;background:#000000;border-radius:6px"/>
</div>

</details>
<!-- tfbrief-demo:end -->

## Why TfBrief?

Hashicorp’s JSON plan is complete but awkward in **pull request checks** and **pipeline logs**. TfBrief is a small Python CLI focused on **infrastructure-as-code** workflows: operators see what will **create, update, or delete** before apply, without a JSON viewer or custom jq scripts.

Typical fit: **Terraform** modules in **GitHub Actions**, **GitLab CI**, or any job that already runs `terraform plan -out=tfplan`.

## Install

```bash
pip install tfbrief
```

Requires Python 3.10+. The `tfbrief` command is on your PATH after install.

**Contributors** (editable install from a clone):

```bash
pip install -e .
```

## Usage

After `terraform plan -out=tfplan`, pipe the JSON plan into TfBrief:

```bash
terraform show -json tfplan | tfbrief
```

That prints the summary panel, resource table, and attribute diffs (see example above).

### Optional: `--has-changes` (apply gate)

Same JSON input, different output — **no** formatted report. Stdout is only `true` or `false` so scripts can skip apply when the plan is empty:

```bash
terraform show -json tfplan | tfbrief --has-changes
# true
```

Plans with only `no-op` / `read` actions (and no output changes) print `false`. Resource or output changes print `true`. Invalid JSON prints an error to stderr and exits `1`.

Typical pattern — log for humans, gate for apply:

```bash
terraform plan -out=tfplan
terraform show -json tfplan | tfbrief
if [ "$(terraform show -json tfplan | tfbrief --has-changes)" = "true" ]; then
  terraform apply tfplan
fi
```

You do **not** need `--has-changes` if you only want readable CI logs or apply manually.

### GitHub Actions

```yaml
- uses: actions/setup-python@v5
  with:
    python-version: "3.12"
- run: pip install -q tfbrief && terraform show -json tfplan | tfbrief
```

Add `--has-changes` in a separate step only when a later step should run `terraform apply` conditionally.

## Security

Redaction is **best-effort**. Treat CI logs as sensitive.

## License

MIT — see [LICENSE](LICENSE).