terraform-optimizer
/terraform-optimizer
Audytuje kod Terraform i OpenTofu pod kątem struktury modułów i stanu, blokad, przypinania wersji, IAM i kosztów, z pomiarami przed i po.
- Autor
- RuneStone-Tech ↗
- Repozytorium
- optimize-anything ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 04.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 11
- Skrypty
- 1
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 04.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- 1 skrypt w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: scripts/audit.py
Co robi i kiedy
Audytuje kod Terraform i OpenTofu pod kątem struktury modułów i stanu, blokad, przypinania wersji, IAM i kosztów, z pomiarami przed i po.
Oryginalny opis (EN)
Audit and optimize Terraform/OpenTofu infrastructure code (Terraform 1.17 current, 1.16 supported, 1.15/1.14 EOL) for module and state structure, remote backends and locking, provider/module version pinning, plan/apply safety, drift and imports/moved blocks, secrets and IAM least privilege, network/storage/database security, CI policy/testing, and cost, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching code. Use this whenever the user mentions Terraform, OpenTofu, `.tf`/state/backend, state locking, `terraform plan`, drift
Jak działa
- Workflow
- Principles
Podgląd SKILL.md
--- name: terraform-optimizer description: Audit and optimize Terraform/OpenTofu infrastructure code (Terraform 1.17 current, 1.16 supported, 1.15/1.14 EOL) for module and state structure, remote backends and locking, provider/module version pinning, plan/apply safety, drift and imports/moved blocks, secrets and IAM least privilege, network/storage/database security, CI policy/testing, and cost, with real before/after measurement. Always produces a written findings report and a fix plan for approval before touching code. Use this whenever the user mentions Terraform, OpenTofu, `.tf`/state/backend, state locking, `terraform plan`, drift, modules, providers, `moved`/`import`, tfstate leaks, IaC security, Checkov/tfsec/Trivy, Terragrunt, or "optimize my Terraform" -- even if they never say audit or optimize. --- # Terraform Optimizer Audit a Terraform codebase, report what is unsafe, brittle or expensive and why, agree a plan, then change it. Order: evidence, approval, edits. State and apply changes can destroy infrastructure; nothing is applied before approval. ## Workflow ### 1. Scope (quick) - Map the repo: root modules, environments, backends, workspaces, providers, modules, state files, CI apply path and cloud accounts. Record Terraform/OpenTofu and provider versions. - Run `python <skill-dir>/scripts/audit.py <repo-root>` -- static scan of `.tf`/`.tfvars`/lockfiles/state for EOL versions, unpinned providers/modules, missing backends/locking, hardcoded secrets, public network/storage, IAM wildcards, destructive settings and plan-safety gaps, with file:line evidence. Use `--json` to post-process. - Classify the pain: state/backend, plan/apply safety, drift, module structure, security/compliance, provider/version upgrades, or cost. Ask which hurts if unclear. - Read `references/tooling.md` once: what can be measured here (`terraform validate/plan`, plan JSON, `terraform graph`, cost, policy scans). ### 2. Audit The script finds cheap leads; you find the rest by reading the root module, backend, variables, state and the CI plan/apply path. Load only what applies: | Area | Reference | |------|-----------| | Modules, state/backends, workspaces, drift, moved/import | `references/modules-state.md` | | Plan/apply safety, refresh, targeting, lifecycle, destroy | `references/plan-safety.md` | | Secrets, IAM, network/storage/database security, provider auth | `references/security-secrets.md` | | Plan time/parallelism, provider/resource graph, cost | `references/performance-cost.md` | | `terraform test`, validation, policy/scanning, CI/CD | `references/testing-ci.md` | | Measurement and honest reporting | `references/tooling.md` | **Measure, never guess.** Run `terraform init -backend=false`, `validate`, `fmt -check`, a read-only `plan` in the target workspace/account, and a policy/scan pass. A clean `plan` is not proof of safety; review the diff, state and apply path. Mark each finding **Confirmed** (plan/state/config/policy evidence) or **Suspected** (needs measuring). ### 3. Report Fill `assets/report-template.md`, save it as `TERRAFORM_OPTIMIZATION_REPORT.md` in the repo root, and show the user. Five-line summary, findings table by impact/effort/risk, then per-finding detail (evidence, why it hurts, fix, state/plan impact, rollback). Group near-duplicates. ### 4. Plan -- then stop for approval Use plan mode: `EnterPlanMode` (load with ToolSearch if deferred), write the plan, present with `ExitPlanMode`; if unavailable show it in chat and wait for an explicit "go". Structure: 1. **Quick wins** -- pin versions/providers/modules, add lockfile, remote backend/locking, remove hardcoded secrets, close public ports/ACLs, enable encryption/deletion protection, add lifecycle/prevent_destroy, fix plan-safety scripts. Low risk. 2. **Structural** -- split root modules/environments, introduce modules/composition, move state with `moved`/`import`, adopt workspaces or separate states, add policy/tests/CI gates, centralize providers/tags. Name each state/plan change. 3. **Heavy** -- Terraform/OpenTofu major upgrade, backend migration, provider major, module extraction/refactor, account/region split, Terragrunt/Stacks adoption. Separately approved with state backup and rollback. Each step: files/state touched, expected plan diff, how to verify, how to roll back. ### 5. Fix Only approved items, in small groups. After each: `terraform fmt -check`, `validate`, `plan` in the target workspace, policy/scan, and review the diff. Never run `apply` as part of an audit without explicit approval. If a change alters state addresses, provider auth, IAM, network exposure or data stores, stop and ask; take a state backup first. ### 6. Verify and wrap up Re-run the same checks: plan diff/no-op, policy/scan findings, state lineage/lock, drift, apply time, resource count and cost estimate. State plainly what could not be measured. End with deferred items and one suggested next step. ## Principles - **State is the source of truth.** Remote, encrypted, locked, backed up and access-controlled. - **Plan is a review artifact.** Save/show it; apply the exact approved plan, not a fresh one. - **Pin everything.** Terraform/OpenTofu, providers, modules and lockfiles; upgrades are deliberate. - **Least privilege and no public defaults.** IAM, security groups, buckets, databases. - **Move, don't recreate.** `moved`/`import` before address changes; never hand-edit state. - **Secrets are not variables in git.** Secret manager/CI env, sensitive/ephemeral values, encrypted state. - **Modules need contracts.** Inputs/outputs/versions/README; avoid god modules and remote-state coupling. - **Test and gate.** `terraform test`, validation, policy/scan and a PR plan. - **Measure cost and drift.** A cheap plan can create expensive, drifting infrastructure.
Pliki w paczce (11)
- LICENSE 1 KB
- README.md 1 KB
- SKILL.md 6 KB
- assets/report-template.md 1 KB
- references/modules-state.md 2 KB
- references/performance-cost.md 2 KB
- references/plan-safety.md 2 KB
- references/security-secrets.md 2 KB
- references/testing-ci.md 2 KB
- references/tooling.md 2 KB
- scripts/audit.py 11 KB
Wersje
W bazie nie ma innych skilli o nazwie terraform-optimizer.
Migawka bazy z 13.11.2026 · wersja paczki 839558a2c0c4 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100terraform-patterns
Stosuje sprawdzone wzorce Terraform: zdalny stan z blokadą S3, strukturę modułów, środowiska i potok CI z planem oraz apply. - 100terraform-ops
Prowadzi operacje w Terraform i OpenTofu: układ projektu, stan, moduły, bezpieczne plan i apply, pipeline'y CI/CD, sekrety, wykrywanie dryfu oraz tflint i checkov. - 100terraform
Obsługuje Terraform i OpenTofu w całym cyklu infrastruktury: struktura modułów, backendy stanu i blokady, plan i apply, wykrywanie dryfu, import, refaktoryzacja i diagnostyka oparta na dowodach, ze skryptem tfops. - 100trove-terraform
Podaje konwencje Terraform i OpenTofu: strukturę modułów, zarządzanie stanem i wzorce bezpieczeństwa. - 95glab-opentofu
Zarządza stanem OpenTofu w GitLab: konfiguruje backendy stanu i obsługuje infrastrukturę jako kod. - 100terraform-bump-terraform
Aktualizuje CLI Terraform lub OpenTofu w ograniczeniach modułów, plikach menedżera wersji, CI i obrazach.