Skip to content

Asset inventory and tag-grouped diagram from plan and synth output (#115) - #165

Open
ms280690 wants to merge 3 commits into
issue-114-taggingfrom
issue-115-asset-inventory
Open

ms280690 wants to merge 3 commits into
issue-114-taggingfrom
issue-115-asset-inventory

Conversation

@ms280690

Copy link
Copy Markdown
Collaborator

Closes #115. Stacked on #164 (issue-114-tagging) for the tagging standard; retarget once that merges. The plan and synth artefacts are produced by the caller (the shared plan step from #89/#93 and the CDK synth from #90/#94 are not built yet), which is how the issue's plan-artifact input is defined anyway.

What

  • .github/actions/asset-inventory/inventory.py (stdlib): OpenTofu parser walks planned_values.root_module and nested child_modules, so module, for_each and count instances appear by full address; tags from tags_all, tags, effective_labels or labels; region from configuration.provider_config; data sources skipped; a type with no tags attribute is taggable: false and never gets violations. CDK parser reads every *.template.json, tags from Properties.Tags, source.path from Metadata["aws:cdk:path"], AWS::CDK::Metadata skipped, taggable by a known-type list or Tags presence. tag_violations lists missing required keys (values are the feat: inventory — tagging standard and PR-time enforcement across IaC stacks #114 gate's job). Plan JSON carries no source positions, so source.path/line are null for OpenTofu and account is null unless given (documented).
  • Renderers: Graphviz DOT (SVG via dot, present on hosted runners) and Mermaid, both clustered project, environment, owner, filled by data-class, violations outlined red. The report embeds Mermaid up to mermaid-max-nodes, else points at the SVG artefact.
  • Diff against a base inventory.json: added, removed, retagged (id, key, before, after); owner changes bold in the report. Report carries the <!-- asset-inventory --> marker.
  • Schema: docs/asset-inventory.schema.json (draft 2020-12); docs/asset-inventory.md documents fields, limits, publishing, and inframap/cdk-dia as unwired add-ons.
  • Composite: inputs stack, input-dir, required-tags, account, base-inventory, mermaid-max-nodes, output-dir; outputs resource-count, violation-count, added-count, report-path; writes SHA256SUMS. Never fails on findings.
  • asset-inventory.yml: inputs from the issue plus required-tags, account, comment, actions-ref. Downloads plan-artifact; on PRs fetches inventory.json from the repo's asset-inventory-latest release (notice if none) and keeps one PR comment (fork PRs skipped); on pushes to the default branch with publish creates or updates that rolling release with inventory.json, inventory.svg, inventory.mmd, SHA256SUMS. Artefact always uploaded.
  • CI Asset Inventory job: fixtures suite (installs check-jsonschema), composite on the OpenTofu fixture with the base inventory and on the CDK fixture, output and SVG assertions, SHA256SUMS check. README rows and section.

Tests

tests/asset-inventory/run.sh: exact resource sets for the OpenTofu fixture (two stacks, child and nested modules, for_each keys, count index, Google labels, untaggable random_id, data source skipped) and the CDK fixture (taggable role without tags, partially tagged topic, untaggable permission, metadata skipped); --account and --required-tags; diff categories and the bold owner change; DOT and Mermaid snapshots (fixtures/expected); Mermaid threshold; SVG render when dot is present; schema validation of three inventories with check-jsonschema; empty input and usage errors.

Deferred

🤖 Generated with Claude Code

https://claude.ai/code/session_01NPH9145e4gFo6bmXvMgBoF

…th output

inventory.py turns OpenTofu plan JSON (root and child modules, for_each and
count instances by full address) or CDK synth templates into inventory.json:
one record per managed resource with type, stack, region, tags, the required
tags it is missing, and the source path where the input carries one. It
renders a Graphviz diagram (DOT and SVG) and a Mermaid block clustered by
project, environment and owner, filled by data-class with violations outlined
in red, and diffs against a base inventory into added, removed and retagged
resources. The schema lives in docs/asset-inventory.schema.json.

The composite wraps the script and writes SHA256SUMS. asset-inventory.yml
downloads the caller's plan artefact, fetches the last published
inventory.json from the repo's asset-inventory-latest release for the PR
diff, keeps one PR comment, and on pushes to the default branch publishes
the register to that rolling release.

tests/asset-inventory/run.sh covers both parsers, taggable heuristics, the
diff, DOT and Mermaid snapshots, the schema and the usage errors; CI runs it
and the composite on the fixtures.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPH9145e4gFo6bmXvMgBoF
@ms280690 ms280690 self-assigned this Oct 12, 2026
Comment thread tests/asset-inventory/run.sh Fixed
ms280690 and others added 2 commits October 11, 2026 19:12
Current GitHub-hosted images do not ship dot, so the SVG was missing and
SHA256SUMS failed. Also a shellcheck SC2016 on a backticked grep in the
test script.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPH9145e4gFo6bmXvMgBoF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants