detect-orphaned-resources-outside-state
Use when live resources may exist that no state file tracks. Cross-checks the cloud inventory against state so untracked resources, their cost and risk, are surfaced.
- License 许可
- MIT
- 最近更新
- 2026-11-13
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- detect-orphaned-resources-outside-state
- description
- Use when live resources may exist that no state file tracks. Cross-checks the cloud inventory against state so untracked resources, their cost and risk, are surfaced.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md365 B
- 参考文档TRUST.auto.yaml2.2 KB
03 SKILL.md 正文
Detect orphaned resources outside state
Resources created by hand or left by a deleted stack persist and bill while no code claims them. Detect them by diffing the cloud inventory against state.
Procedure
- Export tracked IDs from state: terraform state list | xargs -I{} terraform state show {} | grep -E '^\s+id\s+=' | awk '{print $3}' | sort -u > tracked.txt
- Export live IDs for the resource types you manage: aws ec2 describe-instances --query 'Reservations[].Instances[].InstanceId' --output text | tr '\t' '\n' | sort -u > live.txt
- Diff to find untracked resources (present in cloud, absent from state): comm -13 tracked.txt live.txt
- Repeat per resource type; IDs are only meaningful within a type, so scope the diff (EC2 instance IDs vs volume IDs).
- Classify each orphan: adopt (import + code), delete (nobody owns it), or quarantine (unknown owner, tag and alarm).
- Prefer cloud-native inventory for breadth: AWS Config
list-discovered-resources, GCP Asset Inventory, Azure Resource Graph. - Run monthly, not once; manual creations and deleted stacks both produce orphans continuously.
- Alert on new orphans in a shared account so each gets an owner within a week.
Pitfalls
-
Diffing IDs across mismatched types, producing a page of false positives.
-
Adopting an orphan whose real owner uses it out of band, then destroying it in a later plan.
-
A provider id attribute in a different format than the API returns (case, prefix), so a tracked resource looks orphaned.
-
Imports tracked in a different workspace appear as "cloud, not state" from this one.
-
Deleting an orphan that is actually a required shared resource (a peering connection, a DNS zone) with no code.
-
terraform state showfailing on a resource with sensitive attributes, so the tracked list is silently incomplete. -
A resource shared across two states appears tracked in one and orphaned in the other's diff.
Verification
comm -13 tracked.txt live.txt | wc -l # count of untracked resources
terraform state list | wc -l # count tracked
Report: orphan counts by type, the decision per orphan (adopt/delete/quarantine), and the resulting change in the diff.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.