How sm-joe/tf-iam works
tf-iam is a Python CLI for deriving reviewable, least-privilege AWS IAM policy candidates from Terraform configuration or saved plans. The main workflow enters through the CLI, analyzes configuration and lifecycle operations, resolves provider and resource context, then derives scoped permissions for reporting or policy generation. Separate CLI commands support comparison, policy packing, catalog/provider audits, IAM validation, and CloudTrail runtime auditing. Edges follow shown imports and documented command capabilities; unsampled implementation details are not inferred.
Main entry points: scan.py Configuration scan · cli.py Command interface · catalog_loader.py AWS permissions catalog · provider_audit.py Provider audit
Components 25
CLI and reporting
- Command interface
tfiam/cli.py - Report rendering
tfiam/table_output.py
Terraform analysis
- Configuration scan
tfiam/scan.py - Saved-plan parser
tfiam/plan.py - Static resolver
tfiam/resolver.py - Provider contexts
tfiam/provider_context.py - Provider versioning
tfiam/versioning.py - Bucket recovery
tfiam/plan_buckets.py - Role recovery
tfiam/plan_roles.py - Dependency discovery
tfiam/dependencies.py
Permission modeling
- AWS permissions catalog
tfiam/catalog_loader.py - Network plan scope
tfiam/plan_network.py - Action-specific scopes
tfiam/action_scope.py - Service scopes
tfiam/service_scope.py - Expanded scope
tfiam/expanded_scope.py - Grant optimization
tfiam/optimization.py
Review and integrations
- Risk assessment
tfiam/risk.py - Policy comparison
tfiam/comparison.py - Lifecycle separation
tfiam/lifecycle.py - Policy packing
tfiam/policy_size.py - Authorization metadata audit
tfiam/authorization.py - Provider audit
tfiam/provider_audit.py - Evidence audit
tfiam/evidence_audit.py - AWS and CloudTrail
tfiam/cloud.py
Other components
- Security engineer
Connections 29
- Security engineer → Command interface: runs commands
README.md - Command interface → Configuration scan: invokes scan
tfiam/cli.py - Configuration scan → Saved-plan parser: parses plans
tfiam/scan.py - Configuration scan → Static resolver: resolves values
tfiam/scan.py - Configuration scan → Provider contexts: selects contexts
tfiam/scan.py - Configuration scan → Provider versioning: selects version
tfiam/scan.py - Configuration scan → AWS permissions catalog: loads mappings
tfiam/scan.py - Configuration scan → Bucket recovery: recovers buckets
tfiam/scan.py - Configuration scan → Role recovery: recovers roles
tfiam/scan.py - Configuration scan → Dependency discovery: discovers dependencies
tfiam/scan.py - Configuration scan → Network plan scope: uses network scope
tfiam/scan.py - Configuration scan → Action-specific scopes: uses action scopes
tfiam/scan.py - Configuration scan → Service scopes: uses service scopes
tfiam/scan.py - Configuration scan → Expanded scope: expands scopes
tfiam/scan.py - Configuration scan → Grant optimization: optimizes grants
tfiam/scan.py - Configuration scan → Risk assessment: assesses risks
tfiam/scan.py - Command interface → Report rendering: renders reports
tfiam/cli.py - Command interface → Policy comparison: compares grants
tfiam/cli.py - Command interface → Lifecycle separation: splits candidates
tfiam/cli.py - Command interface → Policy packing: packs policies
tfiam/cli.py - Command interface → Authorization metadata audit: audits metadata
tfiam/cli.py - Command interface → Provider audit: audits provider
tfiam/cli.py - Command interface → Evidence audit: audits evidence
tfiam/cli.py - Command interface → AWS and CloudTrail: runs AWS checks
tfiam/cli.py - AWS permissions catalog → Provider versioning: selects overrides
tfiam/catalog_loader.py - Authorization metadata audit → AWS permissions catalog: checks mappings
tfiam/authorization.py - Provider audit → AWS permissions catalog: checks mappings
tfiam/provider_audit.py - Provider audit → Provider versioning: checks versions
tfiam/provider_audit.py - AWS and CloudTrail → Authorization metadata audit: uses metadata
tfiam/cloud.py