How nsiow/yams works
Project type and purpose
• This is a Go-based simulation tool (“yams”) for AWS IAM, exposing both a CLI (multiple subcommands) and an HTTP API/server.
• Its purpose is to load IAM configuration (from AWS Config dumps, JSON files, etc.), build an in-memory model (“universe”) of AWS IAM entities, and run permission simulations.
File structure
• Top-level “cmd/yams” directory holds entrypoints for subcommands:
• cli/… implements the interactive CLI, flag parsing, logging, ASCII art, and invoking each command
• dump, inventory, sim, status, server subdirectories contain subcommand drivers
• “pkg/…” holds reusable packages:
• pkg/server – HTTP routing, handlers, API v1 endpoints, healthchecks
• pkg/sim – the simulation engine, decision logic, tracing, gates
• pkg/loaders – AWS Config loader adapter
• pkg/policy, pkg/entities, pkg/aws – domain model for IAM policy, entities, AWS types
• “internal/…” holds implementation details not exposed as part of public API:
• internal/assets – embedded policy/managed-policy JSON
• internal/smartrw – I/O abstractions for gzip, S3, stdout
• internal/log, internal/common, internal/testlib – support libs and tests
• “misc/…” contains cloudformation templates and helper scripts.
• Configuration and orchestration: Makefile, CI workflows, go.mod, testdata for unit and integration tests.
Additional README insights
• Confirms it is a simulation tool for AWS IAM.
a. Main components (group into logical layers):
1. Presentation Layer
• CLI Frontend (cmd/yams/cli + subcommands: dump, inventory, sim, status)
• REST API Server (cmd/yams/server → pkg/server)
2. Application Core
• Simulation Engine (pkg/sim)
• Universe Builder (pkg/entities + loaders)
• Policy Evaluator (pkg/policy)
3. Infrastructure & Adapters
• AWS Config Loader adapter (pkg/loaders/awsconfig)
• I/O adapters: S3 Reader/Writer, gzip, stdout (internal/smartrw)
• Embedded asset provider (internal/assets)
• Logging (internal/log), common utilities (internal/common)
4. Data & External Services
• AWS Config files (JSON, JSONL, gzipped)
• AWS APIs (for live data, optional)
• CloudFormation templates (misc/cf-templates)
b. Relationships & interactions
• CLI/Server → calls into Application Core
• Simulation Engine uses:
• Universe Builder to load and construct IAM entity graph
• Policy Evaluator to run decision logic on that graph
• Adapters supply data:
• AWS Config Loader reads JSON/JSONL → Entities
• smartrw abstracts reading from file/S3/gzip
• internal/assets supplies bundled policies
• Server handlers wrap the same core logic to serve HTTP requests (list, get, sim, search).
c. Architectural patterns & design principles
• Layered (onion/hexagonal) architecture: core logic isolated from I/O & UI
• Dependency inversion: core depends on interfaces (loaders, readers), implementations live in adapters
• Single binary delivering CLI + HTTP server
• Reuse of packages: “pkg/…” for public APIs, “internal/…” for private helpers
d. Key technologies/frameworks
• Go modules, standard net/http for the server
• Cobra or custom flag parsing in cli/flags.go
• gzip, AWS SDK abstractions for config ingestion
• Go’s embed-style asset bundling (internal/assets)